-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Correctly handle tracebackhide for chained exceptions (#10772)
- Loading branch information
Showing
6 changed files
with
50 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Correctly handle ``__tracebackhide__`` for chained exceptions. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
def test_tbh_chained(testdir): | ||
"""Ensure chained exceptions whose frames contain "__tracebackhide__" are not shown (#1904).""" | ||
p = testdir.makepyfile( | ||
""" | ||
import pytest | ||
def f1(): | ||
__tracebackhide__ = True | ||
try: | ||
return f1.meh | ||
except AttributeError: | ||
pytest.fail("fail") | ||
@pytest.fixture | ||
def fix(): | ||
f1() | ||
def test(fix): | ||
pass | ||
""" | ||
) | ||
result = testdir.runpytest(str(p)) | ||
assert "'function' object has no attribute 'meh'" not in result.stdout.str() | ||
assert result.ret == 1 |