Skip to content

Commit

Permalink
fix: pypy3.9 traces decorators like CPython 3.8
Browse files Browse the repository at this point in the history
  • Loading branch information
nedbat committed Feb 20, 2022
1 parent c778139 commit 9d90ebd
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 21 deletions.
5 changes: 5 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,18 @@ 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.

- Fix: show an intelligible error message if ``--concurrency=multiprocessing``
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:
Expand Down
2 changes: 1 addition & 1 deletion coverage/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down
15 changes: 0 additions & 15 deletions tests/test_arcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
5 changes: 0 additions & 5 deletions tests/test_coverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -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("""\
Expand Down

0 comments on commit 9d90ebd

Please sign in to comment.