diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2010-07-16 19:11:23 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2010-07-16 19:11:23 (GMT) |
commit | 43939338354e314f5c39e3d0b3568041b51dc3b9 (patch) | |
tree | 92175eedf7d03a5d8fac394e9840f3c1cabaf81b | |
parent | bd39f9553a30edaa8aa298d946e0d8f2b14d9886 (diff) | |
download | cpython-43939338354e314f5c39e3d0b3568041b51dc3b9.zip cpython-43939338354e314f5c39e3d0b3568041b51dc3b9.tar.gz cpython-43939338354e314f5c39e3d0b3568041b51dc3b9.tar.bz2 |
Merged revisions 82919 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k
........
r82919 | antoine.pitrou | 2010-07-16 21:10:38 +0200 (ven., 16 juil. 2010) | 4 lines
Fix possible failure in pickling tests due to different instantiations
of the random module being around.
........
-rw-r--r-- | Lib/test/test_threaded_import.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/Lib/test/test_threaded_import.py b/Lib/test/test_threaded_import.py index 5b96d87..6cedb96 100644 --- a/Lib/test/test_threaded_import.py +++ b/Lib/test/test_threaded_import.py @@ -27,6 +27,16 @@ def task(N, done, done_tasks, errors): class ThreadedImportTests(unittest.TestCase): + def setUp(self): + self.old_random = sys.modules.pop('random', None) + + def tearDown(self): + # If the `random` module was already initialized, we restore the + # old module at the end so that pickling tests don't fail. + # See http://bugs.python.org/issue3657#msg110461 + if self.old_random is not None: + sys.modules['random'] = self.old_random + def test_parallel_module_init(self): if imp.lock_held(): # This triggers on, e.g., from test import autotest. |