summaryrefslogtreecommitdiff
path: root/Lib
diff options
context:
space:
mode:
authorJoannah Nanjekye <33177550+nanjekyejoannah@users.noreply.github.com>2019-06-21 15:17:00 -0300
committerBrett Cannon <54418+brettcannon@users.noreply.github.com>2019-06-21 11:17:00 -0700
commita0d73a143af404deecb9c4fcdbd3ddbafd96b41b (patch)
tree976f468e9437ca49a1432fde8b5a3b58007b5ec5 /Lib
parentf8dd77d36067fd7be614edde1e5e9e7467c450dc (diff)
downloadcpython-git-a0d73a143af404deecb9c4fcdbd3ddbafd96b41b.tar.gz
bpo-30202 : Update test.test_importlib.test_abc to test find_spec() (GH-12847)
Diffstat (limited to 'Lib')
-rwxr-xr-x[-rw-r--r--]Lib/test/test_importlib/test_abc.py21
1 files changed, 17 insertions, 4 deletions
diff --git a/Lib/test/test_importlib/test_abc.py b/Lib/test/test_importlib/test_abc.py
index 05608bbb8b..9816b35ef8 100644..100755
--- a/Lib/test/test_importlib/test_abc.py
+++ b/Lib/test/test_importlib/test_abc.py
@@ -357,13 +357,27 @@ class MetaPathFinderFindModuleTests:
return MetaPathSpecFinder()
- def test_no_spec(self):
+ def test_find_module(self):
finder = self.finder(None)
path = ['a', 'b', 'c']
name = 'blah'
with self.assertWarns(DeprecationWarning):
found = finder.find_module(name, path)
self.assertIsNone(found)
+
+ def test_find_spec_with_explicit_target(self):
+ loader = object()
+ spec = self.util.spec_from_loader('blah', loader)
+ finder = self.finder(spec)
+ found = finder.find_spec('blah', 'blah', None)
+ self.assertEqual(found, spec)
+
+ def test_no_spec(self):
+ finder = self.finder(None)
+ path = ['a', 'b', 'c']
+ name = 'blah'
+ found = finder.find_spec(name, path, None)
+ self.assertIsNone(found)
self.assertEqual(name, finder.called_for[0])
self.assertEqual(path, finder.called_for[1])
@@ -371,9 +385,8 @@ class MetaPathFinderFindModuleTests:
loader = object()
spec = self.util.spec_from_loader('blah', loader)
finder = self.finder(spec)
- with self.assertWarns(DeprecationWarning):
- found = finder.find_module('blah', None)
- self.assertIs(found, spec.loader)
+ found = finder.find_spec('blah', None)
+ self.assertIs(found, spec)
(Frozen_MPFFindModuleTests,