summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGES.txt4
-rw-r--r--coverage/codeunit.py4
-rw-r--r--test/modules/aa/afile.odd.py1
-rw-r--r--test/modules/aa/bb.odd/bfile.py1
-rw-r--r--test/modules/aa/bb/bfile.odd.py1
-rw-r--r--test/test_codeunit.py14
6 files changed, 23 insertions, 2 deletions
diff --git a/CHANGES.txt b/CHANGES.txt
index 544ba9cb..8a186a1b 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -15,9 +15,13 @@ Next version
line, which is highlighted on arrival. Added a link back to the index page
at the bottom of each HTML page.
+- Source files can have more than one dot in them (foo.test.py), and will be
+ treated properly while reporting. Fixes `issue 46`_.
+
- Source files with DOS line endings are now properly tokenized for syntax
coloring on non-DOS machines. Fixes `issue 53`_.
+.. _issue 46: http://bitbucket.org/ned/coveragepy/issue/46
.. _issue 53: http://bitbucket.org/ned/coveragepy/issue/53
diff --git a/coverage/codeunit.py b/coverage/codeunit.py
index 73baaa06..9bf6dc97 100644
--- a/coverage/codeunit.py
+++ b/coverage/codeunit.py
@@ -124,8 +124,8 @@ class CodeUnit(object):
if self.modname:
return self.modname.replace('.', '_')
else:
- root = os.path.splitdrive(os.path.splitext(self.name)[0])[1]
- return root.replace('\\', '_').replace('/', '_')
+ root = os.path.splitdrive(self.name)[1]
+ return root.replace('\\', '_').replace('/', '_').replace('.', '_')
def source_file(self):
"""Return an open file for reading the source of the code unit."""
diff --git a/test/modules/aa/afile.odd.py b/test/modules/aa/afile.odd.py
new file mode 100644
index 00000000..c6f49e18
--- /dev/null
+++ b/test/modules/aa/afile.odd.py
@@ -0,0 +1 @@
+# afile.odd.py
diff --git a/test/modules/aa/bb.odd/bfile.py b/test/modules/aa/bb.odd/bfile.py
new file mode 100644
index 00000000..90875404
--- /dev/null
+++ b/test/modules/aa/bb.odd/bfile.py
@@ -0,0 +1 @@
+# bfile.py
diff --git a/test/modules/aa/bb/bfile.odd.py b/test/modules/aa/bb/bfile.odd.py
new file mode 100644
index 00000000..b45cba8c
--- /dev/null
+++ b/test/modules/aa/bb/bfile.odd.py
@@ -0,0 +1 @@
+# bfile.odd.py
diff --git a/test/test_codeunit.py b/test/test_codeunit.py
index 35387ba3..7903d153 100644
--- a/test/test_codeunit.py
+++ b/test/test_codeunit.py
@@ -36,6 +36,20 @@ class CodeUnitTest(CoverageTest):
self.assertEqual(bcu[0].source_file().read(), "# bfile.py\n")
self.assertEqual(ccu[0].source_file().read(), "# cfile.py\n")
+ def test_odd_filenames(self):
+ acu = code_unit_factory("aa/afile.odd.py", FileLocator())
+ bcu = code_unit_factory("aa/bb/bfile.odd.py", FileLocator())
+ b2cu = code_unit_factory("aa/bb.odd/bfile.py", FileLocator())
+ self.assertEqual(acu[0].name, "aa/afile.odd")
+ self.assertEqual(bcu[0].name, "aa/bb/bfile.odd")
+ self.assertEqual(b2cu[0].name, "aa/bb.odd/bfile")
+ self.assertEqual(acu[0].flat_rootname(), "aa_afile_odd")
+ self.assertEqual(bcu[0].flat_rootname(), "aa_bb_bfile_odd")
+ self.assertEqual(b2cu[0].flat_rootname(), "aa_bb_odd_bfile")
+ self.assertEqual(acu[0].source_file().read(), "# afile.odd.py\n")
+ self.assertEqual(bcu[0].source_file().read(), "# bfile.odd.py\n")
+ self.assertEqual(b2cu[0].source_file().read(), "# bfile.py\n")
+
def test_modules(self):
import aa, aa.bb, aa.bb.cc
cu = code_unit_factory([aa, aa.bb, aa.bb.cc], FileLocator())