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

Side by Side Diff: Lib/test/test_importlib/import_/test_api.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 .. import util 1 from .. import util
2 2
3 from importlib import machinery 3 from importlib import machinery
4 import sys 4 import sys
5 import types 5 import types
6 import unittest 6 import unittest
7 7
8 PKG_NAME = 'fine' 8 PKG_NAME = 'fine'
9 SUBMOD_NAME = 'fine.bogus' 9 SUBMOD_NAME = 'fine.bogus'
10 10
11 11
12 class BadSpecFinderLoader: 12 class BadSpecFinderLoader:
13 @classmethod 13 @classmethod
14 def find_spec(cls, fullname, path=None, target=None): 14 def find_spec(cls, fullname, path=None, target=None):
15 if fullname == SUBMOD_NAME: 15 if fullname == SUBMOD_NAME:
16 spec = machinery.ModuleSpec(fullname, cls) 16 spec = machinery.ModuleSpec(fullname, cls)
17 return spec 17 return spec
18
19 @staticmethod
20 def create_module(spec):
21 return None
18 22
19 @staticmethod 23 @staticmethod
20 def exec_module(module): 24 def exec_module(module):
21 if module.__name__ == SUBMOD_NAME: 25 if module.__name__ == SUBMOD_NAME:
22 raise ImportError('I cannot be loaded!') 26 raise ImportError('I cannot be loaded!')
23 27
24 28
25 class BadLoaderFinder: 29 class BadLoaderFinder:
26 @classmethod 30 @classmethod
27 def find_module(cls, fullname, path): 31 def find_module(cls, fullname, path):
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 bad_finder_loader = BadSpecFinderLoader 92 bad_finder_loader = BadSpecFinderLoader
89 93
90 94
91 (Frozen_SpecAPITests, 95 (Frozen_SpecAPITests,
92 Source_SpecAPITests 96 Source_SpecAPITests
93 ) = util.test_both(SpecAPITests, __import__=util.__import__) 97 ) = util.test_both(SpecAPITests, __import__=util.__import__)
94 98
95 99
96 if __name__ == '__main__': 100 if __name__ == '__main__':
97 unittest.main() 101 unittest.main()
OLDNEW

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