diff options
author | Berker Peksag <berker.peksag@gmail.com> | 2014-07-07 11:59:47 (GMT) |
---|---|---|
committer | Berker Peksag <berker.peksag@gmail.com> | 2014-07-07 11:59:47 (GMT) |
commit | 7a5a8c8f7c76c8c632b7570827dd93c6c729b740 (patch) | |
tree | 23e6c5e4011e1825cf7d4e917168e0b52e148764 /Lib/test | |
parent | f2c4ba120767e0e627844c2d8397462b5b2b86ca (diff) | |
parent | 0a0d1da987118e11bc9c28937817facdcc9801cb (diff) | |
download | cpython-7a5a8c8f7c76c8c632b7570827dd93c6c729b740.zip cpython-7a5a8c8f7c76c8c632b7570827dd93c6c729b740.tar.gz cpython-7a5a8c8f7c76c8c632b7570827dd93c6c729b740.tar.bz2 |
Issue #21707: Merge with 3.4.
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_modulefinder.py | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/Lib/test/test_modulefinder.py b/Lib/test/test_modulefinder.py index ed30d6f..b5fdcc8 100644 --- a/Lib/test/test_modulefinder.py +++ b/Lib/test/test_modulefinder.py @@ -245,11 +245,12 @@ def create_package(source): class ModuleFinderTest(unittest.TestCase): - def _do_test(self, info, report=False): + def _do_test(self, info, report=False, debug=0, replace_paths=[]): import_this, modules, missing, maybe_missing, source = info create_package(source) try: - mf = modulefinder.ModuleFinder(path=TEST_PATH) + mf = modulefinder.ModuleFinder(path=TEST_PATH, debug=debug, + replace_paths=replace_paths) mf.import_hook(import_this) if report: mf.report() @@ -308,9 +309,16 @@ class ModuleFinderTest(unittest.TestCase): os.remove(source_path) self._do_test(bytecode_test) + def test_replace_paths(self): + old_path = os.path.join(TEST_DIR, 'a', 'module.py') + new_path = os.path.join(TEST_DIR, 'a', 'spam.py') + with support.captured_stdout() as output: + self._do_test(maybe_test, debug=2, + replace_paths=[(old_path, new_path)]) + output = output.getvalue() + expected = "co_filename '%s' changed to '%s'" % (old_path, new_path) + self.assertIn(expected, output) -def test_main(): - support.run_unittest(ModuleFinderTest) if __name__ == "__main__": unittest.main() |