summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_importlib/test_api.py
diff options
context:
space:
mode:
authorEric Snow <ericsnowcurrently@gmail.com>2016-05-10 22:21:03 (GMT)
committerEric Snow <ericsnowcurrently@gmail.com>2016-05-10 22:21:03 (GMT)
commit228ab1ff6b5b02d8325a678b8afc140a153d4cf5 (patch)
tree416073624d9b0c50297ec609419fcd56f2a413e8 /Lib/test/test_importlib/test_api.py
parent3fa86a0612cd5d427aa36794822047fc58757b2e (diff)
downloadcpython-228ab1ff6b5b02d8325a678b8afc140a153d4cf5.zip
cpython-228ab1ff6b5b02d8325a678b8afc140a153d4cf5.tar.gz
cpython-228ab1ff6b5b02d8325a678b8afc140a153d4cf5.tar.bz2
Issue #21099: Switch applicable importlib tests to use PEP 451 API.
Diffstat (limited to 'Lib/test/test_importlib/test_api.py')
-rw-r--r--Lib/test/test_importlib/test_api.py31
1 files changed, 25 insertions, 6 deletions
diff --git a/Lib/test/test_importlib/test_api.py b/Lib/test/test_importlib/test_api.py
index 6bc3c56..b0a94aa 100644
--- a/Lib/test/test_importlib/test_api.py
+++ b/Lib/test/test_importlib/test_api.py
@@ -99,9 +99,7 @@ class ImportModuleTests:
class FindLoaderTests:
- class FakeMetaFinder:
- @staticmethod
- def find_module(name, path=None): return name, path
+ FakeMetaFinder = None
def test_sys_modules(self):
# If a module with __loader__ is in sys.modules, then return it.
@@ -171,9 +169,30 @@ class FindLoaderTests:
self.assertIsNone(self.init.find_loader('nevergoingtofindthismodule'))
-(Frozen_FindLoaderTests,
- Source_FindLoaderTests
- ) = test_util.test_both(FindLoaderTests, init=init)
+class FindLoaderPEP451Tests(FindLoaderTests):
+
+ class FakeMetaFinder:
+ @staticmethod
+ def find_spec(name, path=None, target=None):
+ return machinery['Source'].ModuleSpec(name, (name, path))
+
+
+(Frozen_FindLoaderPEP451Tests,
+ Source_FindLoaderPEP451Tests
+ ) = test_util.test_both(FindLoaderPEP451Tests, init=init)
+
+
+class FindLoaderPEP302Tests(FindLoaderTests):
+
+ class FakeMetaFinder:
+ @staticmethod
+ def find_module(name, path=None):
+ return name, path
+
+
+(Frozen_FindLoaderPEP302Tests,
+ Source_FindLoaderPEP302Tests
+ ) = test_util.test_both(FindLoaderPEP302Tests, init=init)
class ReloadTests: