summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2016-12-31 09:48:34 -0500
committerNed Batchelder <ned@nedbatchelder.com>2016-12-31 09:48:34 -0500
commitd4527c3eee82d95763658b29cf5b80b17e098c4b (patch)
treedb058abe2f456b7ecc78b85b675c0fea39bc0b83
parent97d96cc8c6d3df79848da698b4072523cc8bb660 (diff)
downloadpython-coveragepy-d4527c3eee82d95763658b29cf5b80b17e098c4b.tar.gz
The PyPy-specific test for atexit/gettrace are also PyPy-version-specific...
-rw-r--r--coverage/env.py2
-rw-r--r--coverage/pytracer.py2
-rw-r--r--tests/test_oddball.py4
3 files changed, 5 insertions, 3 deletions
diff --git a/coverage/env.py b/coverage/env.py
index 4cd02c0..6db3b85 100644
--- a/coverage/env.py
+++ b/coverage/env.py
@@ -12,6 +12,8 @@ LINUX = sys.platform == "linux2"
# Python implementations.
PYPY = '__pypy__' in sys.builtin_module_names
+if PYPY:
+ PYPYVERSION = sys.pypy_version_info
# Python versions.
PYVERSION = sys.version_info
diff --git a/coverage/pytracer.py b/coverage/pytracer.py
index 13a3b0c..6cd3ea3 100644
--- a/coverage/pytracer.py
+++ b/coverage/pytracer.py
@@ -153,7 +153,7 @@ class PyTracer(object):
# so don't warn if we are in atexit on PyPy and the trace function
# has changed to None.
tf = sys.gettrace()
- dont_warn = (env.PYPY and self.in_atexit and tf is None)
+ dont_warn = (env.PYPY and env.PYPYVERSION >= (5, 4) and self.in_atexit and tf is None)
if (not dont_warn) and tf != self._trace:
self.warn("Trace function changed, measurement is likely wrong: %r" % (tf,))
diff --git a/tests/test_oddball.py b/tests/test_oddball.py
index dce65b4..d188aa7 100644
--- a/tests/test_oddball.py
+++ b/tests/test_oddball.py
@@ -515,8 +515,8 @@ class GettraceTest(CoverageTest):
""")
status, out = self.run_command_status("python atexit_gettrace.py")
self.assertEqual(status, 0)
- if env.PYPY:
- # PyPy clears the trace function before atexit runs.
+ if env.PYPY and env.PYPYVERSION >= (5, 4):
+ # Newer PyPy clears the trace function before atexit runs.
self.assertEqual(out, "None\n")
else:
# Other Pythons leave the trace function in place.