Ask questionsLink to files from line references in test log

Not sure what would be involved in this but is there any way to add hyperlinks to file paths/line numbers referenced in the test log that open the files in the editor?


Answer questions kondratyev-nv

@tclose Thank you for the issue! Sorry for the late reply. I've looked through the options on implementing this. As I understood you, there are cases when VSCode doesn't detect that there are paths to test files in the Output. I can see it is the case with the pytest

assert (2 + 2) == 5
def test_two_plus_two_is_five_failed():
>       assert (2 + 2) == 5
E       assert (2 + 2) == 5

test/other_tests/ AssertionError

test/other_tests/ is not clickable.

As I understood, VSCode detects file path in the Output by itself and there is no way to change its behavior. Also, at the moment, Python Test Explorer dumps the output that is written by unittest/pytest without any modifications to it, so it is pretty much the same you might expect from a test execution in a command line.

I can suggest adding something like Test failed at <absolute path>:<test function line number> as the first line in the output. Such a link should be detected correctly by the VSCode. Would it help you? I have some doubts about this solution because you've probably got the output from the Test Explorer panel, and it has a "Go to source" button on a test.


Related questions

how to configure for pytest and coverage hot 29
Nikolay Kondratyev kondratyev-nv Software developer with strong desire to learn and interest in large-scale software systems, web services, software design and architecture.
Github User Rank List