Closed cdietschrun closed 5 years ago
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:
{
"python.testing.pyTestArgs": [
".",
"-v",
"-s"
],
"python.testing.unittestEnabled": false,
"python.testing.nosetestsEnabled": false,
"python.testing.pyTestEnabled": true
}
Additionally i get a large error message in the console, which could help you guys debug this error:
Python Extension: Failed to parse discovered Test Error: Traceback (most recent call last):
File "C:\Users\USER\.vscode\extensions\ms-python.python-2019.4.11987\pythonFiles\testing_tools\run_adapter.py", line 16, in <module>
main(tool, cmd, subargs, toolargs)
File "C:\Users\USER\.vscode\extensions\ms-python.python-2019.4.11987\pythonFiles\testing_tools\adapter\__main__.py", line 90, in main
parents, result = run(toolargs, **subargs)
File "C:\Users\USER\.vscode\extensions\ms-python.python-2019.4.11987\pythonFiles\testing_tools\adapter\pytest.py", line 43, in discover
raise Exception('pytest discovery failed (exit code {})'.format(ec))
Exception: pytest discovery failed (exit code 2)
at ChildProcess.module.exports.exec.c.once (C:\Users\USER\.vscode\extensions\ms-python.python-2019.4.11987\out\client\extension.js:9:35776)
at Object.onceWrapper (events.js:273:13)
at ChildProcess.emit (events.js:182:13)
at maybeClose (internal/child_process.js:961:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:248:5)
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 code .
in my conda env, I get pop-up messages telling me that I can change the Python interpreter in the status bar (my env has curiously been renamed to base
in the status bar, which is the name reserved for the root env), and that I need to change the value of the setting python.unitTest
to python.testing
.
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 Unknown configuration setting
.
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 Please could you provide a sample repo (files/project) that we can use at our end to replicate this bug.
@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:
Starting Jedi Python language engine.
Diagnostic Code: InvalidTestSettingDiagnostic, Message: Your settings needs to be updated to change the setting "python.unitTest." to "python.testing.", otherwise testing Python code using the extension may not work. Would you like to automatically update your settings now?
VS Code version:
Version: 1.33.1 (user setup)
Commit: 51b0b28134d51361cf996d2f0a1c698247aeabd8
Date: 2019-04-11T08:27:14.102Z
Electron: 3.1.6
Chrome: 66.0.3359.181
Node.js: 10.2.0
V8: 6.6.346.32
OS: Windows_NT x64 10.0.17134
Anaconda: Python 3.6.5 :: Anaconda, Inc.
vscode_bug_demo
is my project folder.
[./vscode_bug_demo/.vscode/settings.json]
{
"python.pythonPath": "C:\\ProgramData\\Anaconda3\\python.exe",
"python.testing.unittestArgs": [
"-v",
"-s",
"./test",
"-p",
"*_test.py"
],
"python.testing.pyTestEnabled": true,
"python.testing.nosetestsEnabled": false,
"python.testing.unittestEnabled": false,
"python.testing.pyTestArgs": [
"test"
]
}
[./vscode_bug_demo/test/demo_test.py]
import pytest
class Test_Demo(object):
def test_demo(self):
assert True
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 OS and version: Windows 10 Python version: 3.7.2 in my virtualenv pytest-4.4.1
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 OS and version: Windows 10 Python version: 3.7.2 in my virtualenv pytest-4.4.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 __init__.py
file! Tests are discovered successfully. I have to add, that an existing __init__.py
has no effect on manually running pytest! Hope it helps discovering the bug.
@xibalba01 I guess you do not experience this issue as you do not specify a folder for your tests (python.testing.pyTestArgs
).
If you do so, like python.testing.pyTestArgs = [ "tests" ]
, VSCode tries to access the test file in tests/folder/test_sometest.py
as folder/test_sometest.py
, which of course isn't accessible.
For me, a work-around was to use python.testing.pyTestArgs = [ "." ]
and to ignore the folders I do not want to test.
@xibalba01 I guess you do not expirence this issue as you do not specify a folder for your tests (
python.testing.pyTestArgs
). If you do so, likepython.testing.pyTestArgs = [ "tests" ]
, VSCode tries to access the test file intests/folder/test_sometest.py
asfolder/test_sometest.py
, which of course isn't accessible.For me, a work-around was to use
python.testing.pyTestArgs = [ "." ]
and to ignore the folders I do not want to test.
While this is indeed a workaround for the non-recognition of tests in subfolders, which worked for me when I added an __init__.py
file in the subfolder, for me this still results in a test discovery error with exit code 2, related to an import of a package.
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 settings.json
in the repo i pointed to, i specified the root directory as test directory --> python.testing.pyTestArgs = [ "." ]
.
Anyway, i think it should not be such a hassle to discover tests, which are somewhere in the workspace folder tree - with or without __init__.py
. I am wondering that this is somehow broken, because the same setup worked a few days before (maybe it has to do with python extension update?!)...
As i said, when running pytest from the commandline from the root folder with the same commands from the pyTestArgs
the tests are discovered without any problem - with and without __init__.py
. Within vscode tests are only discovered when i leave out the __init__.py
. For replication check my repo: https://github.com/xibalba01/vscode_python_ext_bug
@r-beer i second that. More clear error messages would be helpful.
Test Discovery failed:
Error: Traceback (most recent call last):
File "c:\Users\wuguilin.vscode\extensions\ms-python.python-2019.4.11987\pythonFiles\testing_tools\run_adapter.py", line 16, in
import pytest
def test_a():
assert 1
I ran into the same issue. Here's a minimal repro (you need pytest
and pytest-flake8
):
Test discovery fails with the addopts line in pytest.ini
and passes without it.
Python Extension Version: 2019.4.11987 VSCode version: 1.33.1
Here's what should happen:
$ pytest --collect-only
============================= test session starts ==============================
platform darwin -- Python 3.7.3, pytest-4.3.1, py-1.8.0, pluggy-0.9.0
rootdir: /Users/hameerabbasi/Quansight/vscode-test, inifile: pytest.ini
plugins: mypy-0.3.2, flake8-1.0.4, cov-2.6.1, nbval-0.9.1
collected 2 items
<Flake8Item tests/test_abc.py>
<Module tests/test_abc.py>
<Function test_abc>
========================= no tests ran in 0.01 seconds =========================
I met similar issue here: Test discovery error, please check the configuration settings for the tests.
My setings.json: "python.testing.pyTestArgs": [ "." ], "python.testing.unittestEnabled": false, "python.testing.nosetestsEnabled": false, "python.testing.pyTestEnabled": true
VS Code Version: 1.33.1 Extension version Version: 2019.4.11987 Python version: 3.5.6 64-bit Type of virtual environment used (N/A | venv | virtualenv | conda | ...): conda Relevant/affected Python packages and their versions: pytest 4.4.0
@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 --no-cov
flag.
@DonJayamanne Here is my sample repo. https://github.com/musicguitar/vscode_python_pytest_fails_sample When I run the "Run All tests" in vscode. Also, there are no any test cases been found.
It shows the following errors:
Test Discovery failed:
Error: Traceback (most recent call last):
File "/home/darrenwu/.vscode/extensions/ms-python.python-2019.4.11987/pythonFiles/testing_tools/run_adapter.py", line 16, in <module>
main(tool, cmd, subargs, toolargs)
File "/home/darrenwu/.vscode/extensions/ms-python.python-2019.4.11987/pythonFiles/testing_tools/adapter/__main__.py", line 90, in main
parents, result = run(toolargs, **subargs)
File "/home/darrenwu/.vscode/extensions/ms-python.python-2019.4.11987/pythonFiles/testing_tools/adapter/pytest.py", line 43, in discover
raise Exception('pytest discovery failed (exit code {})'.format(ec))
Exception: pytest discovery failed (exit code 2)
Test Discovery failed:
Error: Traceback (most recent call last):
File "/home/darrenwu/.vscode/extensions/ms-python.python-2019.4.11987/pythonFiles/testing_tools/run_adapter.py", line 16, in <module>
main(tool, cmd, subargs, toolargs)
File "/home/darrenwu/.vscode/extensions/ms-python.python-2019.4.11987/pythonFiles/testing_tools/adapter/__main__.py", line 90, in main
parents, result = run(toolargs, **subargs)
File "/home/darrenwu/.vscode/extensions/ms-python.python-2019.4.11987/pythonFiles/testing_tools/adapter/pytest.py", line 43, in discover
raise Exception('pytest discovery failed (exit code {})'.format(ec))
Exception: pytest discovery failed (exit code 2)
Test Discovery failed:
Error: Traceback (most recent call last):
File "/home/darrenwu/.vscode/extensions/ms-python.python-2019.4.11987/pythonFiles/testing_tools/run_adapter.py", line 16, in <module>
main(tool, cmd, subargs, toolargs)
File "/home/darrenwu/.vscode/extensions/ms-python.python-2019.4.11987/pythonFiles/testing_tools/adapter/__main__.py", line 90, in main
parents, result = run(toolargs, **subargs)
File "/home/darrenwu/.vscode/extensions/ms-python.python-2019.4.11987/pythonFiles/testing_tools/adapter/pytest.py", line 43, in discover
raise Exception('pytest discovery failed (exit code {})'.format(ec))
Exception: pytest discovery failed (exit code 2)
Test Discovery failed:
Error: Traceback (most recent call last):
File "/home/darrenwu/.vscode/extensions/ms-python.python-2019.4.11987/pythonFiles/testing_tools/run_adapter.py", line 16, in <module>
main(tool, cmd, subargs, toolargs)
File "/home/darrenwu/.vscode/extensions/ms-python.python-2019.4.11987/pythonFiles/testing_tools/adapter/__main__.py", line 90, in main
parents, result = run(toolargs, **subargs)
File "/home/darrenwu/.vscode/extensions/ms-python.python-2019.4.11987/pythonFiles/testing_tools/adapter/pytest.py", line 43, in discover
raise Exception('pytest discovery failed (exit code {})'.format(ec))
Exception: pytest discovery failed (exit code 2)
============================= test session starts ==============================
platform linux -- Python 3.5.6, pytest-4.4.0, py-1.8.0, pluggy-0.9.0
rootdir: /home/darrenwu/workspace/stock/vscode_python_pytest_fails_sample
collected 1 item
tests/test_stockcodes.py . [100%]
-------------- generated xml file: /tmp/tmp-8268oUZMSUx4pq2M.xml ---------------
=========================== 1 passed in 0.27 seconds ===========================
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:
"python.unitTest.pyTestArgs": [
"."
],
"python.unitTest.unittestEnabled": false,
"python.unitTest.nosetestsEnabled": false,
"python.unitTest.pyTestEnabled": true
The pytest works with my test repo: https://github.com/musicguitar/vscode_python_pytest_fails_sample
Name: Python
Id: ms-python.python
Description: Linting, Debugging (multi-threaded, remote), Intellisense, code formatting, refactoring, unit tests, snippets, and more.
Version: 2019.3.6558
Publisher: Microsoft
VS Marketplace Link: https://marketplace.visualstudio.com/items?itemName=ms-python.python
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.
I have found out other interesting things...
Regarding version 2019.4.11987:
If test_module.py
IS NOT in a dedicated folder and the current working directory contains an __init__.py
-file, i have to use relative import syntax from . import module
to get test discovery to work.
If test_module.py
IS in a dedicated folder test discovery only works if the package directory is in my PATH/PYTHONPATH environment variable. Then i would have to use absolute import syntax: from package import module
. Explicit relative imports upwards the directory tree from .. import module
don't work.
Regarding version 2019.3.6558:
Without caring about __init__.py
files, dedicated folders or the way imports are done i can simply discover unittests.
test_module.py
in/not in a dedicated folder and without caring about the python.unittest.pyTestArgs
-setting simply use import module
Maybe this path/import related observations help you discover the bug...
I'm hitting this issue as well with my previously testing & working reference repo: https://github.com/noelbundick/azure-python-boilerplate
# setup
git clone https://github.com/noelbundick/azure-python-boilerplate
cd azure-python-boilerplate
python3 -m venv .venv
source .venv/bin/activate
# verify it's working in cli
boilerplate
pytest
code .
python.unitTest.*
to python.testing.*
in settings.jsonTest discovery failed
errorpython.unitTest.*
againNote that tests are discovered and tests pass
I wanted to give some transparency about this whole situation and how we got here as I know some people are a bit frustrated at the moment with our pytest support has been fluctuating a bit over the last few releases.
We used to use a hack to discover tests in pytest and the pytest team specifically asked us to stop (and rightfully so) 😁 . Pytest didn't have any stability guarantees for the hack we were using, hence why the last few releases there has been skew for what tests we discovered in the extension (totally our fault for using the hack BTW, it's just the usual software issue of having the time to do the proper fix versus patching what we had).
And so in this release we finally got around to using pytest's plug-in system for test discovery which is a more proper way. Unfortunately there seems to be a an issue yet again in terms of what pytest reports and what we used to discover using the hack (and I'm not placing blame on pytest, just that discovery is not universally broken, just that it's hard to pin down). Add to that the fact that pytest is very flexible in its discovery and it makes finding reproducers a bit hard without repos we can clone (thanks to those providing such repos!). We did increase our testing of test discovery as well, so I would like to think this isn't due to sloppiness on our part as much as the complexity of the whole situation as people's testing setups are not always simple.
Regardless of everything I have said above, we're obviously sorry this has caused trouble for folks and we are actively trying to figure out what's going on.
You are doing an awesome job by providing this extension! Thanks for all that effort!
I have to say, that it worked for me with pytest version 4.4.0 but due to the python extension update it stopped working. I tried to upgrade pytest to 4.4.1 but it didn't help. With pytest 4.4.1 and python extension 2019.3.6558 it works as exspected.
+1 I tried to upgrade pytest to 4.4.1 from 4.4.0 which didn't help. I have to downgrade python extension to 2019.3.6558.
You are doing an awesome job by providing this extension! Thanks for all that effort!
I have to say, that it worked for me with pytest version 4.4.0 but due to the python extension update it stopped working. I tried to upgrade pytest to 4.4.1 but it didn't help. With pytest 4.4.1 and python extension 2019.3.6558 it works as exspected.
With the latest version, on MacOS, the settings are python.unitTest. but on Linux, it is python.testing.. I have a hard time to share a consolidated cross-platform workspace setting file
@praenubilus
The settings are python.testing.*
on all platforms. Please update your extension on MacOS.
@DonJayamanne How do we handle the issue of pytest discovery failed (exit code 2). I see that changing unitTest to testing removes the unknown configuration error but any idea on how to handle pytest discovery failure? Thank you so much!
@akhilkumarco007 check my reply in #5401
Hi All. It looks like the problems are mostly related to conflicting pytest plugins. So for those that reported a problem, please reply with which pytest plugins you are using. Thanks!
Hi everyone:
Python Test Log
output panel. Please provide the details of the failure.Once again, we apologize for the inconvenience caused by this issue.
Tried the debug extension, the abbreviated error message is: "E ModuleNotFoundError: No module named 'mylib'" ./mylib is one of module folder in the project root dir.
This is the same error I get when I run "pytest" in my root project dir from command line. My work around was to run the following instead: "PYTHONPATH=. pytest"
The fix is probably ensuring that PYTHONPATH includes the project root dir when you launch 'pytest'.
@brettcannon @ericsnowcurrently
My work around was to run "python -m pytest" instead. The fix is probably ensuring that PYTHONPATH includes the project
I believe that's one of the problems. We've been using -m
which adds current DIR into path, whereas the current speech doesn't. Solution is to just add the workspace into the path.
Tried the debug extension, the abbreviated error message is: "E ModuleNotFoundError: No module named 'mylib'" ./mylib is one of module folder in the project root dir.
I get the same error with the development version when my project folder is not in PYTHONPATH. I think this error log would be generally a good idea because errno 2 from pytest is rather confusing than helpful.
As a good read regarding pytest test discovery i found this link from the pytest docs. It explains a lot of what can go wrong and how to properly set up your project folder for testing.
You asked for the installed plugins:
I only installed the coverage plugin from pip. The other plugins came with pytest.
platform win32 -- Python 3.7.1, pytest-4.4.1, py-1.8.0, pluggy-0.9.0
using: pytest-4.4.1 pylib-1.8.0
setuptools registered plugins:
pytest-cov-2.6.1 at C:\Users\USER\Miniconda3\lib\site-packages\pytest_cov\plugin.py
active plugins:
2744903230408 : <_pytest.config.PytestPluginManager object at 0x0000027F18FB63C8>
pytestconfig : <_pytest.config.Config object at 0x0000027F197500B8>
mark : C:\Users\USER\Miniconda3\lib\site-packages\_pytest\mark\__init__.py
main : C:\Users\USER\Miniconda3\lib\site-packages\_pytest\main.py
terminal : C:\Users\USER\Miniconda3\lib\site-packages\_pytest\terminal.py
runner : C:\Users\USER\Miniconda3\lib\site-packages\_pytest\runner.py
python : C:\Users\USER\Miniconda3\lib\site-packages\_pytest\python.py
fixtures : C:\Users\USER\Miniconda3\lib\site-packages\_pytest\fixtures.py
debugging : C:\Users\USER\Miniconda3\lib\site-packages\_pytest\debugging.py
unittest : C:\Users\USER\Miniconda3\lib\site-packages\_pytest\unittest.py
capture : C:\Users\USER\Miniconda3\lib\site-packages\_pytest\capture.py
skipping : C:\Users\USER\Miniconda3\lib\site-packages\_pytest\skipping.py
tmpdir : C:\Users\USER\Miniconda3\lib\site-packages\_pytest\tmpdir.py
monkeypatch : C:\Users\USER\Miniconda3\lib\site-packages\_pytest\monkeypatch.py
recwarn : C:\Users\USER\Miniconda3\lib\site-packages\_pytest\recwarn.py
pastebin : C:\Users\USER\Miniconda3\lib\site-packages\_pytest\pastebin.py
helpconfig : C:\Users\USER\Miniconda3\lib\site-packages\_pytest\helpconfig.py
nose : C:\Users\USER\Miniconda3\lib\site-packages\_pytest\nose.py
assertion : C:\Users\USER\Miniconda3\lib\site-packages\_pytest\assertion\__init__.py
junitxml : C:\Users\USER\Miniconda3\lib\site-packages\_pytest\junitxml.py
resultlog : C:\Users\USER\Miniconda3\lib\site-packages\_pytest\resultlog.py
doctest : C:\Users\USER\Miniconda3\lib\site-packages\_pytest\doctest.py
cacheprovider : C:\Users\USER\Miniconda3\lib\site-packages\_pytest\cacheprovider.py
freeze_support : C:\Users\USER\Miniconda3\lib\site-packages\_pytest\freeze_support.py
setuponly : C:\Users\USER\Miniconda3\lib\site-packages\_pytest\setuponly.py
setupplan : C:\Users\USER\Miniconda3\lib\site-packages\_pytest\setupplan.py
stepwise : C:\Users\USER\Miniconda3\lib\site-packages\_pytest\stepwise.py
warnings : C:\Users\USER\Miniconda3\lib\site-packages\_pytest\warnings.py
logging : C:\Users\USER\Miniconda3\lib\site-packages\_pytest\logging.py
reports : C:\Users\USER\Miniconda3\lib\site-packages\_pytest\reports.py
pytest_cov : C:\Users\USER\Miniconda3\lib\site-packages\pytest_cov\plugin.py
capturemanager : <CaptureManager _method='fd' _global_capturing=<MultiCapture out=<FDCapture 1 oldfd=8> err=<FDCapture 2 oldfd=9> in_=<FDCapture 0 oldfd=6>> _current_item=None>
session : <Session mocking_test exitstatus=0 testsfailed=0 testscollected=0>
lfplugin : <_pytest.cacheprovider.LFPlugin object at 0x0000027F1A2E6E48>
nfplugin : <_pytest.cacheprovider.NFPlugin object at 0x0000027F1A2E6F98>
stepwiseplugin : <_pytest.stepwise.StepwisePlugin object at 0x0000027F1A2D1FD0>
terminalreporter : <_pytest.terminal.TerminalReporter object at 0x0000027F1A2EF390>
logging-plugin : <_pytest.logging.LoggingPlugin object at 0x0000027F1A2FBDA0>
funcmanage : <_pytest.fixtures.FixtureManager object at 0x0000027F1A30B2B0>
I tested a few plugins (all installed, only one activated). It seems anything adding additional tests to the list fails.
cov
passes (no extra tests added)
- It looks like the problems are mostly related to conflicting pytest plugins. So for those that reported a problem, please reply with which pytest plugins you are using. Thanks!
I have the same issue with both pytest and unittest
@DonJayamanne
Please provide the details of the failure.
code .
from an active conda env with pytest and plugins installed as below:
# Name Version Build Channel
pytest 4.4.1 py37_0 conda-forge
pytest-cov 2.6.1 py_0 conda-forge
pytest-forked 1.0.2 py_0 conda-forge
pytest-xdist 1.28.0 py_0 conda-forge
python /Users/arg/.vscode/extensions/ms-python.python-2019.5.13046-dev/pythonFiles/testing_tools/run_adapter.py discover pytest -- -s --cache-clear
Test Discovery failed:
Error: ============================= test session starts ==============================
platform darwin -- Python 3.7.3, pytest-4.4.1, py-1.8.0, pluggy-0.9.0
rootdir: /my/repo/dir, inifile: setup.cfg
plugins: xdist-1.28.0, forked-1.0.2, cov-2.6.1
Iteration 1: K=6, E=-3921.542356, dE=inf
Iteration 2: K=6, E=-9005.635226, dE=5084.092869
Iteration 3: K=5, E=-9284.169959, dE=278.534733
Iteration 4: K=4, E=-9355.516041, dE=71.346083
Iteration 5: K=3, E=-9372.186172, dE=16.670131
Iteration 6: K=3, E=-9373.110672, dE=0.924500
Iteration 7: K=3, E=-9373.110672, dE=0.000000
collected 204 items / 2 errors / 18 deselected / 184 selected
Traceback (most recent call last):
File "/Users/arg/.vscode/extensions/ms-python.python-2019.5.13046-dev/pythonFiles/testing_tools/run_adapter.py", line 16, in
So, it looks like I had a type error, though it wasn't being picked up by other tools, though was causing test discovery to fail. Having the test discovery error logging from the insiders build you shared actually helped me find the issue and fix it. Please keep the extra logging as useful diagnosis.
After pulling a few hairs out I figured out how to debug this for my case.
The issue was that I had broken relative imports in a __init__.py
. I found this by running my unit tests manually:
python -m unittest
Which crashed out with a python trace clearly indicating the issue.
I looked around in VSCode hoping that an output panel would list this output but found nothing. I think it would be good to report the stderr/stdout to a log somewhere when VSCode cannot find tests.
Seeing the same thing. Just reinstalled the latest python extension. Here's my settings and test discovery output.
{
// relevant settings
"python.pythonPath": ".venv/bin/python",
"python.testing.pyTestArgs": ["-m", "tests"],
"python.testing.unittestEnabled": false,
"python.testing.nosetestsEnabled": false,
"python.testing.pyTestEnabled": true,
"python.testing.cwd": "${workspaceFolder}",
"python.testing.pyTestPath": ".venv/bin/pytest"
}
The Python Test Log shows all of my test functions being found. Truncated output is as follows:
============================= test session starts ==============================
platform linux -- Python 3.6.7, pytest-4.4.1, py-1.8.0, pluggy-0.9.0
rootdir: /home/username/path/workspaceroot/tests
collected 92 items
<Package /home/username/path/workspaceroot/tests/models>
<Module test_foo.py>
<Function test_bar>
...
========================= no tests ran in 0.13 seconds =========================
Test Discovery failed:
TypeError: Cannot read property 'uri' of undefined
============================= test session starts ==============================
platform linux -- Python 3.6.7, pytest-4.4.1, py-1.8.0, pluggy-0.9.0
rootdir: /home/username/path/workspaceroot/tests
collected 92 items / 92 deselected
-------------- generated xml file: /tmp/tmp-312305gw4Jz1Vl5wy.xml --------------
======================== 92 deselected in 0.13 seconds =========================
Running pytest
manually works fine. Not sure where the uri
error is coming from. I've got __init__.py
s for all of my subdirs within tests/
.
Reverting works for me. pip list in my virtual environment shows
...
pytest 3.10.0
@ablakey there is an Output Panel and you can choose Python test output for it see things like tracebacks and such.
@cdietschrun FYI that's a very old version of pytest, so you might want to see if you can upgrade.
This error went away and then came back for me.
The log:
python /Users/hameerabbasi/.vscode/extensions/ms-python.python-2019.6.24221/pythonFiles/testing_tools/run_adapter.py discover pytest -- -s --cache-clear
Test Discovery failed:
Error: ============================= test session starts ==============================
platform darwin -- Python 3.7.3, pytest-5.0.1, py-1.8.0, pluggy-0.12.0
rootdir: /Users/hameerabbasi/Quansight/unumpy, inifile: pytest.ini, testpaths: unumpy
plugins: mypy-0.3.3, cov-2.7.1, black-0.3.7
collected 183 items
<BlackItem unumpy/__init__.py>
<MypyItem unumpy/__init__.py>
<DoctestModule unumpy/__init__.py>
<DoctestItem unumpy>
<Package /Users/hameerabbasi/Quansight/unumpy/unumpy>
<BlackItem _multimethods.py>
<MypyItem _multimethods.py>
<BlackItem _version.py>
<MypyItem _version.py>
<BlackItem cupy_backend.py>
<MypyItem cupy_backend.py>
<BlackItem dask_backend.py>
<MypyItem dask_backend.py>
<BlackItem numpy_backend.py>
<MypyItem numpy_backend.py>
<BlackItem sparse_backend.py>
<MypyItem sparse_backend.py>
<BlackItem torch_backend.py>
<MypyItem torch_backend.py>
<BlackItem xnd_backend.py>
<MypyItem xnd_backend.py>
<BlackItem unumpy/tests/__init__.py>
<MypyItem unumpy/tests/__init__.py>
<Package /Users/hameerabbasi/Quansight/unumpy/unumpy/tests>
<BlackItem test_numpy.py>
<MypyItem test_numpy.py>
<Module test_numpy.py>
<Function test_ufuncs_coerce[backend0-method0-args0-kwargs0]>
<Function test_ufuncs_coerce[backend0-method1-args1-kwargs1]>
<Function test_ufuncs_coerce[backend0-method2-args2-kwargs2]>
<Function test_functions_coerce[backend0-method0-args0-kwargs0]>
<Function test_functions_coerce[backend0-method1-args1-kwargs1]>
<Function test_functions_coerce[backend0-method2-args2-kwargs2]>
<Function test_functions_coerce[backend0-method3-args3-kwargs3]>
<Function test_functions_coerce[backend0-method4-args4-kwargs4]>
<Function test_functions_coerce[backend0-method5-args5-kwargs5]>
<Function test_functions_coerce[backend0-method6-args6-kwargs6]>
<Function test_functions_coerce[backend0-method7-args7-kwargs7]>
<Function test_functions_coerce[backend0-method8-args8-kwargs8]>
<Function test_functions_coerce[backend0-method9-args9-kwargs9]>
<Function test_functions_coerce[backend0-method10-args10-kwargs10]>
<Function test_functions_coerce[backend0-method11-args11-kwargs11]>
<Function test_functions_coerce[backend0-method12-args12-kwargs12]>
<Function test_functions_coerce[backend0-method13-args13-kwargs13]>
<Function test_functions_coerce[backend0-method14-args14-kwargs14]>
<Function test_functions_coerce[backend0-method15-args15-kwargs15]>
<Function test_functions_coerce[backend0-method16-args16-kwargs16]>
<Function test_functions_coerce[backend0-method17-args17-kwargs17]>
<Function test_functions_coerce[backend0-method18-args18-kwargs18]>
<Function test_functions_coerce[backend0-method19-args19-kwargs19]>
<Function test_functions_coerce[backend0-method20-args20-kwargs20]>
<Function test_functions_coerce[backend0-method21-args21-kwargs21]>
<Function test_functions_coerce[backend0-method22-args22-kwargs22]>
<Function test_functions_coerce[backend0-method23-args23-kwargs23]>
<Function test_functions_coerce[backend0-method24-args24-kwargs24]>
<Function test_functions_coerce[backend0-method25-args25-kwargs25]>
<Function test_functions_coerce[backend0-method26-args26-kwargs26]>
<Function test_functions_coerce[backend0-method27-args27-kwargs27]>
<Function test_multiple_output[backend0-method0-args0-kwargs0]>
<Function test_ufuncs_coerce[backend1-method0-args0-kwargs0]>
<Function test_ufuncs_coerce[backend1-method1-args1-kwargs1]>
<Function test_ufuncs_coerce[backend1-method2-args2-kwargs2]>
<Function test_functions_coerce[backend1-method0-args0-kwargs0]>
<Function test_functions_coerce[backend1-method1-args1-kwargs1]>
<Function test_functions_coerce[backend1-method2-args2-kwargs2]>
<Function test_functions_coerce[backend1-method3-args3-kwargs3]>
<Function test_functions_coerce[backend1-method4-args4-kwargs4]>
<Function test_functions_coerce[backend1-method5-args5-kwargs5]>
<Function test_functions_coerce[backend1-method6-args6-kwargs6]>
<Function test_functions_coerce[backend1-method7-args7-kwargs7]>
<Function test_functions_coerce[backend1-method8-args8-kwargs8]>
<Function test_functions_coerce[backend1-method9-args9-kwargs9]>
<Function test_functions_coerce[backend1-method10-args10-kwargs10]>
<Function test_functions_coerce[backend1-method11-args11-kwargs11]>
<Function test_functions_coerce[backend1-method12-args12-kwargs12]>
<Function test_functions_coerce[backend1-method13-args13-kwargs13]>
<Function test_functions_coerce[backend1-method14-args14-kwargs14]>
<Function test_functions_coerce[backend1-method15-args15-kwargs15]>
<Function test_functions_coerce[backend1-method16-args16-kwargs16]>
<Function test_functions_coerce[backend1-method17-args17-kwargs17]>
<Function test_functions_coerce[backend1-method18-args18-kwargs18]>
<Function test_functions_coerce[backend1-method19-args19-kwargs19]>
<Function test_functions_coerce[backend1-method20-args20-kwargs20]>
<Function test_functions_coerce[backend1-method21-args21-kwargs21]>
<Function test_functions_coerce[backend1-method22-args22-kwargs22]>
<Function test_functions_coerce[backend1-method23-args23-kwargs23]>
<Function test_functions_coerce[backend1-method24-args24-kwargs24]>
<Function test_functions_coerce[backend1-method25-args25-kwargs25]>
<Function test_functions_coerce[backend1-method26-args26-kwargs26]>
<Function test_functions_coerce[backend1-method27-args27-kwargs27]>
<Function test_multiple_output[backend1-method0-args0-kwargs0]>
<Function test_ufuncs_coerce[backend2-method0-args0-kwargs0]>
<Function test_ufuncs_coerce[backend2-method1-args1-kwargs1]>
<Function test_ufuncs_coerce[backend2-method2-args2-kwargs2]>
<Function test_functions_coerce[backend2-method0-args0-kwargs0]>
<Function test_functions_coerce[backend2-method1-args1-kwargs1]>
<Function test_functions_coerce[backend2-method2-args2-kwargs2]>
<Function test_functions_coerce[backend2-method3-args3-kwargs3]>
<Function test_functions_coerce[backend2-method4-args4-kwargs4]>
<Function test_functions_coerce[backend2-method5-args5-kwargs5]>
<Function test_functions_coerce[backend2-method6-args6-kwargs6]>
<Function test_functions_coerce[backend2-method7-args7-kwargs7]>
<Function test_functions_coerce[backend2-method8-args8-kwargs8]>
<Function test_functions_coerce[backend2-method9-args9-kwargs9]>
<Function test_functions_coerce[backend2-method10-args10-kwargs10]>
<Function test_functions_coerce[backend2-method11-args11-kwargs11]>
<Function test_functions_coerce[backend2-method12-args12-kwargs12]>
<Function test_functions_coerce[backend2-method13-args13-kwargs13]>
<Function test_functions_coerce[backend2-method14-args14-kwargs14]>
<Function test_functions_coerce[backend2-method15-args15-kwargs15]>
<Function test_functions_coerce[backend2-method16-args16-kwargs16]>
<Function test_functions_coerce[backend2-method17-args17-kwargs17]>
<Function test_functions_coerce[backend2-method18-args18-kwargs18]>
<Function test_functions_coerce[backend2-method19-args19-kwargs19]>
<Function test_functions_coerce[backend2-method20-args20-kwargs20]>
<Function test_functions_coerce[backend2-method21-args21-kwargs21]>
<Function test_functions_coerce[backend2-method22-args22-kwargs22]>
<Function test_functions_coerce[backend2-method23-args23-kwargs23]>
<Function test_functions_coerce[backend2-method24-args24-kwargs24]>
<Function test_functions_coerce[backend2-method25-args25-kwargs25]>
<Function test_functions_coerce[backend2-method26-args26-kwargs26]>
<Function test_functions_coerce[backend2-method27-args27-kwargs27]>
<Function test_multiple_output[backend2-method0-args0-kwargs0]>
<Function test_ufuncs_coerce[backend3-method0-args0-kwargs0]>
<Function test_ufuncs_coerce[backend3-method1-args1-kwargs1]>
<Function test_ufuncs_coerce[backend3-method2-args2-kwargs2]>
<Function test_functions_coerce[backend3-method0-args0-kwargs0]>
<Function test_functions_coerce[backend3-method1-args1-kwargs1]>
<Function test_functions_coerce[backend3-method2-args2-kwargs2]>
<Function test_functions_coerce[backend3-method3-args3-kwargs3]>
<Function test_functions_coerce[backend3-method4-args4-kwargs4]>
<Function test_functions_coerce[backend3-method5-args5-kwargs5]>
<Function test_functions_coerce[backend3-method6-args6-kwargs6]>
<Function test_functions_coerce[backend3-method7-args7-kwargs7]>
<Function test_functions_coerce[backend3-method8-args8-kwargs8]>
<Function test_functions_coerce[backend3-method9-args9-kwargs9]>
<Function test_functions_coerce[backend3-method10-args10-kwargs10]>
<Function test_functions_coerce[backend3-method11-args11-kwargs11]>
<Function test_functions_coerce[backend3-method12-args12-kwargs12]>
<Function test_functions_coerce[backend3-method13-args13-kwargs13]>
<Function test_functions_coerce[backend3-method14-args14-kwargs14]>
<Function test_functions_coerce[backend3-method15-args15-kwargs15]>
<Function test_functions_coerce[backend3-method16-args16-kwargs16]>
<Function test_functions_coerce[backend3-method17-args17-kwargs17]>
<Function test_functions_coerce[backend3-method18-args18-kwargs18]>
<Function test_functions_coerce[backend3-method19-args19-kwargs19]>
<Function test_functions_coerce[backend3-method20-args20-kwargs20]>
<Function test_functions_coerce[backend3-method21-args21-kwargs21]>
<Function test_functions_coerce[backend3-method22-args22-kwargs22]>
<Function test_functions_coerce[backend3-method23-args23-kwargs23]>
<Function test_functions_coerce[backend3-method24-args24-kwargs24]>
<Function test_functions_coerce[backend3-method25-args25-kwargs25]>
<Function test_functions_coerce[backend3-method26-args26-kwargs26]>
<Function test_functions_coerce[backend3-method27-args27-kwargs27]>
<Function test_multiple_output[backend3-method0-args0-kwargs0]>
<Function test_ufuncs_coerce[backend4-method0-args0-kwargs0]>
<Function test_ufuncs_coerce[backend4-method1-args1-kwargs1]>
<Function test_ufuncs_coerce[backend4-method2-args2-kwargs2]>
<Function test_functions_coerce[backend4-method0-args0-kwargs0]>
<Function test_functions_coerce[backend4-method1-args1-kwargs1]>
<Function test_functions_coerce[backend4-method2-args2-kwargs2]>
<Function test_functions_coerce[backend4-method3-args3-kwargs3]>
<Function test_functions_coerce[backend4-method4-args4-kwargs4]>
<Function test_functions_coerce[backend4-method5-args5-kwargs5]>
<Function test_functions_coerce[backend4-method6-args6-kwargs6]>
<Function test_functions_coerce[backend4-method7-args7-kwargs7]>
<Function test_functions_coerce[backend4-method8-args8-kwargs8]>
<Function test_functions_coerce[backend4-method9-args9-kwargs9]>
<Function test_functions_coerce[backend4-method10-args10-kwargs10]>
<Function test_functions_coerce[backend4-method11-args11-kwargs11]>
<Function test_functions_coerce[backend4-method12-args12-kwargs12]>
<Function test_functions_coerce[backend4-method13-args13-kwargs13]>
<Function test_functions_coerce[backend4-method14-args14-kwargs14]>
<Function test_functions_coerce[backend4-method15-args15-kwargs15]>
<Function test_functions_coerce[backend4-method16-args16-kwargs16]>
<Function test_functions_coerce[backend4-method17-args17-kwargs17]>
<Function test_functions_coerce[backend4-method18-args18-kwargs18]>
<Function test_functions_coerce[backend4-method19-args19-kwargs19]>
<Function test_functions_coerce[backend4-method20-args20-kwargs20]>
<Function test_functions_coerce[backend4-method21-args21-kwargs21]>
<Function test_functions_coerce[backend4-method22-args22-kwargs22]>
<Function test_functions_coerce[backend4-method23-args23-kwargs23]>
<Function test_functions_coerce[backend4-method24-args24-kwargs24]>
<Function test_functions_coerce[backend4-method25-args25-kwargs25]>
<Function test_functions_coerce[backend4-method26-args26-kwargs26]>
<Function test_functions_coerce[backend4-method27-args27-kwargs27]>
<Function test_multiple_output[backend4-method0-args0-kwargs0]>
INTERNALERROR> Traceback (most recent call last):
INTERNALERROR> File "/Users/hameerabbasi/miniconda3/envs/uarray/lib/python3.7/site-packages/_pytest/main.py", line 462, in perform_collect
INTERNALERROR> session=self, config=self.config, items=items
INTERNALERROR> File "/Users/hameerabbasi/miniconda3/envs/uarray/lib/python3.7/site-packages/pluggy/hooks.py", line 289, in __call__
INTERNALERROR> return self._hookexec(self, self.get_hookimpls(), kwargs)
INTERNALERROR> File "/Users/hameerabbasi/miniconda3/envs/uarray/lib/python3.7/site-packages/pluggy/manager.py", line 87, in _hookexec
INTERNALERROR> return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR> File "/Users/hameerabbasi/miniconda3/envs/uarray/lib/python3.7/site-packages/pluggy/manager.py", line 81, in <lambda>
INTERNALERROR> firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
INTERNALERROR> File "/Users/hameerabbasi/miniconda3/envs/uarray/lib/python3.7/site-packages/pluggy/callers.py", line 208, in _multicall
INTERNALERROR> return outcome.get_result()
INTERNALERROR> File "/Users/hameerabbasi/miniconda3/envs/uarray/lib/python3.7/site-packages/pluggy/callers.py", line 80, in get_result
INTERNALERROR> raise ex[1].with_traceback(ex[2])
INTERNALERROR> File "/Users/hameerabbasi/miniconda3/envs/uarray/lib/python3.7/site-packages/pluggy/callers.py", line 187, in _multicall
INTERNALERROR> res = hook_impl.function(*args)
INTERNALERROR> File "/Users/hameerabbasi/.vscode/extensions/ms-python.python-2019.6.24221/pythonFiles/testing_tools/adapter/pytest/_discovery.py", line 77, in pytest_collection_modifyitems
INTERNALERROR> self._tests.add_test(test, parents)
INTERNALERROR> File "/Users/hameerabbasi/.vscode/extensions/ms-python.python-2019.6.24221/pythonFiles/testing_tools/adapter/discovery.py", line 35, in add_test
INTERNALERROR> parentid = self._ensure_parent(test.path, parents)
INTERNALERROR> File "/Users/hameerabbasi/.vscode/extensions/ms-python.python-2019.6.24221/pythonFiles/testing_tools/adapter/discovery.py", line 60, in _ensure_parent
INTERNALERROR> assert nodeid == '.'
INTERNALERROR> AssertionError
INTERNALERROR>
INTERNALERROR> During handling of the above exception, another exception occurred:
INTERNALERROR>
INTERNALERROR> Traceback (most recent call last):
INTERNALERROR> File "/Users/hameerabbasi/miniconda3/envs/uarray/lib/python3.7/site-packages/_pytest/main.py", line 213, in wrap_session
INTERNALERROR> session.exitstatus = doit(config, session) or 0
INTERNALERROR> File "/Users/hameerabbasi/miniconda3/envs/uarray/lib/python3.7/site-packages/_pytest/main.py", line 256, in _main
INTERNALERROR> config.hook.pytest_collection(session=session)
INTERNALERROR> File "/Users/hameerabbasi/miniconda3/envs/uarray/lib/python3.7/site-packages/pluggy/hooks.py", line 289, in __call__
INTERNALERROR> return self._hookexec(self, self.get_hookimpls(), kwargs)
INTERNALERROR> File "/Users/hameerabbasi/miniconda3/envs/uarray/lib/python3.7/site-packages/pluggy/manager.py", line 87, in _hookexec
INTERNALERROR> return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR> File "/Users/hameerabbasi/miniconda3/envs/uarray/lib/python3.7/site-packages/pluggy/manager.py", line 81, in <lambda>
INTERNALERROR> firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
INTERNALERROR> File "/Users/hameerabbasi/miniconda3/envs/uarray/lib/python3.7/site-packages/pluggy/callers.py", line 208, in _multicall
INTERNALERROR> return outcome.get_result()
INTERNALERROR> File "/Users/hameerabbasi/miniconda3/envs/uarray/lib/python3.7/site-packages/pluggy/callers.py", line 80, in get_result
INTERNALERROR> raise ex[1].with_traceback(ex[2])
INTERNALERROR> File "/Users/hameerabbasi/miniconda3/envs/uarray/lib/python3.7/site-packages/pluggy/callers.py", line 187, in _multicall
INTERNALERROR> res = hook_impl.function(*args)
INTERNALERROR> File "/Users/hameerabbasi/miniconda3/envs/uarray/lib/python3.7/site-packages/_pytest/main.py", line 266, in pytest_collection
INTERNALERROR> return session.perform_collect()
INTERNALERROR> File "/Users/hameerabbasi/miniconda3/envs/uarray/lib/python3.7/site-packages/_pytest/main.py", line 465, in perform_collect
INTERNALERROR> hook.pytest_collection_finish(session=self)
INTERNALERROR> File "/Users/hameerabbasi/miniconda3/envs/uarray/lib/python3.7/site-packages/pluggy/hooks.py", line 289, in __call__
INTERNALERROR> return self._hookexec(self, self.get_hookimpls(), kwargs)
INTERNALERROR> File "/Users/hameerabbasi/miniconda3/envs/uarray/lib/python3.7/site-packages/pluggy/manager.py", line 87, in _hookexec
INTERNALERROR> return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR> File "/Users/hameerabbasi/miniconda3/envs/uarray/lib/python3.7/site-packages/pluggy/manager.py", line 81, in <lambda>
INTERNALERROR> firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
INTERNALERROR> File "/Users/hameerabbasi/miniconda3/envs/uarray/lib/python3.7/site-packages/pluggy/callers.py", line 208, in _multicall
INTERNALERROR> return outcome.get_result()
INTERNALERROR> File "/Users/hameerabbasi/miniconda3/envs/uarray/lib/python3.7/site-packages/pluggy/callers.py", line 80, in get_result
INTERNALERROR> raise ex[1].with_traceback(ex[2])
INTERNALERROR> File "/Users/hameerabbasi/miniconda3/envs/uarray/lib/python3.7/site-packages/pluggy/callers.py", line 187, in _multicall
INTERNALERROR> res = hook_impl.function(*args)
INTERNALERROR> File "/Users/hameerabbasi/.vscode/extensions/ms-python.python-2019.6.24221/pythonFiles/testing_tools/adapter/pytest/_discovery.py", line 91, in pytest_collection_finish
INTERNALERROR> self._tests.add_test(test, parents)
INTERNALERROR> File "/Users/hameerabbasi/.vscode/extensions/ms-python.python-2019.6.24221/pythonFiles/testing_tools/adapter/discovery.py", line 35, in add_test
INTERNALERROR> parentid = self._ensure_parent(test.path, parents)
INTERNALERROR> File "/Users/hameerabbasi/.vscode/extensions/ms-python.python-2019.6.24221/pythonFiles/testing_tools/adapter/discovery.py", line 60, in _ensure_parent
INTERNALERROR> assert nodeid == '.'
INTERNALERROR> AssertionError
========================= no tests ran in 1.18 seconds =========================
Traceback (most recent call last):
File "/Users/hameerabbasi/.vscode/extensions/ms-python.python-2019.6.24221/pythonFiles/testing_tools/run_adapter.py", line 16, in <module>
main(tool, cmd, subargs, toolargs)
File "/Users/hameerabbasi/.vscode/extensions/ms-python.python-2019.6.24221/pythonFiles/testing_tools/adapter/__main__.py", line 90, in main
parents, result = run(toolargs, **subargs)
File "/Users/hameerabbasi/.vscode/extensions/ms-python.python-2019.6.24221/pythonFiles/testing_tools/adapter/pytest/_discovery.py", line 34, in discover
raise Exception('pytest discovery failed (exit code {})'.format(ec))
Exception: pytest discovery failed (exit code 3)
pytest --collect-only
============================================== test session starts ==============================================
platform darwin -- Python 3.7.3, pytest-5.0.1, py-1.8.0, pluggy-0.12.0
rootdir: /Users/hameerabbasi/Quansight/unumpy, inifile: pytest.ini, testpaths: unumpy
plugins: mypy-0.3.3, cov-2.7.1, black-0.3.7
collected 183 items
<BlackItem unumpy/__init__.py>
<MypyItem unumpy/__init__.py>
<DoctestModule unumpy/__init__.py>
<DoctestItem unumpy>
<Package /Users/hameerabbasi/Quansight/unumpy/unumpy>
<BlackItem _multimethods.py>
<MypyItem _multimethods.py>
<BlackItem _version.py>
<MypyItem _version.py>
<BlackItem cupy_backend.py>
<MypyItem cupy_backend.py>
<BlackItem dask_backend.py>
<MypyItem dask_backend.py>
<BlackItem numpy_backend.py>
<MypyItem numpy_backend.py>
<BlackItem sparse_backend.py>
<MypyItem sparse_backend.py>
<BlackItem torch_backend.py>
<MypyItem torch_backend.py>
<BlackItem xnd_backend.py>
<MypyItem xnd_backend.py>
<BlackItem unumpy/tests/__init__.py>
<MypyItem unumpy/tests/__init__.py>
<Package /Users/hameerabbasi/Quansight/unumpy/unumpy/tests>
<BlackItem test_numpy.py>
<MypyItem test_numpy.py>
<Module test_numpy.py>
<Function test_ufuncs_coerce[backend0-method0-args0-kwargs0]>
<Function test_ufuncs_coerce[backend0-method1-args1-kwargs1]>
<Function test_ufuncs_coerce[backend0-method2-args2-kwargs2]>
<Function test_functions_coerce[backend0-method0-args0-kwargs0]>
<Function test_functions_coerce[backend0-method1-args1-kwargs1]>
<Function test_functions_coerce[backend0-method2-args2-kwargs2]>
<Function test_functions_coerce[backend0-method3-args3-kwargs3]>
<Function test_functions_coerce[backend0-method4-args4-kwargs4]>
<Function test_functions_coerce[backend0-method5-args5-kwargs5]>
<Function test_functions_coerce[backend0-method6-args6-kwargs6]>
<Function test_functions_coerce[backend0-method7-args7-kwargs7]>
<Function test_functions_coerce[backend0-method8-args8-kwargs8]>
<Function test_functions_coerce[backend0-method9-args9-kwargs9]>
<Function test_functions_coerce[backend0-method10-args10-kwargs10]>
<Function test_functions_coerce[backend0-method11-args11-kwargs11]>
<Function test_functions_coerce[backend0-method12-args12-kwargs12]>
<Function test_functions_coerce[backend0-method13-args13-kwargs13]>
<Function test_functions_coerce[backend0-method14-args14-kwargs14]>
<Function test_functions_coerce[backend0-method15-args15-kwargs15]>
<Function test_functions_coerce[backend0-method16-args16-kwargs16]>
<Function test_functions_coerce[backend0-method17-args17-kwargs17]>
<Function test_functions_coerce[backend0-method18-args18-kwargs18]>
<Function test_functions_coerce[backend0-method19-args19-kwargs19]>
<Function test_functions_coerce[backend0-method20-args20-kwargs20]>
<Function test_functions_coerce[backend0-method21-args21-kwargs21]>
<Function test_functions_coerce[backend0-method22-args22-kwargs22]>
<Function test_functions_coerce[backend0-method23-args23-kwargs23]>
<Function test_functions_coerce[backend0-method24-args24-kwargs24]>
<Function test_functions_coerce[backend0-method25-args25-kwargs25]>
<Function test_functions_coerce[backend0-method26-args26-kwargs26]>
<Function test_functions_coerce[backend0-method27-args27-kwargs27]>
<Function test_multiple_output[backend0-method0-args0-kwargs0]>
<Function test_ufuncs_coerce[backend1-method0-args0-kwargs0]>
<Function test_ufuncs_coerce[backend1-method1-args1-kwargs1]>
<Function test_ufuncs_coerce[backend1-method2-args2-kwargs2]>
<Function test_functions_coerce[backend1-method0-args0-kwargs0]>
<Function test_functions_coerce[backend1-method1-args1-kwargs1]>
<Function test_functions_coerce[backend1-method2-args2-kwargs2]>
<Function test_functions_coerce[backend1-method3-args3-kwargs3]>
<Function test_functions_coerce[backend1-method4-args4-kwargs4]>
<Function test_functions_coerce[backend1-method5-args5-kwargs5]>
<Function test_functions_coerce[backend1-method6-args6-kwargs6]>
<Function test_functions_coerce[backend1-method7-args7-kwargs7]>
<Function test_functions_coerce[backend1-method8-args8-kwargs8]>
<Function test_functions_coerce[backend1-method9-args9-kwargs9]>
<Function test_functions_coerce[backend1-method10-args10-kwargs10]>
<Function test_functions_coerce[backend1-method11-args11-kwargs11]>
<Function test_functions_coerce[backend1-method12-args12-kwargs12]>
<Function test_functions_coerce[backend1-method13-args13-kwargs13]>
<Function test_functions_coerce[backend1-method14-args14-kwargs14]>
<Function test_functions_coerce[backend1-method15-args15-kwargs15]>
<Function test_functions_coerce[backend1-method16-args16-kwargs16]>
<Function test_functions_coerce[backend1-method17-args17-kwargs17]>
<Function test_functions_coerce[backend1-method18-args18-kwargs18]>
<Function test_functions_coerce[backend1-method19-args19-kwargs19]>
<Function test_functions_coerce[backend1-method20-args20-kwargs20]>
<Function test_functions_coerce[backend1-method21-args21-kwargs21]>
<Function test_functions_coerce[backend1-method22-args22-kwargs22]>
<Function test_functions_coerce[backend1-method23-args23-kwargs23]>
<Function test_functions_coerce[backend1-method24-args24-kwargs24]>
<Function test_functions_coerce[backend1-method25-args25-kwargs25]>
<Function test_functions_coerce[backend1-method26-args26-kwargs26]>
<Function test_functions_coerce[backend1-method27-args27-kwargs27]>
<Function test_multiple_output[backend1-method0-args0-kwargs0]>
<Function test_ufuncs_coerce[backend2-method0-args0-kwargs0]>
<Function test_ufuncs_coerce[backend2-method1-args1-kwargs1]>
<Function test_ufuncs_coerce[backend2-method2-args2-kwargs2]>
<Function test_functions_coerce[backend2-method0-args0-kwargs0]>
<Function test_functions_coerce[backend2-method1-args1-kwargs1]>
<Function test_functions_coerce[backend2-method2-args2-kwargs2]>
<Function test_functions_coerce[backend2-method3-args3-kwargs3]>
<Function test_functions_coerce[backend2-method4-args4-kwargs4]>
<Function test_functions_coerce[backend2-method5-args5-kwargs5]>
<Function test_functions_coerce[backend2-method6-args6-kwargs6]>
<Function test_functions_coerce[backend2-method7-args7-kwargs7]>
<Function test_functions_coerce[backend2-method8-args8-kwargs8]>
<Function test_functions_coerce[backend2-method9-args9-kwargs9]>
<Function test_functions_coerce[backend2-method10-args10-kwargs10]>
<Function test_functions_coerce[backend2-method11-args11-kwargs11]>
<Function test_functions_coerce[backend2-method12-args12-kwargs12]>
<Function test_functions_coerce[backend2-method13-args13-kwargs13]>
<Function test_functions_coerce[backend2-method14-args14-kwargs14]>
<Function test_functions_coerce[backend2-method15-args15-kwargs15]>
<Function test_functions_coerce[backend2-method16-args16-kwargs16]>
<Function test_functions_coerce[backend2-method17-args17-kwargs17]>
<Function test_functions_coerce[backend2-method18-args18-kwargs18]>
<Function test_functions_coerce[backend2-method19-args19-kwargs19]>
<Function test_functions_coerce[backend2-method20-args20-kwargs20]>
<Function test_functions_coerce[backend2-method21-args21-kwargs21]>
<Function test_functions_coerce[backend2-method22-args22-kwargs22]>
<Function test_functions_coerce[backend2-method23-args23-kwargs23]>
<Function test_functions_coerce[backend2-method24-args24-kwargs24]>
<Function test_functions_coerce[backend2-method25-args25-kwargs25]>
<Function test_functions_coerce[backend2-method26-args26-kwargs26]>
<Function test_functions_coerce[backend2-method27-args27-kwargs27]>
<Function test_multiple_output[backend2-method0-args0-kwargs0]>
<Function test_ufuncs_coerce[backend3-method0-args0-kwargs0]>
<Function test_ufuncs_coerce[backend3-method1-args1-kwargs1]>
<Function test_ufuncs_coerce[backend3-method2-args2-kwargs2]>
<Function test_functions_coerce[backend3-method0-args0-kwargs0]>
<Function test_functions_coerce[backend3-method1-args1-kwargs1]>
<Function test_functions_coerce[backend3-method2-args2-kwargs2]>
<Function test_functions_coerce[backend3-method3-args3-kwargs3]>
<Function test_functions_coerce[backend3-method4-args4-kwargs4]>
<Function test_functions_coerce[backend3-method5-args5-kwargs5]>
<Function test_functions_coerce[backend3-method6-args6-kwargs6]>
<Function test_functions_coerce[backend3-method7-args7-kwargs7]>
<Function test_functions_coerce[backend3-method8-args8-kwargs8]>
<Function test_functions_coerce[backend3-method9-args9-kwargs9]>
<Function test_functions_coerce[backend3-method10-args10-kwargs10]>
<Function test_functions_coerce[backend3-method11-args11-kwargs11]>
<Function test_functions_coerce[backend3-method12-args12-kwargs12]>
<Function test_functions_coerce[backend3-method13-args13-kwargs13]>
<Function test_functions_coerce[backend3-method14-args14-kwargs14]>
<Function test_functions_coerce[backend3-method15-args15-kwargs15]>
<Function test_functions_coerce[backend3-method16-args16-kwargs16]>
<Function test_functions_coerce[backend3-method17-args17-kwargs17]>
<Function test_functions_coerce[backend3-method18-args18-kwargs18]>
<Function test_functions_coerce[backend3-method19-args19-kwargs19]>
<Function test_functions_coerce[backend3-method20-args20-kwargs20]>
<Function test_functions_coerce[backend3-method21-args21-kwargs21]>
<Function test_functions_coerce[backend3-method22-args22-kwargs22]>
<Function test_functions_coerce[backend3-method23-args23-kwargs23]>
<Function test_functions_coerce[backend3-method24-args24-kwargs24]>
<Function test_functions_coerce[backend3-method25-args25-kwargs25]>
<Function test_functions_coerce[backend3-method26-args26-kwargs26]>
<Function test_functions_coerce[backend3-method27-args27-kwargs27]>
<Function test_multiple_output[backend3-method0-args0-kwargs0]>
<Function test_ufuncs_coerce[backend4-method0-args0-kwargs0]>
<Function test_ufuncs_coerce[backend4-method1-args1-kwargs1]>
<Function test_ufuncs_coerce[backend4-method2-args2-kwargs2]>
<Function test_functions_coerce[backend4-method0-args0-kwargs0]>
<Function test_functions_coerce[backend4-method1-args1-kwargs1]>
<Function test_functions_coerce[backend4-method2-args2-kwargs2]>
<Function test_functions_coerce[backend4-method3-args3-kwargs3]>
<Function test_functions_coerce[backend4-method4-args4-kwargs4]>
<Function test_functions_coerce[backend4-method5-args5-kwargs5]>
<Function test_functions_coerce[backend4-method6-args6-kwargs6]>
<Function test_functions_coerce[backend4-method7-args7-kwargs7]>
<Function test_functions_coerce[backend4-method8-args8-kwargs8]>
<Function test_functions_coerce[backend4-method9-args9-kwargs9]>
<Function test_functions_coerce[backend4-method10-args10-kwargs10]>
<Function test_functions_coerce[backend4-method11-args11-kwargs11]>
<Function test_functions_coerce[backend4-method12-args12-kwargs12]>
<Function test_functions_coerce[backend4-method13-args13-kwargs13]>
<Function test_functions_coerce[backend4-method14-args14-kwargs14]>
<Function test_functions_coerce[backend4-method15-args15-kwargs15]>
<Function test_functions_coerce[backend4-method16-args16-kwargs16]>
<Function test_functions_coerce[backend4-method17-args17-kwargs17]>
<Function test_functions_coerce[backend4-method18-args18-kwargs18]>
<Function test_functions_coerce[backend4-method19-args19-kwargs19]>
<Function test_functions_coerce[backend4-method20-args20-kwargs20]>
<Function test_functions_coerce[backend4-method21-args21-kwargs21]>
<Function test_functions_coerce[backend4-method22-args22-kwargs22]>
<Function test_functions_coerce[backend4-method23-args23-kwargs23]>
<Function test_functions_coerce[backend4-method24-args24-kwargs24]>
<Function test_functions_coerce[backend4-method25-args25-kwargs25]>
<Function test_functions_coerce[backend4-method26-args26-kwargs26]>
<Function test_functions_coerce[backend4-method27-args27-kwargs27]>
<Function test_multiple_output[backend4-method0-args0-kwargs0]>
---------------- generated xml file: /Users/hameerabbasi/Quansight/unumpy/junit/test-results.xml ----------------
---------- coverage: platform darwin, python 3.7.3-final-0 -----------
Name Stmts Miss Branch BrPart Cover
----------------------------------------------------------------------------------------------------
/Users/hameerabbasi/Quansight/uarray/uarray/__init__.py 4 0 0 0 100%
/Users/hameerabbasi/Quansight/uarray/uarray/_backend.py 91 36 14 0 58%
/Users/hameerabbasi/Quansight/uarray/uarray/_version.py 278 154 144 22 36%
/Users/hameerabbasi/Quansight/uarray/uarray/tests/__init__.py 0 0 0 0 100%
/Users/hameerabbasi/Quansight/uarray/uarray/tests/test_uarray.py 91 91 38 0 0%
----------------------------------------------------------------------------------------------------
TOTAL 464 281 196 22 33%
Coverage HTML written to dir htmlcov
Coverage XML written to file coverage.xml
========================================= no tests ran in 1.37 seconds ==========================================
Same issue for me, just a bit different error:
python /Users/sisuser/.vscode/extensions/ms-python.python-2019.8.29288/pythonFiles/testing_tools/run_adapter.py discover pytest -- -s --cache-clear --reuse-db
Test Discovery failed:
Error: ============================= test session starts ==============================
platform darwin -- Python 2.7.16, pytest-4.6.5, py-1.5.4, pluggy-0.12.0 -- /
...
INTERNALERROR> File "/Users/sisuser/.vscode/extensions/ms-python.python-2019.8.29288/pythonFiles/testing_tools/adapter/pytest/_discovery.py", line 94, in pytest_collection_finish
INTERNALERROR> test, parents = parse_item(item, self.NORMCASE, self.PATHSEP)
INTERNALERROR> File "/Users/sisuser/.vscode/extensions/ms-python.python-2019.8.29288/pythonFiles/testing_tools/adapter/pytest/_pytest_item.py", line 156, in parse_item
INTERNALERROR> if not fspath.endswith(relfile[1:]):
INTERNALERROR> TypeError: 'NoneType' object has no attribute '__getitem__'
======================== no tests ran in 10.97 seconds =========================
Traceback (most recent call last):
File "/Users/sisuser/.vscode/extensions/ms-python.python-2019.8.29288/pythonFiles/testing_tools/run_adapter.py", line 18, in <module>
main(tool, cmd, subargs, toolargs)
File "/Users/sisuser/.vscode/extensions/ms-python.python-2019.8.29288/pythonFiles/testing_tools/adapter/__main__.py", line 90, in main
parents, result = run(toolargs, **subargs)
File "/Users/sisuser/.vscode/extensions/ms-python.python-2019.8.29288/pythonFiles/testing_tools/adapter/pytest/_discovery.py", line 36, in discover
raise Exception('pytest discovery failed (exit code {})'.format(ec))
Exception: pytest discovery failed (exit code 3)
@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:
============================= test session starts ==============================
platform linux -- Python 3.6.7, pytest-4.4.1, py-1.8.0, pluggy-0.9.0
rootdir: /home/username/path/workspaceroot/tests
collected 92 items
<Package /home/username/path/workspaceroot/tests/models>
<Module test_foo.py>
<Function test_bar>
...
========================= no tests ran in 0.13 seconds =========================
Test Discovery failed:
TypeError: Cannot read property 'uri' of undefined
Same problem, after trying different versions of Python Extension finally discovered with Python 2019.2.5558
Logs when failing:
============================= test session starts ============================== platform linux -- Python 3.6.7, pytest-4.4.1, py-1.8.0, pluggy-0.9.0 rootdir: /home/username/path/workspaceroot/tests collected 92 items <Package /home/username/path/workspaceroot/tests/models> <Module test_foo.py> <Function test_bar> ... ========================= no tests ran in 0.13 seconds ========================= Test Discovery failed: TypeError: Cannot read property 'uri' of undefined
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
Same problem, after trying different versions of Python Extension finally discovered with Python 2019.2.5558 Logs when failing:
============================= test session starts ============================== platform linux -- Python 3.6.7, pytest-4.4.1, py-1.8.0, pluggy-0.9.0 rootdir: /home/username/path/workspaceroot/tests collected 92 items <Package /home/username/path/workspaceroot/tests/models> <Module test_foo.py> <Function test_bar> ... ========================= no tests ran in 0.13 seconds ========================= Test Discovery failed: TypeError: Cannot read property 'uri' of undefined
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. It's weird that now I'm seeing again the "Discovery failed" error, but when I click the "Run All Tests" or "Debug All Tests" icons of upper left corner (in "Test" vertical tab) they work. However I can't see the options of run | debug above each test, neither see the tests tree in "Test" vertical tab
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.
python /home/jetxeberria/.vscode/extensions/ms-python.python-2019.8.30787/pythonFiles/testing_tools/run_adapter.py discover pytest -- -s .
Test Discovery failed:
TypeError: Cannot read property 'uri' of undefined
============================= test session starts ==============================
platform linux -- Python 3.7.3, pytest-5.0.1, py-1.8.0, pluggy-0.12.0
rootdir: /media/jetxeberria/data/data/documents/projects/ppmatic/astronest
plugins: html-1.20.0, metadata-1.8.0
collected 15 items
test_config.py .... [ 26%]
test_movement.py . [ 33%]
test_parser.py .......... [100%]
=============================== warnings summary ===============================
/home/jetxeberria/documents/programs/anaconda/anaconda3/envs/astronest/lib/python3.7/site-packages/pike/loader.py:3
/home/jetxeberria/documents/programs/anaconda/anaconda3/envs/astronest/lib/python3.7/site-packages/pike/loader.py:3: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
import imp
-- Docs: https://docs.pytest.org/en/latest/warnings.html
-------------- generated xml file: /tmp/tmp-1564HZCZ7m2Dfw6g.xml ---------------
==================== 15 passed, 1 warnings in 0.37 seconds =====================
Also, when executing View > Command Palette > Python: Discover Tests this is the output of "Python Test Log":
python /home/jetxeberria/.vscode/extensions/ms-python.python-2019.8.30787/pythonFiles/testing_tools/run_adapter.py discover pytest -- -s --cache-clear .
Test Discovery failed:
TypeError: Cannot read property 'uri' of undefined
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 https://github.com/microsoft/vscode-python/issues/5458#issuecomment-515114391
I have the following options configured in setup.cfg
:
[tool:pytest]
addopts = --cov=src --strict-markers --gherkin-terminal-reporter-expanded --flake8 -v
Turns out that --flake8
was the option causing the problem. If I remove --flake8
, VSCode python succeeds in test discovery. Apologies, I have not dug further than this level, but I can supply more info if required.
Versions:
pytest 5.0.1
pytest-bdd 3.1.1
pytest-cov 2.7.1
pytest-flake8 1.0.4
flake8 3.7.8
Invoking the whole command succeeds in terminal, of course:
pytest --cov=src --strict-markers --gherkin-terminal-reporter-expanded -v
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
)