question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Test dicovery doesn't provide feedback on failure

See original GitHub issue

I find quite often my tests “disappear” from the test window, or discovery appears to do nothing. This is almost always because I’ve introduced a syntax error in the package I’m testing which results in an import failure. The reason is clear in the Python Test Log, i.e. below I forgot to install a dependency culminating in discovery failing with exit code 2. If this should happen at the very least the test sidebar should provide some indication that test discovery exited abnormally - perhaps with a highlight on the “Show Test Output” icon since clicking on that is the first step in resolving the issue.

Test Discovery failed: 
Error: ============================= test session starts ==============================

<snip>

    import ahocorasick # pip install pyahocorasick
E   ModuleNotFoundError: No module named 'ahocorasick'
=========================== short test summary info ============================
ERROR tests/test_label_model.py
!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!
===================== 5 tests collected, 1 error in 2.00s ======================

Traceback (most recent call last):
  File "/home/david/.vscode/extensions/ms-python.python-2021.7.1060902895/pythonFiles/testing_tools/run_adapter.py", line 22, in <module>
    main(tool, cmd, subargs, toolargs)
  File "/home/david/.vscode/extensions/ms-python.python-2021.7.1060902895/pythonFiles/testing_tools/adapter/__main__.py", line 100, in main
    parents, result = run(toolargs, **subargs)
  File "/home/david/.vscode/extensions/ms-python.python-2021.7.1060902895/pythonFiles/testing_tools/adapter/pytest/_discovery.py", line 44, in discover
    raise Exception("pytest discovery failed (exit code {})".format(ec))
Exception: pytest discovery failed (exit code 2)

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
karthiknadigcommented, Aug 3, 2021

Depends on the test framework, and type of error. On unittest, the test in that particular file with syntax error will be skipped. In pytest, currently syntax errors means it won’t be able to see any of the other tests. We have plans on making that part better when we update our integration with pytest.

0reactions
aholmescommented, Aug 3, 2021

In pytest, currently syntax errors means it won’t be able to see any of the other tests.

Yeah this is a huge bummer w/ pytest.

We have plans on making that part better when we update our integration with pytest.

Great! Looking forward to it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Python Test Discovery Failed with no error message #11513
According to the Python testing page when I click on the icon that says "Test discovery failed" it should provide more information.
Read more >
TestExplorer test discovery for google tests doesn't work since ...
Since Visual Studio 16.4.6, none of the solutions described above work anymore - the discovery can not find any test. I've tried the...
Read more >
Visual Studio Test Explorer FAQ - Microsoft Learn
Refer to these frequently asked questions about Visual Studio Test Explorer, which include some common troubleshooting.
Read more >
Why is the Visual Studio 2015/2017/2019 Test Runner not ...
Eliminate discovery exceptions from your inquiries; go to the output Window (Ctrl-Alt-O), then switch the show output from dropdown (Shift-Alt-S) to Tests ......
Read more >
Failure is Feedback: Unit Testing - Coveros
Do not allow broken tests to simply be turned off, ignored or deleted. A failing test is feedback that needs attention.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found