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

This commit is contained in:
Joannah Nanjekye 2019-06-21 15:17:00 -03:00 committed by Brett Cannon
parent f8dd77d360
commit a0d73a143a
2 changed files with 18 additions and 4 deletions

21
Lib/test/test_importlib/test_abc.py Normal file → Executable file
View File

@ -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,

View File

@ -0,0 +1 @@
Update ``test.test_importlib.test_abc`` to test ``find_spec()``.