From 2bdfbaea138642f21117ffa89f2951890b8af5b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Thu, 7 Jul 2016 14:59:22 +0200 Subject: [PATCH] Test tearDown: remove all 'application.xxx' submodules from sys.modules This ensures that the modules are reloaded for every test, for better test separation. --- tests/common_test_class.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/common_test_class.py b/tests/common_test_class.py index 9bb9fd67..034cc2f5 100644 --- a/tests/common_test_class.py +++ b/tests/common_test_class.py @@ -69,6 +69,10 @@ class AbstractPillarTest(TestMinimal): # Not only delete self.app (like the superclass does), # but also un-import the application. del sys.modules['application'] + remove = [modname for modname in sys.modules + if modname.startswith('application.')] + for modname in remove: + del sys.modules[modname] def ensure_file_exists(self, file_overrides=None): self.ensure_project_exists()