From 0a3b1a065257109295f9322f5a7e199d157acfe6 Mon Sep 17 00:00:00 2001 From: Jannis Pohlmann Date: Fri, 27 Sep 2013 18:35:15 +0100 Subject: Fix importing submodules with the same basenames This patch fixes a bug in CoverageTestRunner.py, where submodules with the same basenames were not loaded into separate module objects. Because the module names passed to imp.load_module() were the same, previously loaded modules would be reloaded in place, causing different problems: 1. Imports of the affected modules in the test and tested code would sometimes import a different module and cause AttributeError exceptions when expected symbols were not present in the imported module. 2. Sometimes, all but one of the imported modules would incorrectly be considered to have zero test coverage. --- CoverageTestRunner.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'CoverageTestRunner.py') diff --git a/CoverageTestRunner.py b/CoverageTestRunner.py index 88987a1..6500041 100644 --- a/CoverageTestRunner.py +++ b/CoverageTestRunner.py @@ -158,7 +158,7 @@ class CoverageTestRunner: for tuple in imp.get_suffixes(): suffix, mode, type = tuple if pathname.endswith(suffix): - name = os.path.basename(pathname[:-len(suffix)]) + name = pathname[:-len(suffix)] f = file(pathname, mode) return imp.load_module(name, f, pathname, tuple) raise Exception("Unknown module: %s" % pathname) -- cgit v1.2.1