From 9d90ebd1e6bd49a7ff13dad85ae3593995127565 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Sun, 20 Feb 2022 17:11:38 -0500 Subject: [PATCH] fix: pypy3.9 traces decorators like CPython 3.8 --- CHANGES.rst | 5 +++++ coverage/env.py | 2 +- tests/test_arcs.py | 15 --------------- tests/test_coverage.py | 5 ----- 4 files changed, 6 insertions(+), 21 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index f6371b23d..60d43c570 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 ecc40c4f6..444cb8923 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 7991a4ad4..d19a6588f 100644 --- a/tests/test_arcs.py +++ b/tests/test_arcs.py @@ -926,11 +926,6 @@ def test_finally_in_loop_bug_92(self): 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 @@ def f(a, b): 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 @@ def my_function( 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 a6d3ccaef..fc4263de9 100644 --- a/tests/test_coverage.py +++ b/tests/test_coverage.py @@ -1218,11 +1218,6 @@ def foo( 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("""\