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

Find console frame based on project path #1034

Merged
merged 1 commit into from
Apr 4, 2021
Merged
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
15 changes: 9 additions & 6 deletions brownie/test/managers/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,12 +434,15 @@ def pytest_exception_interact(self, report, call):
tw = TerminalWriter()
report.longrepr.toterminal(tw)

# find last traceback frame within the active test
excinfo = call.excinfo
traceback = next(
(i for i in excinfo.traceback[::-1] if Path(i.path).as_posix().endswith(location)),
excinfo.traceback[-1],
)
# find the last traceback frame within the active project
traceback = call.excinfo.traceback[-1]
for tb_frame in call.excinfo.traceback[::-1]:
try:
Path(tb_frame.path).relative_to(self.project_path)
traceback = tb_frame
break
except ValueError:
pass

# get global namespace
globals_dict = traceback.frame.f_globals
Expand Down