mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
Issue #15627: Add the compile_source() method to
importlib.abc.SourceLoader. This provides an easy hook into the import system to allow for source transformations, AST optimizations, etc.
This commit is contained in:
parent
195ad6ce05
commit
5650e4f41c
5 changed files with 2404 additions and 2360 deletions
|
@ -148,6 +148,11 @@ class SourceOnlyLoaderTests(SourceLoaderTestHarness):
|
|||
code_object = self.loader.get_code(self.name)
|
||||
self.verify_code(code_object)
|
||||
|
||||
def test_compile_source(self):
|
||||
# Verify the compiled code object.
|
||||
code = self.loader.compile_source(self.loader.source, self.path)
|
||||
self.verify_code(code)
|
||||
|
||||
def test_load_module(self):
|
||||
# Loading a module should set __name__, __loader__, __package__,
|
||||
# __path__ (for packages), __file__, and __cached__.
|
||||
|
@ -395,12 +400,10 @@ class AbstractMethodImplTests(unittest.TestCase):
|
|||
|
||||
def test_main():
|
||||
from test.support import run_unittest
|
||||
run_unittest(SkipWritingBytecodeTests, RegeneratedBytecodeTests,
|
||||
BadBytecodeFailureTests, MissingPathsTests,
|
||||
SourceOnlyLoaderTests,
|
||||
SourceLoaderBytecodeTests,
|
||||
SourceLoaderGetSourceTests,
|
||||
AbstractMethodImplTests)
|
||||
run_unittest(SourceOnlyLoaderTests,
|
||||
SourceLoaderBytecodeTests,
|
||||
SourceLoaderGetSourceTests,
|
||||
AbstractMethodImplTests)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue