From 14fe34c48f119d05f2b48894c3e60c8cb9f0d163 Mon Sep 17 00:00:00 2001 From: Darren Burns Date: Mon, 24 May 2021 23:48:28 +0100 Subject: [PATCH] Linking to PyCharm --- ward/_terminal.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/ward/_terminal.py b/ward/_terminal.py index 9c5bb824..199f542a 100644 --- a/ward/_terminal.py +++ b/ward/_terminal.py @@ -156,7 +156,11 @@ def output_test_result_line( grid.add_column() columns = [ Padding(outcome_tag, style=test_style, pad=(0, 1, 0, 1)), - Padding(f"{test_location}{test_case_number}", style="muted", pad=(0, 1, 0, 1)), + Padding( + f"[link=pycharm://open?file={test.path.absolute()}&line={test.line_number}]{test_location}{test_case_number}[/link]", + style="muted", + pad=(0, 1, 0, 1), + ), Padding( Markdown(test.description, inline_code_theme="ansi_dark"), pad=(0, 1, 0, 0) ), @@ -368,7 +372,14 @@ def output_dots_module( def print_dot(result: TestResult) -> None: style = outcome_to_style(result.outcome) - console.print(result.outcome.display_char, style=style, end="") + if result.outcome == TestOutcome.FAIL: + console.print( + f"[link=pycharm://open?file={result.test.path}&line={result.test.line_number}]{result.outcome.display_char}", + style=style, + end="", + ) + else: + console.print(result.outcome.display_char, style=style, end="") def print_end_of_line_for_dots(