@@ -245,11 +245,12 @@ def create_package(source):
245245
246246
247247class ModuleFinderTest (unittest .TestCase ):
248- def _do_test (self , info , report = False ):
248+ def _do_test (self , info , report = False , debug = 0 , replace_paths = [] ):
249249 import_this , modules , missing , maybe_missing , source = info
250250 create_package (source )
251251 try :
252- mf = modulefinder .ModuleFinder (path = TEST_PATH )
252+ mf = modulefinder .ModuleFinder (path = TEST_PATH , debug = debug ,
253+ replace_paths = replace_paths )
253254 mf .import_hook (import_this )
254255 if report :
255256 mf .report ()
@@ -308,9 +309,16 @@ def test_bytecode(self):
308309 os .remove (source_path )
309310 self ._do_test (bytecode_test )
310311
312+ def test_replace_paths (self ):
313+ old_path = os .path .join (TEST_DIR , 'a' , 'module.py' )
314+ new_path = os .path .join (TEST_DIR , 'a' , 'spam.py' )
315+ with support .captured_stdout () as output :
316+ self ._do_test (maybe_test , debug = 2 ,
317+ replace_paths = [(old_path , new_path )])
318+ output = output .getvalue ()
319+ expected = "co_filename '%s' changed to '%s'" % (old_path , new_path )
320+ self .assertIn (expected , output )
311321
312- def test_main ():
313- support .run_unittest (ModuleFinderTest )
314322
315323if __name__ == "__main__" :
316324 unittest .main ()
0 commit comments