Kaydet (Commit) a0d73a14 authored tarafından Joannah Nanjekye's avatar Joannah Nanjekye Kaydeden (comit) Brett Cannon

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

üst f8dd77d3
...@@ -357,13 +357,27 @@ class MetaPathFinderFindModuleTests: ...@@ -357,13 +357,27 @@ class MetaPathFinderFindModuleTests:
return MetaPathSpecFinder() return MetaPathSpecFinder()
def test_no_spec(self): def test_find_module(self):
finder = self.finder(None) finder = self.finder(None)
path = ['a', 'b', 'c'] path = ['a', 'b', 'c']
name = 'blah' name = 'blah'
with self.assertWarns(DeprecationWarning): with self.assertWarns(DeprecationWarning):
found = finder.find_module(name, path) found = finder.find_module(name, path)
self.assertIsNone(found) 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(name, finder.called_for[0])
self.assertEqual(path, finder.called_for[1]) self.assertEqual(path, finder.called_for[1])
...@@ -371,9 +385,8 @@ class MetaPathFinderFindModuleTests: ...@@ -371,9 +385,8 @@ class MetaPathFinderFindModuleTests:
loader = object() loader = object()
spec = self.util.spec_from_loader('blah', loader) spec = self.util.spec_from_loader('blah', loader)
finder = self.finder(spec) finder = self.finder(spec)
with self.assertWarns(DeprecationWarning): found = finder.find_spec('blah', None)
found = finder.find_module('blah', None) self.assertIs(found, spec)
self.assertIs(found, spec.loader)
(Frozen_MPFFindModuleTests, (Frozen_MPFFindModuleTests,
......
Update ``test.test_importlib.test_abc`` to test ``find_spec()``.
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment