diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2020-04-20 15:18:11 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-20 15:18:11 (GMT) |
commit | 81de3c225774179cdc82a1733a64e4a876ff02b5 (patch) | |
tree | 33da5d5ef141b98df118dc512b41cb2d38a867b7 /Lib/test | |
parent | 984a567cbb2dc4645f2baf72f608d44c9173d190 (diff) | |
download | cpython-81de3c225774179cdc82a1733a64e4a876ff02b5.zip cpython-81de3c225774179cdc82a1733a64e4a876ff02b5.tar.gz cpython-81de3c225774179cdc82a1733a64e4a876ff02b5.tar.bz2 |
bpo-40260: Revert breaking changes made in modulefinder (GH-19595)
(cherry picked from commit 9b0b5d2baebd0b6a545317200c313a6a7408731e)
Co-authored-by: Barry <barry@barrys-emacs.org>
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_modulefinder.py | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/Lib/test/test_modulefinder.py b/Lib/test/test_modulefinder.py index 1aa4501..23c7e5f 100644 --- a/Lib/test/test_modulefinder.py +++ b/Lib/test/test_modulefinder.py @@ -317,13 +317,12 @@ def create_package(source): if ofi: ofi.close() - class ModuleFinderTest(unittest.TestCase): - def _do_test(self, info, report=False, debug=0, replace_paths=[]): + def _do_test(self, info, report=False, debug=0, replace_paths=[], modulefinder_class=modulefinder.ModuleFinder): import_this, modules, missing, maybe_missing, source = info create_package(source) try: - mf = modulefinder.ModuleFinder(path=TEST_PATH, debug=debug, + mf = modulefinder_class(path=TEST_PATH, debug=debug, replace_paths=replace_paths) mf.import_hook(import_this) if report: @@ -421,5 +420,17 @@ b.py def test_coding_explicit_cp1252(self): self._do_test(coding_explicit_cp1252_test) + def test_load_module_api(self): + class CheckLoadModuleApi(modulefinder.ModuleFinder): + def __init__(self, *args, **kwds): + super().__init__(*args, **kwds) + + def load_module(self, fqname, fp, pathname, file_info): + # confirm that the fileinfo is a tuple of 3 elements + suffix, mode, type = file_info + return super().load_module(fqname, fp, pathname, file_info) + + self._do_test(absolute_import_test, modulefinder_class=CheckLoadModuleApi) + if __name__ == "__main__": unittest.main() |