forked from pytest-dev/pytest
-
Notifications
You must be signed in to change notification settings - Fork 0
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
- Loading branch information
Showing
2 changed files
with
40 additions
and
9 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,24 @@ | ||
def test_tbh_chained(testdir): | ||
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 |