File: pytest-8.4.patch

package info (click to toggle)
python-pytest-trio 0.8.0-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 464 kB
  • sloc: python: 944; sh: 49; makefile: 20
file content (68 lines) | stat: -rw-r--r-- 2,537 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
From: Colin Watson <cjwatson@debian.org>
Date: Mon, 15 Sep 2025 00:12:10 +0100
Subject: Fix test failures with pytest 8.4

https://github.com/pytest-dev/pytest/pull/13380 (I think) means that
pytest now fails if all the traceback frames after the cut have
`__tracebackhide__ = True` set.  To avoid this, set `__tracebackhide__ =
False` if we're about to raise an exception directly from the plugin.

Fixes: #151

This may need to be fixed in pytest instead; see the upstream issue.

Origin: other, https://github.com/python-trio/pytest-trio/pull/152
Bug: https://github.com/python-trio/pytest-trio/issues/151
Bug-Debian: https://bugs.debian.org/1114324
Last-Update: 2025-09-18
---
 pytest_trio/plugin.py | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/pytest_trio/plugin.py b/pytest_trio/plugin.py
index 6638d67..8e6784f 100644
--- a/pytest_trio/plugin.py
+++ b/pytest_trio/plugin.py
@@ -310,6 +310,7 @@ class TrioFixture:
                 except StopAsyncIteration:
                     pass
                 else:
+                    __tracebackhide__ = False
                     raise RuntimeError("too many yields in fixture")
             elif isinstance(func_value, Generator):
                 try:
@@ -317,6 +318,7 @@ class TrioFixture:
                 except StopIteration:
                     pass
                 else:
+                    __tracebackhide__ = False
                     raise RuntimeError("too many yields in fixture")
 
 
@@ -340,6 +342,7 @@ def _trio_test(run):
             elif len(clocks) == 1:
                 clock = list(clocks.values())[0]
             else:
+                __tracebackhide__ = False
                 raise ValueError(
                     f"Expected at most one Clock in kwargs, got {clocks!r}"
                 )
@@ -347,6 +350,7 @@ def _trio_test(run):
             try:
                 return run(partial(fn, **kwargs), clock=clock, instruments=instruments)
             except BaseExceptionGroup as eg:
+                __tracebackhide__ = False
                 queue = [eg]
                 leaves = []
                 while queue:
@@ -423,8 +427,10 @@ def _trio_test_runner_factory(item, testfunc=None):
                 )
 
         if len(test_ctx.error_list) == 1:
+            __tracebackhide__ = False
             raise test_ctx.error_list[0]
         elif test_ctx.error_list:
+            __tracebackhide__ = False
             raise BaseExceptionGroup(
                 "errors in async test and trio fixtures", test_ctx.error_list
             )