Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a0d73a1

Browse files
nanjekyejoannahbrettcannon
authored andcommitted
bpo-30202 : Update test.test_importlib.test_abc to test find_spec() (GH-12847)
1 parent f8dd77d commit a0d73a1

2 files changed

Lines changed: 18 additions & 4 deletions

File tree

Lib/test/test_importlib/test_abc.py

100644100755
Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -357,23 +357,36 @@ def find_spec(self, fullname, path, target=None):
357357

358358
return MetaPathSpecFinder()
359359

360-
def test_no_spec(self):
360+
def test_find_module(self):
361361
finder = self.finder(None)
362362
path = ['a', 'b', 'c']
363363
name = 'blah'
364364
with self.assertWarns(DeprecationWarning):
365365
found = finder.find_module(name, path)
366366
self.assertIsNone(found)
367+
368+
def test_find_spec_with_explicit_target(self):
369+
loader = object()
370+
spec = self.util.spec_from_loader('blah', loader)
371+
finder = self.finder(spec)
372+
found = finder.find_spec('blah', 'blah', None)
373+
self.assertEqual(found, spec)
374+
375+
def test_no_spec(self):
376+
finder = self.finder(None)
377+
path = ['a', 'b', 'c']
378+
name = 'blah'
379+
found = finder.find_spec(name, path, None)
380+
self.assertIsNone(found)
367381
self.assertEqual(name, finder.called_for[0])
368382
self.assertEqual(path, finder.called_for[1])
369383

370384
def test_spec(self):
371385
loader = object()
372386
spec = self.util.spec_from_loader('blah', loader)
373387
finder = self.finder(spec)
374-
with self.assertWarns(DeprecationWarning):
375-
found = finder.find_module('blah', None)
376-
self.assertIs(found, spec.loader)
388+
found = finder.find_spec('blah', None)
389+
self.assertIs(found, spec)
377390

378391

379392
(Frozen_MPFFindModuleTests,
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Update ``test.test_importlib.test_abc`` to test ``find_spec()``.

0 commit comments

Comments
 (0)