summaryrefslogtreecommitdiff
path: root/Lib/test/test_pkg.py
diff options
context:
space:
mode:
authorAmaury Forgeot d'Arc <amauryfa@gmail.com>2008-04-18 23:31:33 +0000
committerAmaury Forgeot d'Arc <amauryfa@gmail.com>2008-04-18 23:31:33 +0000
commit607bff1ebe81e869697e228322da4c308e8753a5 (patch)
treeab9126adaba09e9c1cd436b1ca76c5ac3d67eb3c /Lib/test/test_pkg.py
parent6f34109384f3a78d5f4f8bdd418a89caca19631e (diff)
downloadcpython-git-607bff1ebe81e869697e228322da4c308e8753a5.tar.gz
Some tests did not pass on repeated calls (regrtest -R::)
Perform additional cleanup, mostly deleting from sys.modules, or clearing the warnings registry.
Diffstat (limited to 'Lib/test/test_pkg.py')
-rw-r--r--Lib/test/test_pkg.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/Lib/test/test_pkg.py b/Lib/test/test_pkg.py
index 4fa367f560..3a954ca366 100644
--- a/Lib/test/test_pkg.py
+++ b/Lib/test/test_pkg.py
@@ -46,12 +46,20 @@ class Test(unittest.TestCase):
def setUp(self):
self.root = None
+ self.pkgname = None
self.syspath = list(sys.path)
def tearDown(self):
sys.path[:] = self.syspath
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})
@@ -74,6 +82,8 @@ class Test(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__"+os.extsep+"py", "")]
@@ -223,8 +233,8 @@ class Test(unittest.TestCase):
def test_7(self):
hier = [
- ("t7"+os.extsep+"py", ""),
("t7", None),
+ ("t7"+os.extsep+"py", ""),
("t7 __init__"+os.extsep+"py", ""),
("t7 sub"+os.extsep+"py",
"raise RuntimeError('Shouldnt load sub.py')"),