Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

bpo-30158: Fix deprecation warnings in test_importlib introduced by … #1285

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 16 additions & 13 deletions 29 Lib/test/test_importlib/test_abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,15 +157,14 @@ class MetaPathFinderDefaultsTests(ABCTestHarness):

def test_find_module(self):
# Default should return None.
self.assertIsNone(self.ins.find_module('something', None))
with self.assertWarns(DeprecationWarning):
found = self.ins.find_module('something', None)
self.assertIsNone(found)

def test_invalidate_caches(self):
# Calling the method is a no-op.
self.ins.invalidate_caches()

def test_find_module_warns(self):
with self.assertWarns(DeprecationWarning):
self.ins.find_module('something', None)

(Frozen_MPFDefaultTests,
Source_MPFDefaultTests
Expand All @@ -183,7 +182,9 @@ class PathEntryFinderDefaultsTests(ABCTestHarness):
SPLIT = make_abc_subclasses(PathEntryFinder)

def test_find_loader(self):
self.assertEqual((None, []), self.ins.find_loader('something'))
with self.assertWarns(DeprecationWarning):
found = self.ins.find_loader('something')
self.assertEqual(found, (None, []))

def find_module(self):
self.assertEqual(None, self.ins.find_module('something'))
Expand All @@ -192,9 +193,6 @@ def test_invalidate_caches(self):
# Should be a no-op.
self.ins.invalidate_caches()

def test_find_loader_warns(self):
with self.assertWarns(DeprecationWarning):
self.ins.find_loader('something')

(Frozen_PEFDefaultTests,
Source_PEFDefaultTests
Expand Down Expand Up @@ -324,7 +322,8 @@ def test_no_spec(self):
finder = self.finder(None)
path = ['a', 'b', 'c']
name = 'blah'
found = finder.find_module(name, path)
with self.assertWarns(DeprecationWarning):
found = finder.find_module(name, path)
self.assertIsNone(found)
self.assertEqual(name, finder.called_for[0])
self.assertEqual(path, finder.called_for[1])
Expand All @@ -333,7 +332,8 @@ def test_spec(self):
loader = object()
spec = self.util.spec_from_loader('blah', loader)
finder = self.finder(spec)
found = finder.find_module('blah', None)
with self.assertWarns(DeprecationWarning):
found = finder.find_module('blah', None)
self.assertIs(found, spec.loader)


Expand All @@ -358,7 +358,8 @@ def find_spec(self, fullname, target=None):
def test_no_spec(self):
finder = self.finder(None)
name = 'blah'
found = finder.find_loader(name)
with self.assertWarns(DeprecationWarning):
found = finder.find_loader(name)
self.assertIsNone(found[0])
self.assertEqual([], found[1])
self.assertEqual(name, finder.called_for)
Expand All @@ -367,15 +368,17 @@ def test_spec_with_loader(self):
loader = object()
spec = self.util.spec_from_loader('blah', loader)
finder = self.finder(spec)
found = finder.find_loader('blah')
with self.assertWarns(DeprecationWarning):
found = finder.find_loader('blah')
self.assertIs(found[0], spec.loader)

def test_spec_with_portions(self):
spec = self.machinery.ModuleSpec('blah', None)
paths = ['a', 'b', 'c']
spec.submodule_search_locations = paths
finder = self.finder(spec)
found = finder.find_loader('blah')
with self.assertWarns(DeprecationWarning):
found = finder.find_loader('blah')
self.assertIsNone(found[0])
self.assertEqual(paths, found[1])

Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.