diff options
author | Brett Cannon <brett@python.org> | 2012-04-17 00:48:50 (GMT) |
---|---|---|
committer | Brett Cannon <brett@python.org> | 2012-04-17 00:48:50 (GMT) |
commit | ceffda822f4caa26cd6dd5e0bf753c35e6bbcb80 (patch) | |
tree | ce34c23db35c00a8f0ff5ba7b564960df005c758 /Lib/test/test_reprlib.py | |
parent | de10bf4f4d655eef5e015931ef9891d6989887e9 (diff) | |
download | cpython-ceffda822f4caa26cd6dd5e0bf753c35e6bbcb80.zip cpython-ceffda822f4caa26cd6dd5e0bf753c35e6bbcb80.tar.gz cpython-ceffda822f4caa26cd6dd5e0bf753c35e6bbcb80.tar.bz2 |
Issue #14599: Make test_reprlib robust against import cache race
conditions when regrtest is run with its -j option.
Diffstat (limited to 'Lib/test/test_reprlib.py')
-rw-r--r-- | Lib/test/test_reprlib.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/Lib/test/test_reprlib.py b/Lib/test/test_reprlib.py index e75ba1c..eb2b17a 100644 --- a/Lib/test/test_reprlib.py +++ b/Lib/test/test_reprlib.py @@ -213,6 +213,8 @@ class LongReprTest(unittest.TestCase): # Remember where we are self.here = os.getcwd() sys.path.insert(0, self.here) + # When regrtest is run with its -j option, this command alone is not + # enough. importlib.invalidate_caches() def tearDown(self): @@ -233,6 +235,7 @@ class LongReprTest(unittest.TestCase): def test_module(self): eq = self.assertEqual create_empty_file(os.path.join(self.subpkgname, self.pkgname + '.py')) + importlib.invalidate_caches() from areallylongpackageandmodulenametotestreprtruncation.areallylongpackageandmodulenametotestreprtruncation import areallylongpackageandmodulenametotestreprtruncation eq(repr(areallylongpackageandmodulenametotestreprtruncation), "<module %r from %r>" % (areallylongpackageandmodulenametotestreprtruncation.__name__, areallylongpackageandmodulenametotestreprtruncation.__file__)) @@ -244,6 +247,7 @@ class LongReprTest(unittest.TestCase): class foo(object): pass ''') + importlib.invalidate_caches() from areallylongpackageandmodulenametotestreprtruncation.areallylongpackageandmodulenametotestreprtruncation import foo eq(repr(foo.foo), "<class '%s.foo'>" % foo.__name__) @@ -258,6 +262,7 @@ class foo(object): class bar: pass ''') + importlib.invalidate_caches() from areallylongpackageandmodulenametotestreprtruncation.areallylongpackageandmodulenametotestreprtruncation import bar # Module name may be prefixed with "test.", depending on how run. self.assertEqual(repr(bar.bar), "<class '%s.bar'>" % bar.__name__) @@ -267,6 +272,7 @@ class bar: class baz: pass ''') + importlib.invalidate_caches() from areallylongpackageandmodulenametotestreprtruncation.areallylongpackageandmodulenametotestreprtruncation import baz ibaz = baz.baz() self.assertTrue(repr(ibaz).startswith( @@ -278,6 +284,7 @@ class baz: class aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa: def amethod(self): pass ''') + importlib.invalidate_caches() from areallylongpackageandmodulenametotestreprtruncation.areallylongpackageandmodulenametotestreprtruncation import qux # Unbound methods first r = repr(qux.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.amethod) |