[Python-checkins] bpo-30202 : Update test.test_importlib.test_abc to test find_spec() (GH-12847)

Brett Cannon webhook-mailer at python.org
Fri Jun 21 14:17:05 EDT 2019


https://github.com/python/cpython/commit/a0d73a143af404deecb9c4fcdbd3ddbafd96b41b
commit: a0d73a143af404deecb9c4fcdbd3ddbafd96b41b
branch: master
author: Joannah Nanjekye <33177550+nanjekyejoannah at users.noreply.github.com>
committer: Brett Cannon <54418+brettcannon at users.noreply.github.com>
date: 2019-06-21T11:17:00-07:00
summary:

bpo-30202 : Update test.test_importlib.test_abc to test find_spec() (GH-12847)

files:
A Misc/NEWS.d/next/Tests/2019-04-15-19-05-35.bpo-30202.Wt7INj.rst
M Lib/test/test_importlib/test_abc.py

diff --git a/Lib/test/test_importlib/test_abc.py b/Lib/test/test_importlib/test_abc.py
old mode 100644
new mode 100755
index 05608bbb8b9d..9816b35ef829
--- a/Lib/test/test_importlib/test_abc.py
+++ b/Lib/test/test_importlib/test_abc.py
@@ -357,13 +357,27 @@ def find_spec(self, fullname, path, target=None):
 
         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 @@ def test_spec(self):
         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
index 000000000000..29fae778fba7
--- /dev/null
+++ b/Misc/NEWS.d/next/Tests/2019-04-15-19-05-35.bpo-30202.Wt7INj.rst
@@ -0,0 +1 @@
+Update ``test.test_importlib.test_abc`` to test ``find_spec()``.
\ No newline at end of file



More information about the Python-checkins mailing list