summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2022-02-20 17:11:38 -0500
committerNed Batchelder <ned@nedbatchelder.com>2022-02-20 17:18:05 -0500
commit9d90ebd1e6bd49a7ff13dad85ae3593995127565 (patch)
tree17c6124376cb1c7b316be4026e4cb92976010dc5
parentc778139f859c75815fdccefedf9b4133318be795 (diff)
downloadpython-coveragepy-git-9d90ebd1e6bd49a7ff13dad85ae3593995127565.tar.gz
fix: pypy3.9 traces decorators like CPython 3.8
-rw-r--r--CHANGES.rst5
-rw-r--r--coverage/env.py2
-rw-r--r--tests/test_arcs.py15
-rw-r--r--tests/test_coverage.py5
4 files changed, 6 insertions, 21 deletions
diff --git a/CHANGES.rst b/CHANGES.rst
index f6371b23..60d43c57 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -20,6 +20,10 @@ development at the same time, such as 4.5.x and 5.0.
Unreleased
----------
+- Fix: adapt to pypy3.9's decorator tracing behavior. It now traces function
+ decorators like CPython 3.8: both the @-line and the def-line are traced.
+ Fixes `issue 1326`_.
+
- Debug: added ``pybehave`` to the list of :ref:`cmd_debug` and
:ref:`cmd_run_debug` options.
@@ -27,6 +31,7 @@ Unreleased
is used without a configuration file. Closes `issue 1320`_.
.. _issue 1320: https://github.com/nedbat/coveragepy/issues/1320
+.. _issue 1326: https://github.com/nedbat/coveragepy/issues/1326
.. _changes_631:
diff --git a/coverage/env.py b/coverage/env.py
index ecc40c4f..444cb892 100644
--- a/coverage/env.py
+++ b/coverage/env.py
@@ -71,7 +71,7 @@ class PYBEHAVIOR:
# When a function is decorated, does the trace function get called for the
# @-line and also the def-line (new behavior in 3.8)? Or just the @-line
# (old behavior)?
- trace_decorated_def = (CPYTHON and PYVERSION >= (3, 8))
+ trace_decorated_def = (CPYTHON and PYVERSION >= (3, 8)) or (PYPY and PYVERSION >= (3, 9))
# Functions are no longer claimed to start at their earliest decorator even though
# the decorators are traced?
diff --git a/tests/test_arcs.py b/tests/test_arcs.py
index 7991a4ad..d19a6588 100644
--- a/tests/test_arcs.py
+++ b/tests/test_arcs.py
@@ -926,11 +926,6 @@ class ExceptionArcTest(CoverageTest):
arcz=".1 12 23 35 56 61 17 7.",
)
- @pytest.mark.xfail(
- env.PYPY and env.PYVERSION >= (3, 9),
- reason="avoid a PyPy bug: 3662"
- # https://foss.heptapod.net/pypy/pypy/-/issues/3662
- )
def test_bug_212(self):
# "except Exception as e" is crucial here.
# Bug 212 said that the "if exc" line was incorrectly marked as only
@@ -1653,11 +1648,6 @@ class MiscArcTest(CoverageTest):
class DecoratorArcTest(CoverageTest):
"""Tests of arcs with decorators."""
- @pytest.mark.xfail(
- env.PYPY and env.PYVERSION >= (3, 9),
- reason="avoid a PyPy bug: 3666"
- # https://foss.heptapod.net/pypy/pypy/-/issues/3666
- )
def test_function_decorator(self):
arcz = (
".1 16 67 7A AE EF F. " # main line
@@ -1686,11 +1676,6 @@ class DecoratorArcTest(CoverageTest):
arcz=arcz,
)
- @pytest.mark.xfail(
- env.PYPY and env.PYVERSION >= (3, 9),
- reason="avoid a PyPy bug: 3666"
- # https://foss.heptapod.net/pypy/pypy/-/issues/3666
- )
def test_class_decorator(self):
arcz = (
".1 16 67 6D 7A AE E. " # main line
diff --git a/tests/test_coverage.py b/tests/test_coverage.py
index a6d3ccae..fc4263de 100644
--- a/tests/test_coverage.py
+++ b/tests/test_coverage.py
@@ -1218,11 +1218,6 @@ class CompoundStatementTest(CoverageTest):
reason="avoid class docstring bug: bpo 46331",
# https://bugs.python.org/issue46331
)
- @pytest.mark.xfail(
- env.PYPY and env.PYVERSION[:2] == (3, 9),
- reason="avoid PyPy class docstring bug: 3665",
- # https://foss.heptapod.net/pypy/pypy/-/issues/3665
- )
def test_class_def(self):
arcz="-22 2D DE E-2 23 36 6A A-2 -68 8-6 -AB B-A"
self.check_coverage("""\