This test failed under python -O.

rewrite_file():  Delete both .pyc and .pyo leftovers, and explicitly close
the new source file after writing to it.
This commit is contained in:
Tim Peters 2001-08-02 17:23:11 +00:00
parent 044bb4d22a
commit d342c62961

View file

@ -36,9 +36,13 @@ class TestImport(unittest.TestCase):
self.remove_modules() self.remove_modules()
def rewrite_file(self, contents): def rewrite_file(self, contents):
compiled_path = self.module_path + 'c' for extension in "co":
if os.path.exists(compiled_path): os.remove(compiled_path) compiled_path = self.module_path + extension
open(self.module_path, 'w').write(contents) if os.path.exists(compiled_path):
os.remove(compiled_path)
f = open(self.module_path, 'w')
f.write(contents)
f.close()
def test_package_import__semantics(self): def test_package_import__semantics(self):