summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--coverage/control.py8
-rw-r--r--pybanner.py7
-rw-r--r--setup.py2
-rw-r--r--test/farm/html/run_unicode.py12
-rw-r--r--test/test_process.py4
5 files changed, 29 insertions, 4 deletions
diff --git a/coverage/control.py b/coverage/control.py
index b617f486..ddeb77c0 100644
--- a/coverage/control.py
+++ b/coverage/control.py
@@ -327,7 +327,7 @@ class coverage(object):
try:
pkg_file = mod.__file__
except AttributeError:
- self._warn("Module %s has no Python source." % pkg)
+ pkg_file = None
else:
d, f = os.path.split(pkg_file)
if f.startswith('__init__.'):
@@ -336,8 +336,14 @@ class coverage(object):
else:
pkg_file = self._source_for_file(pkg_file)
pkg_file = self.file_locator.canonical_filename(pkg_file)
+ if not os.path.exists(pkg_file):
+ pkg_file = None
+
+ if pkg_file:
self.source.append(pkg_file)
self.source_match.add(pkg_file)
+ else:
+ self._warn("Module %s has no Python source." % pkg)
for pkg in found:
self.source_pkgs.remove(pkg)
diff --git a/pybanner.py b/pybanner.py
index b3a3c85c..c7d2a2ad 100644
--- a/pybanner.py
+++ b/pybanner.py
@@ -8,4 +8,9 @@ try:
except AttributeError:
impl = "Python"
-print('=== %s %s %s (%s) ===' % (impl, platform.python_version(), sys.argv[1], sys.executable))
+version = platform.python_version()
+
+if '__pypy__' in sys.builtin_module_names:
+ version += " (pypy %s)" % ".".join([str(v) for v in sys.pypy_version_info])
+
+print('=== %s %s %s (%s) ===' % (impl, version, sys.argv[1], sys.executable))
diff --git a/setup.py b/setup.py
index 71c43421..bad1c048 100644
--- a/setup.py
+++ b/setup.py
@@ -110,7 +110,7 @@ if sys.platform.startswith('java'):
# Jython can't compile C extensions
compile_extension = False
-if hasattr(sys, "pypy_version_info"):
+if '__pypy__' in sys.builtin_module_names:
# Pypy can't compile C extensions
compile_extension = False
diff --git a/test/farm/html/run_unicode.py b/test/farm/html/run_unicode.py
index 210a9113..6ed44660 100644
--- a/test/farm/html/run_unicode.py
+++ b/test/farm/html/run_unicode.py
@@ -1,3 +1,5 @@
+import sys
+
def html_it():
"""Run coverage and make an HTML report for unicode.py."""
import coverage
@@ -14,7 +16,15 @@ runfunc(html_it, rundir="src")
compare("gold_unicode", "html_unicode", size_within=10, file_pattern="*.html")
contains("html_unicode/unicode.html",
"<span class='str'>&quot;&#654;d&#729;&#477;b&#592;&#633;&#477;&#652;o&#596;&quot;</span>",
- "<span class='str'>&quot;db40,dd00: x&#56128;&#56576;&quot;</span>",
)
+if sys.maxunicode == 65535:
+ contains("html_unicode/unicode.html",
+ "<span class='str'>&quot;db40,dd00: x&#56128;&#56576;&quot;</span>",
+ )
+else:
+ contains("html_unicode/unicode.html",
+ "<span class='str'>&quot;db40,dd00: x&#917760;&quot;</span>",
+ )
+
clean("html_unicode")
diff --git a/test/test_process.py b/test/test_process.py
index b40eac12..05857b1d 100644
--- a/test/test_process.py
+++ b/test/test_process.py
@@ -226,6 +226,10 @@ class ProcessTest(CoverageTest):
# same traceback.
status, out = self.run_command_status("coverage run throw.py", 1)
out2 = self.run_command("python throw.py")
+ if '__pypy__' in sys.builtin_module_names:
+ # Pypy has an extra frame in the traceback for some reason
+ lines2 = out2.splitlines()
+ out2 = "".join([l+"\n" for l in lines2 if "toplevel" not in l])
self.assertMultiLineEqual(out, out2)
# But also make sure that the output is what we expect.