summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2009-05-07 21:19:40 -0400
committerNed Batchelder <ned@nedbatchelder.com>2009-05-07 21:19:40 -0400
commitf71f94d6aa7b962a715652d2fc9fcdba3a35b97c (patch)
treed8de404dce9d2fdfefb8cf3ff7840903403ec20e
parent92606b9dc48b7c6d0156eee83d221e4520fd771b (diff)
downloadpython-coveragepy-f71f94d6aa7b962a715652d2fc9fcdba3a35b97c.tar.gz
Treat files not ending in .py properly.
-rw-r--r--coverage/control.py6
-rw-r--r--test/farm/run/run_xxx.py6
2 files changed, 7 insertions, 5 deletions
diff --git a/coverage/control.py b/coverage/control.py
index 3c6b55a..697e732 100644
--- a/coverage/control.py
+++ b/coverage/control.py
@@ -40,7 +40,6 @@ class coverage:
should not.
"""
- ofilename = filename
if filename == '<string>':
# There's no point in ever tracing string executions, we can't do
# anything with the data later anyway.
@@ -55,13 +54,12 @@ class coverage:
dunder_file = frame.f_globals.get('__file__')
if dunder_file:
if not dunder_file.endswith(".py"):
- dunder_file = dunder_file[:-1]
+ if dunder_file[-4:-1] == ".py":
+ dunder_file = dunder_file[:-1]
filename = dunder_file
canonical = self.file_locator.canonical_filename(filename)
- #print "of: %r\nfn: %r\n__: %r\nca: %r\n" % (ofilename, filename, dunder_file, canonical)
-
# If we aren't supposed to trace the stdlib, then check if this is in
# the stdlib and skip it if so.
if not self.cover_stdlib:
diff --git a/test/farm/run/run_xxx.py b/test/farm/run/run_xxx.py
index f3287a7..3c39f0f 100644
--- a/test/farm/run/run_xxx.py
+++ b/test/farm/run/run_xxx.py
@@ -3,6 +3,10 @@ run("""
coverage -e -x xxx
coverage -r
""", rundir="out", outfile="stdout.txt")
-contains("out/stdout.txt", "xxx: 3 4 0 7")
+contains("out/stdout.txt",
+ "xxx: 3 4 0 7",
+ "\nxxx ", # The reporting line for xxx
+ " 7 6 85%" # The reporting data for xxx
+ )
doesnt_contain("out/stdout.txt", "No such file or directory")
clean("out")