cpython: dbb9c23e1887 (original) (raw)
Mercurial > cpython
changeset 87942:dbb9c23e1887
Issue #19704: Port test.test_threaded_import to PEP 451 [#19704]
Brett Cannon brett@python.org | |
---|---|
date | Fri, 13 Dec 2013 16:47:19 -0500 |
parents | 33938321d46f |
children | f2c6b0485ce6 |
files | Lib/test/test_threaded_import.py |
diffstat | 1 files changed, 6 insertions(+), 6 deletions(-)[+] [-] Lib/test/test_threaded_import.py 12 |
line wrap: on
line diff
--- a/Lib/test/test_threaded_import.py +++ b/Lib/test/test_threaded_import.py @@ -57,7 +57,7 @@ circular_imports_modules = { } class Finder:
- """A dummy finder to detect concurrent access to its find_spec() method.""" def init(self): @@ -65,8 +65,8 @@ class Finder: self.x = 0 self.lock = threading.Lock()
- def find_module(self, name, path=None):
# Simulate some thread-unsafe behaviour. If calls to find_module()[](#l1.17)
- def find_spec(self, name, path=None, target=None):
# Simulate some thread-unsafe behaviour. If calls to find_spec()[](#l1.19) # are properly serialized, `x` will end up the same as `numcalls`.[](#l1.20) # Otherwise not.[](#l1.21) assert imp.lock_held()[](#l1.22)
@@ -80,7 +80,7 @@ class FlushingFinder: """A dummy finder which flushes sys.path_importer_cache when it gets called."""
@@ -145,13 +145,13 @@ class ThreadedImportTests(unittest.TestC # dedicated meta_path entry. flushing_finder = FlushingFinder() def path_hook(path):
finder.find_module('')[](#l1.36)
finder.find_spec('')[](#l1.37) raise ImportError[](#l1.38) sys.path_hooks.insert(0, path_hook)[](#l1.39) sys.meta_path.append(flushing_finder)[](#l1.40) try:[](#l1.41) # Flush the cache a first time[](#l1.42)
flushing_finder.find_module('')[](#l1.43)
flushing_finder.find_spec('')[](#l1.44) numtests = self.check_parallel_module_init()[](#l1.45) self.assertGreater(finder.numcalls, 0)[](#l1.46) self.assertEqual(finder.x, finder.numcalls)[](#l1.47)