Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Traceback-trimming of contextlib under Python 3.11 #3326

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ their individual contributions.
* `Charles O'Farrell <https://www.github.com/charleso>`_
* `Charlie Tanksley <https://www.github.com/charlietanksley>`_
* `Chase Garner <https://www.github.com/chasegarner>`_ (chase@garner.red)
* `Cheuk Ting Ho <https://github.com/Cheukting>`_
* `Chris Down <https://chrisdown.name>`_
* `Christopher Martin <https://www.github.com/chris-martin>`_ (ch.martin@gmail.com)
* `Claudio Jolowicz <https://github.com/cjolowicz>`_
Expand Down
3 changes: 3 additions & 0 deletions hypothesis-python/RELEASE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
RELEASE_TYPE: patch

This patch by Cheuk Ting Ho improves traceback trimming on Python 3.11 prereleases (:issue:`3298`).
6 changes: 6 additions & 0 deletions hypothesis-python/src/hypothesis/internal/escalation.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ def accept(filepath):


is_hypothesis_file = belongs_to(hypothesis)
is_contextlib_file = belongs_to(contextlib)

HYPOTHESIS_CONTROL_EXCEPTIONS = (DeadlineExceeded, StopTest, UnsatisfiedAssumption)

Expand Down Expand Up @@ -98,6 +99,11 @@ def get_trimmed_traceback(exception=None):
# But our `@proxies` decorator overrides the source location,
# so we check for an attribute it injects into the frame too.
or tb.tb_frame.f_globals.get("__hypothesistracebackhide__") is True
# trim frames from contextlib in python 3.11
or (
sys.version_info[:2] == (3, 11)
and is_contextlib_file(getframeinfo(tb.tb_frame).filename)
)
):
tb = tb.tb_next
return tb
Expand Down
5 changes: 0 additions & 5 deletions hypothesis-python/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,6 @@
if sys.version_info >= (3, 11):
collect_ignore_glob.append("cover/test_asyncio.py") # @asyncio.coroutine removed

assert sys.version_info.releaselevel == "alpha"
# TODO: our traceback elision doesn't work with Python 3.11's nice new format yet
collect_ignore_glob.append("cover/test_traceback_elision.py")
collect_ignore_glob.append("pytest/test_capture.py")


def pytest_configure(config):
config.addinivalue_line("markers", "slow: pandas expects this marker to exist.")
Expand Down