summaryrefslogtreecommitdiff
path: root/Lib/test/test_pkg.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_pkg.py')
-rw-r--r--Lib/test/test_pkg.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/Lib/test/test_pkg.py b/Lib/test/test_pkg.py
index dcc7433176..db8e844215 100644
--- a/Lib/test/test_pkg.py
+++ b/Lib/test/test_pkg.py
@@ -46,6 +46,7 @@ class TestPkg(unittest.TestCase):
def setUp(self):
self.root = None
+ self.pkgname = None
self.syspath = list(sys.path)
self.sysmodules = sys.modules.copy()
@@ -56,6 +57,13 @@ class TestPkg(unittest.TestCase):
del self.sysmodules
cleanout(self.root)
+ # delete all modules concerning the tested hiearchy
+ if self.pkgname:
+ modules = [name for name in sys.modules
+ if self.pkgname in name.split('.')]
+ for name in modules:
+ del sys.modules[name]
+
def run_code(self, code):
exec(textwrap.dedent(code), globals(), {"self": self})
@@ -78,6 +86,8 @@ class TestPkg(unittest.TestCase):
f.write('\n')
f.close()
self.root = root
+ # package name is the name of the first item
+ self.pkgname = descr[0][0]
def test_1(self):
hier = [("t1", None), ("t1 __init__.py", "")]