[Python-checkins] r52805 - sandbox/trunk/import_in_py/test_importer.py
brett.cannon
python-checkins at python.org
Mon Nov 20 21:35:07 CET 2006
Author: brett.cannon
Date: Mon Nov 20 21:35:06 2006
New Revision: 52805
Modified:
sandbox/trunk/import_in_py/test_importer.py
Log:
Clean up better.
Modified: sandbox/trunk/import_in_py/test_importer.py
==============================================================================
--- sandbox/trunk/import_in_py/test_importer.py (original)
+++ sandbox/trunk/import_in_py/test_importer.py Mon Nov 20 21:35:06 2006
@@ -252,6 +252,10 @@
def tearDown(self):
TestPyPycFiles.tearDown(self)
os.remove(self.top_level_module_path)
+ pyc_path = (os.path.splitext(self.top_level_module_path)[0] +
+ self.pyc_ext)
+ if os.path.exists(pyc_path):
+ os.remove(pyc_path)
shutil.rmtree(self.pkg_path)
def verify_package(self, module, actual_name=None):
@@ -372,12 +376,14 @@
def test_pkg_before_module(self):
# Importing a name that is represented as both a package and a module
# should give precedence to the package.
- module_path = os.path.join(self.directory, self.pkg_name + '.' +
- self.py_ext)
+ module_path = os.path.join(self.directory, self.pkg_name + self.py_ext)
with open(module_path, 'w') as test_file:
test_file.write("blah")
- loader = self.importer.find_module(self.pkg_name)
- self.failUnlessEqual(loader.file_path, self.pkg_init_path)
+ try:
+ loader = self.importer.find_module(self.pkg_name)
+ self.failUnlessEqual(loader.file_path, self.pkg_init_path)
+ finally:
+ os.remove(module_path)
class FileSystemLoaderMockEnv(unittest.TestCase):
More information about the Python-checkins
mailing list