Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion InternalDocs/generators.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ execution state.

A generator object resumes execution in its frame when its `send()`
method is called. This is analogous to a function executing in its own
fram when it is called, but a function returns to the calling frame only once,
frame when it is called, but a function returns to the calling frame only once,
while a generator "returns" execution to the caller's frame every time
it emits a new item with a
[`yield` expression](https://docs.python.org/dev/reference/expressions.html#yield-expressions).
Expand Down
26 changes: 22 additions & 4 deletions Lib/test/test_importlib/test_abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,15 @@ class ResourceLoaderDefaultsTests(ABCTestHarness):
SPLIT = make_abc_subclasses(ResourceLoader)

def test_get_data(self):
with self.assertRaises(IOError):
with (
self.assertRaises(IOError),
self.assertWarnsRegex(
DeprecationWarning,
r"importlib\.abc\.ResourceLoader is deprecated in favour of "
r"supporting resource loading through importlib\.resources"
r"\.abc\.TraversableResources.",
),
):
self.ins.get_data('/some/path')


Expand Down Expand Up @@ -927,9 +935,19 @@ def get_filename(self, fullname):

def path_stats(self, path):
return {'mtime': 1}

loader = DummySourceLoader()
with self.assertWarns(DeprecationWarning):
with self.assertWarnsRegex(
DeprecationWarning,
r"importlib\.abc\.ResourceLoader is deprecated in favour of "
r"supporting resource loading through importlib\.resources"
r"\.abc\.TraversableResources.",
):
loader = DummySourceLoader()

with self.assertWarnsRegex(
DeprecationWarning,
r"SourceLoader\.path_mtime is deprecated in favour of "
r"SourceLoader\.path_stats\(\)\."
):
loader.path_mtime('foo.py')


Expand Down
31 changes: 27 additions & 4 deletions Lib/test/test_importlib/test_windows.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,23 +91,46 @@ class WindowsRegistryFinderTests:
test_module = "spamham{}".format(os.getpid())

def test_find_spec_missing(self):
spec = self.machinery.WindowsRegistryFinder.find_spec('spam')
with self.assertWarnsRegex(
DeprecationWarning,
r"importlib\.machinery\.WindowsRegistryFinder is deprecated; "
r"use site configuration instead\. Future versions of Python may "
r"not enable this finder by default\."
):
spec = self.machinery.WindowsRegistryFinder.find_spec('spam')
self.assertIsNone(spec)

def test_module_found(self):
with setup_module(self.machinery, self.test_module):
spec = self.machinery.WindowsRegistryFinder.find_spec(self.test_module)
with self.assertWarnsRegex(
DeprecationWarning,
r"importlib\.machinery\.WindowsRegistryFinder is deprecated; "
r"use site configuration instead\. Future versions of Python may "
r"not enable this finder by default\."
):
spec = self.machinery.WindowsRegistryFinder.find_spec(self.test_module)
self.assertIsNotNone(spec)

def test_module_not_found(self):
with setup_module(self.machinery, self.test_module, path="."):
spec = self.machinery.WindowsRegistryFinder.find_spec(self.test_module)
with self.assertWarnsRegex(
DeprecationWarning,
r"importlib\.machinery\.WindowsRegistryFinder is deprecated; "
r"use site configuration instead\. Future versions of Python may "
r"not enable this finder by default\."
):
spec = self.machinery.WindowsRegistryFinder.find_spec(self.test_module)
self.assertIsNone(spec)

def test_raises_deprecation_warning(self):
# WindowsRegistryFinder is not meant to be instantiated, so the
# deprecation warning is raised in the 'find_spec' method instead.
with self.assertWarns(DeprecationWarning):
with self.assertWarnsRegex(
DeprecationWarning,
r"importlib\.machinery\.WindowsRegistryFinder is deprecated; "
r"use site configuration instead\. Future versions of Python may "
r"not enable this finder by default\."
):
self.machinery.WindowsRegistryFinder.find_spec('spam')

(Frozen_WindowsRegistryFinderTests,
Expand Down
Loading