]> granicus.if.org Git - python/commitdiff
bpo-30202 : Update test.test_importlib.test_abc to test find_spec() (GH-12847)
authorJoannah Nanjekye <33177550+nanjekyejoannah@users.noreply.github.com>
Fri, 21 Jun 2019 18:17:00 +0000 (15:17 -0300)
committerBrett Cannon <54418+brettcannon@users.noreply.github.com>
Fri, 21 Jun 2019 18:17:00 +0000 (11:17 -0700)
Lib/test/test_importlib/test_abc.py [changed mode: 0644->0755]
Misc/NEWS.d/next/Tests/2019-04-15-19-05-35.bpo-30202.Wt7INj.rst [new file with mode: 0644]

old mode 100644 (file)
new mode 100755 (executable)
index 05608bb..9816b35
@@ -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,
diff --git a/Misc/NEWS.d/next/Tests/2019-04-15-19-05-35.bpo-30202.Wt7INj.rst b/Misc/NEWS.d/next/Tests/2019-04-15-19-05-35.bpo-30202.Wt7INj.rst
new file mode 100644 (file)
index 0000000..29fae77
--- /dev/null
@@ -0,0 +1 @@
+Update ``test.test_importlib.test_abc`` to test ``find_spec()``.
\ No newline at end of file