Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(175391)

Unified Diff: Lib/test/test_importlib/test_util.py

Issue 23014: Don't have importlib.abc.Loader.create_module() be optional
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
--- a/Lib/test/test_importlib/test_util.py Fri Dec 12 12:00:02 2014 -0500
+++ b/Lib/test/test_importlib/test_util.py Fri Dec 12 12:23:43 2014 -0500
@@ -41,10 +41,16 @@
class ModuleFromSpecTests:
def test_no_create_module(self):
- class Loader(self.abc.Loader):
- pass
+ class Loader:
+ def exec_module(self, module):
+ pass
spec = self.machinery.ModuleSpec('test', Loader())
- module = self.util.module_from_spec(spec)
+ with warnings.catch_warnings(record=True) as w:
+ warnings.simplefilter('always')
+ module = self.util.module_from_spec(spec)
+ self.assertEqual(1, len(w))
berkerpeksag 2014/12/12 20:07:45 ``self.assertEqual(len(w), 1)`` looks more readabl
+ self.assertTrue(issubclass(w[0].category, DeprecationWarning))
+ self.assertIn('create_module', str(w[0].message))
self.assertIsInstance(module, types.ModuleType)
self.assertEqual(module.__name__, spec.name)

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+