-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Tests not being discovered since 2019.4.0 #5458
Comments
I have the same problem with pytest! I didn't change anything to the test configuration and it worked fine yesterday. Environment data (vscode and python extension version) is more or less the same as from the OP except that i use Miniconda python v3.7.1. Here are my workspace settings:
Additionally i get a large error message in the console, which could help you guys debug this error:
I would like to add that i love vscode and its capabilities - you are doing great work! Please fix this error, because i also need vscode and testing at work :) |
Similar behavior for VS Code 1.33.1/Python extension 2019.4.11987 on macOS 10.12. When running My previous settings.json file had this line to enable pytest: "python.unitTest.pyTestEnabled": true, Now, that line of the config file shows a tooltip message I tried making the recommended change to settings.json and this resulted in another error pop-up (sorry did not take screen grab in time). I backed out and restored an earlier copy of settings.json. VSCode now runs without error messages. |
@cdietschrun @ralexx @xibalba01 |
@DonJayamanne, unfortunately I can't provide my repo. I tried to drag some modules and their companion tests into a fresh repo but VSCode/Python were well-behaved. From Python output window after running VSCode in the original repo:
|
I have similar problem!1. EnvVS Code version:
Anaconda: 2. My demo repo is bellow:
[./vscode_bug_demo/test/demo_test.py]
|
After update extension do 2019.4.0 pytest return code -2. I reconfigure setting and don`t work too. VS Code version: 1.33.1 |
I get the same error, with exit code 2 or 4 using a similar setup but Python 3.7.1 in a conda environment. I was able to set up a small folder with just two files as described in the VS Code tutorial for unit testing which successfully discovers and runs the tests. However, as soon as I add test_function.py files from my repository, I get the errors. Maybe there are some bugs which interrupt the test discovery when imports within the test_function.py files are not successful? |
Strangely when i set up a clean repo i get not problems... since my repo/filebase where the error occured is largely crap i dont like to make it official :) But maybe it helps: https://github.com/xibalba01/vscode_python_ext_bug Some interesting thing happened while playing around with my repo: I figured out that the error did NOT occur in vscode when i leave out the |
@xibalba01 I guess you do not experience this issue as you do not specify a folder for your tests ( For me, a work-around was to use |
While this is indeed a workaround for the non-recognition of tests in subfolders, which worked for me when I added an I can control whether the test discovery will fail or not, by just (de-) commenting one import statement in one file. I am new to pytest, so please let me know, if this is intended. Anyway, it would be helpful if unsuccesful imports result in an error for the respective file without the test discovery failing entirely. |
@chkpnt when you look in the Anyway, i think it should not be such a hassle to discover tests, which are somewhere in the workspace folder tree - with or without As i said, when running pytest from the commandline from the root folder with the same commands from the @r-beer i second that. More clear error messages would be helpful. |
after update pytest and vscode are latest version,I met same issue with exit code 2Test Discovery failed: my codeimport pytest
def test_a():
assert 1 |
I ran into the same issue. Here's a minimal repro (you need Test discovery fails with the addopts line in Python Extension Version: 2019.4.11987 Here's what should happen:
|
I met similar issue here: My setings.json: VS Code Version: 1.33.1 |
@MusicGuitar Please could you provide a sample repo we can use to replicate this at our end. |
@DonJayamanne I’ve provided a ZIP file in my comments, it’s a minimal repro. You can also use https://github.com/Quansight-Labs/uarray I basically just switched the unit test framework to PyTest and added the |
@DonJayamanne It shows the following errors:
|
I have found that removing all args, and leaving it as a blank list appears to work. |
Tried to revert to 2019.3.6558. And reverted setting.json as:
The pytest works with my test repo:
|
Seems like a bug in the latest version of VS Code Python extension. I had the same issue, then I downgraded the Python extension to 2019.3.6558 and then it works again. So we should go to our VS Code extensions list, select the Python extension and "Install another version..." from the setting of that extension. |
(for #5458) pythonFiles/testing_tools/adapter/pytest.py has gotten too big, with too many different things implemented there. This change addresses that by adding a "pytest" subpackage and splitting the code from pytest.py up into several modules under that subpackage. Note that this change is almost exclusively moving code around, adding missing docstrings, and removing superfluous comments.
This error went away and then came back for me. |
The log:
|
Same issue for me, just a bit different error:
|
@niksite can you please open a new issue since your cause is different? |
Same problem, after trying different versions of Python Extension finally discovered with Python 2019.2.5558 Logs when failing:
|
There are lots of reasons test will not be discovered. e.g. If you have syntax error or import error(cannot find module being imported, usually it is caused by missing appropriate init.py). Based on your partial log, I doubt it may be the former one. I will suggest you paste the whole log |
My Python Extension has been automatically updated to 2019.8.30787. Here you have the full log taken from the "Python Test Log" from the "Output" tab. It's generated when I click the "Run All Test" button in "Test" vertical tab.
Also, when executing View > Command Palette > Python: Discover Tests this is the output of "Python Test Log":
When executing View > Command Palette > Python: Run All Tests the first log is shown |
I have version 2019.8.30787 (the same as in comment above ☝️ ), and I get the same error as #5458 (comment) I have the following options configured in
Turns out that Versions:
Invoking the whole command succeeds in terminal, of course: |
Edit: Scratch that, I have |
Hey folks. There was a refactoring to the code that handles test discovery some time ago to address a series of issues. I believe many of the issues reported here might have been fixed or will when we address #6594. The remaining action item on the extension side regarding this issue has now become unclear, that's I'm closing this issue. If you're still having issues with test discovery with pytest, I'm going to kindly ask you all to try to run pytest in the terminal -- if it works, then it's probably an extension issue and it'd be great if you could file a separate issue following the template providing your environment info as well as repro steps. If it doesn't work, then most probably it's not a bug in the extension side, but you can always file a new issue if you're unsure. |
Environment data
Expected behaviour
Discover Python unit tests should pick up unit tests (excluding ones I want ignored), mark the unit tests in the source file with the 'debug test|run test' annotations, and running unit tests should only run my tests. This was working prior to yesterday.
Actual behaviour
Discover unit tests includes directories I've asked to be ignored in python.testing.pyTestArgs, unit test source files are not marked with annotations, and all tests run. Also I'm not seeing the results of Discover Unit Tests anywhere after run it.
Steps to reproduce:
``
Logs
Output for
Python
in theOutput
panel (View
→Output
, change the drop-down the upper-right of theOutput
panel toPython
)and cps_python_packages shouldn't be linted or tested, but is being linted and tested. I have no user settings affecting this.
Output from
Console
under theDeveloper Tools
panel (toggle Developer Tools on underHelp
; turn on source maps to make any tracebacks be useful by runningEnable source map support for extension debugging
)The text was updated successfully, but these errors were encountered: