Close #15486: Simplify the mechanism used to remove importlib frames from tracebacks when they just introduce irrelevant noise

This commit is contained in:
Nick Coghlan 2012-07-31 21:14:18 +10:00
parent 73a74dad3f
commit 42c0766a53
4 changed files with 3503 additions and 3616 deletions

View file

@ -785,11 +785,13 @@ class ImportTracebackTests(unittest.TestCase):
sys.path[:] = self.old_path
rmtree(TESTFN)
def create_module(self, mod, contents):
with open(os.path.join(TESTFN, mod + ".py"), "w") as f:
def create_module(self, mod, contents, ext=".py"):
fname = os.path.join(TESTFN, mod + ext)
with open(fname, "w") as f:
f.write(contents)
self.addCleanup(unload, mod)
importlib.invalidate_caches()
return fname
def assert_traceback(self, tb, files):
deduped_files = []