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

Side by Side Diff: Lib/test/test_importlib/import_/test___loader__.py

Issue 23014: Don't have importlib.abc.Loader.create_module() be optional
Patch Set: Created 4 years, 8 months ago
Left:
Right:
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 unified diff | Download patch
OLDNEW
1 from importlib import machinery 1 from importlib import machinery
2 import sys 2 import sys
3 import types 3 import types
4 import unittest 4 import unittest
5 5
6 from .. import util 6 from .. import util
7 7
8 8
9 class SpecLoaderMock: 9 class SpecLoaderMock:
10 10
11 def find_spec(self, fullname, path=None, target=None): 11 def find_spec(self, fullname, path=None, target=None):
12 return machinery.ModuleSpec(fullname, self) 12 return machinery.ModuleSpec(fullname, self)
13
14 def create_module(self, spec):
15 return None
13 16
14 def exec_module(self, module): 17 def exec_module(self, module):
15 pass 18 pass
16 19
17 20
18 class SpecLoaderAttributeTests: 21 class SpecLoaderAttributeTests:
19 22
20 def test___loader__(self): 23 def test___loader__(self):
21 loader = SpecLoaderMock() 24 loader = SpecLoaderMock()
22 with util.uncache('blah'), util.import_state(meta_path=[loader]): 25 with util.uncache('blah'), util.import_state(meta_path=[loader]):
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 self.assertEqual(loader, module.__loader__) 66 self.assertEqual(loader, module.__loader__)
64 67
65 68
66 (Frozen_Tests, 69 (Frozen_Tests,
67 Source_Tests 70 Source_Tests
68 ) = util.test_both(LoaderAttributeTests, __import__=util.__import__) 71 ) = util.test_both(LoaderAttributeTests, __import__=util.__import__)
69 72
70 73
71 if __name__ == '__main__': 74 if __name__ == '__main__':
72 unittest.main() 75 unittest.main()
OLDNEW

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