[Python-checkins] r82919 - python/branches/py3k/Lib/test/test_threaded_import.py
antoine.pitrou
python-checkins at python.org
Fri Jul 16 21:10:38 CEST 2010
Author: antoine.pitrou
Date: Fri Jul 16 21:10:38 2010
New Revision: 82919
Log:
Fix possible failure in pickling tests due to different instantiations
of the random module being around.
Modified:
python/branches/py3k/Lib/test/test_threaded_import.py
Modified: python/branches/py3k/Lib/test/test_threaded_import.py
==============================================================================
--- python/branches/py3k/Lib/test/test_threaded_import.py (original)
+++ python/branches/py3k/Lib/test/test_threaded_import.py Fri Jul 16 21:10:38 2010
@@ -27,6 +27,16 @@
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.
More information about the Python-checkins
mailing list