Development #41813
tests: utiliser une fixture autouse pour le nettoyage du cache
0%
Description
Plutôt que de taper des cache.clear()
un peu partout dans les tests.
Fichiers
Demandes liées
Révisions associées
Historique
Mis à jour par Paul Marillonnet il y a environ 4 ans
- Fichier 0001-tests-add-cache-clearance-autouse-fixture-41813.patch 0001-tests-add-cache-clearance-autouse-fixture-41813.patch ajouté
- Statut changé de Nouveau à Solution proposée
- Patch proposed changé de Non à Oui
Mis à jour par Paul Marillonnet il y a environ 4 ans
Cf #41489-16:
Pour les tests unitaires le plus simple c'est de de vider le cache entre les tests, si ça pose un souci, c'est déjà fait ponctuellement mais ça devrait être la politique générale avec une fixture
clear_cache(autouse=True)
dans conftest.py.
Mis à jour par Paul Marillonnet il y a environ 4 ans
- Lié à Development #41489: ratelimiting sur les interfaces envoyant des emails ajouté
Mis à jour par Paul Marillonnet il y a environ 4 ans
- Fichier 0001-tests-add-cache-clearance-autouse-fixture-41813.patch 0001-tests-add-cache-clearance-autouse-fixture-41813.patch ajouté
Avec suppression de l'import inutilisé, quand même…
Mis à jour par Benjamin Dauvergne il y a environ 4 ans
Paul Marillonnet a écrit :
Avec suppression de l'import inutilisé, quand même…
Y aussi le cache des hooks et quelques autres (à vérifier certains viennent d'intéractions au sein d'un même test, il ne faut pas forcément supprimer la ligne dans le test) :
$ git grep '\.clear' tests tests/auth_fc/conftest.py: hooks.get_hooks.cache.clear() tests/auth_fc/conftest.py: hook.clear() tests/conftest.py: hooks.get_hooks.cache.clear() tests/conftest.py: hook.clear() tests/test_auth_oidc.py: get_provider.cache.clear() tests/test_auth_oidc.py: get_provider_by_issuer.cache.clear() tests/test_auth_oidc.py: OU.cached.cache.clear() tests/test_auth_oidc.py: get_providers.cache.clear() tests/test_auth_oidc.py: has_providers.cache.clear() tests/test_auth_oidc.py: get_providers.cache.clear() tests/test_auth_oidc.py: has_providers.cache.clear() tests/test_auth_oidc.py: get_providers.cache.clear() tests/test_auth_oidc.py: has_providers.cache.clear() tests/test_auth_oidc.py: get_providers.cache.clear() tests/test_auth_oidc.py: has_providers.cache.clear() tests/test_auth_oidc.py: get_providers.cache.clear() tests/test_auth_oidc.py: has_providers.cache.clear() tests/test_idp_oidc.py: cache.clear() tests/test_idp_oidc.py: cache.clear() tests/test_idp_oidc.py: cache.clear() tests/test_idp_oidc.py: cache.clear() tests/test_idp_oidc.py: cache.clear() tests/test_idp_oidc.py: cache.clear() tests/test_idp_oidc.py: cache.clear() tests/test_idp_oidc.py: cache.clear() tests/test_idp_oidc.py: cache.clear() tests/test_idp_oidc.py: cache.clear() tests/test_idp_oidc.py: cache.clear() tests/test_idp_oidc.py: cache.clear() tests/test_login.py: app.cookiejar.clear() <- ça non tests/test_manager.py: get_ou_count.cache.clear() tests/test_user_manager.py: has_show_username.cache.clear() tests/test_user_manager.py: has_show_username.cache.clear()
Mis à jour par Paul Marillonnet il y a environ 4 ans
- Fichier 0001-tests-add-cache-clearance-autouse-fixture-41813.patch 0001-tests-add-cache-clearance-autouse-fixture-41813.patch ajouté
Benjamin Dauvergne a écrit :
Y aussi le cache des hooks et quelques autres (à vérifier certains viennent d'intéractions au sein d'un même test, il ne faut pas forcément supprimer la ligne dans le test) :
[...]
Ah oui en effet, merci. Quelque chose comme ça, je pense.
Mis à jour par Benjamin Dauvergne il y a environ 4 ans
Paul Marillonnet a écrit :
Benjamin Dauvergne a écrit :
Y aussi le cache des hooks et quelques autres (à vérifier certains viennent d'intéractions au sein d'un même test, il ne faut pas forcément supprimer la ligne dans le test) :
[...]Ah oui en effet, merci. Quelque chose comme ça, je pense.
Il manque l'ajout des différents cache.clear() dans la fixture clear_cache() (c'est plein de caches différents en fait).
Mis à jour par Paul Marillonnet il y a environ 4 ans
- Fichier 0001-tests-add-cache-clearance-autouse-fixture-41813.patch 0001-tests-add-cache-clearance-autouse-fixture-41813.patch ajouté
Benjamin Dauvergne a écrit :
Il manque l'ajout des différents cache.clear() dans la fixture clear_cache() (c'est plein de caches différents en fait).
Oui complètement…
Je pense avoir tout pris en compte ici.
Mis à jour par Paul Marillonnet il y a environ 4 ans
Mis à jour par Benjamin Dauvergne il y a environ 4 ans
- Statut changé de Solution proposée à Solution validée
Mis à jour par Paul Marillonnet il y a environ 4 ans
- Statut changé de Solution validée à Résolu (à déployer)
commit 0d42dd46d67ac9a7028493b14e9314e250cbbe0f Author: Paul Marillonnet <pmarillonnet@entrouvert.com> Date: Fri Apr 17 10:46:28 2020 +0200 tests: add cache clearance autouse fixture (#41813)
Mis à jour par Frédéric Péters il y a environ 4 ans
- Statut changé de Résolu (à déployer) à Solution déployée
tests: add cache clearance autouse fixture (#41813)