python.languageServer setting: PylanceTest are run after >Python: Run All Tests command
There is an error when running the tests.
Command 'Python: Run All Tests' resulted in an error (Cannot read property 'testsuites' of null)
Output: c:UsersVaust XIIIAppDataLocalProgramsPythonPython37python.exe: can't open file '"c:/Users/Vaust XIII/.vscode/extensions/ms-python.python-2020.9.111407/pythonFiles/pyvsc-run-isolated.py"': [Errno 22] Invalid argument
Error: TypeError: Cannot read property 'testsuites' of null
Test have been running fine, then I added a new one and started getting this error. I tried deleting the new test, but it didn't help, the error is still there
hello.py
def hello():
return "Hello"
hello_test.py
from hello import *
def test_hello():
assert hello() == "Hello"
The >Python: Debug All Tests command works fine. Tests are run, I can debug them, message "x passed in y" is printed to Debug Console
Python in the Output panel (View→Output, change the drop-down the upper-right of the Output panel to Python)
> ~\AppData\Local\Programs\Python\Python37\python.exe "c:/Users/Vaust XIII/.vscode/extensions/ms-python.python-2020.9.111407/pythonFiles/pyvsc-run-isolated.py" pytest --override-ini junit_family=xunit1 --rootdir e:\python\foo --junit-xml=C:\Users\VAUSTX~1\AppData\Local\Temp\tmp-2288ORjzo6SAoZsg.xml .
cwd: e:\python\foo
> ~\AppData\Local\Programs\Python\Python37\python.exe "c:/Users/Vaust XIII/.vscode/extensions/ms-python.python-2020.9.111407/pythonFiles/pyvsc-run-isolated.py" pytest --override-ini junit_family=xunit1 --rootdir e:\python\foo --junit-xml=C:\Users\VAUSTX~1\AppData\Local\Temp\tmp-2288ORjzo6SAoZsg.xml .
cwd: e:\python\foo
This is fixed by https://github.com/microsoft/vscode-python/pull/14108
Hi! I'm running into the same problem, with a pyenv and poetry virtual environments. I can debug tests but running them from the GUI produces this error. How is #14108 fixing this? I don't understand.
Update: I can run tests only if I do pip install ., using -e alone is not enough. With poetry, I can't find a way to obtain this result.
My setup:
$code --version
1.51.0
fcac248b077b55bae4ba5bab613fd6e9156c2f0c
x64
python.languageServer setting: PylanceCan we reopen this issue?
The issue here was that the JSON returned was either empty or not parse-able. TypeError: Cannot read property 'testsuites' of null is a side effect of that. This particular issue was where we we quoting the script name twice, which caused python to treat it differently (as relative path), than when it is quoted once.
Also, test discovery issues with editable installs (pip install . -e) are is due to this bug #14570.
If test discovery is not working, try running the command it shows there in the test log to see if the JSON generated is parse able. If you are not able to see where the command is. Please file a separate bug.
@diegoquintanav I have run into the same problem:
Exception: pytest discovery failed (exit code 2)
python /home/jfn/.vscode/extensions/ms-python.python-2020.10.332292344/pythonFiles/testing_tools/run_adapter.py discover pytest -- --rootdir /home/jfn/source/github.com/prometheus-adaptive-cards -s tests
python /home/jfn/.vscode/extensions/ms-python.python-2020.10.332292344/pythonFiles/testing_tools/run_adapter.py discover pytest -- --rootdir /home/jfn/source/github.com/prometheus-adaptive-cards -s --cache-clear tests
python /home/jfn/.vscode/extensions/ms-python.python-2020.10.332292344/pythonFiles/testing_tools/run_adapter.py discover pytest -- --rootdir /home/jfn/source/github.com/prometheus-adaptive-cards -s --cache-clear tests
python /home/jfn/.vscode/extensions/ms-python.python-2020.10.332292344/pythonFiles/testing_tools/run_adapter.py discover pytest -- --rootdir /home/jfn/source/github.com/prometheus-adaptive-cards -s --cache-clear tests
python /home/jfn/.vscode/extensions/ms-python.python-2020.10.332292344/pythonFiles/testing_tools/run_adapter.py discover pytest -- --rootdir /home/jfn/source/github.com/prometheus-adaptive-cards -s --cache-clear tests
python /home/jfn/.vscode/extensions/ms-python.python-2020.10.332292344/pythonFiles/testing_tools/run_adapter.py discover pytest -- --rootdir /home/jfn/source/github.com/prometheus-adaptive-cards -s --cache-clear tests
python /home/jfn/.vscode/extensions/ms-python.python-2020.10.332292344/pythonFiles/testing_tools/run_adapter.py discover pytest -- --rootdir /home/jfn/source/github.com/prometheus-adaptive-cards -s --cache-clear tests
python /home/jfn/.vscode/extensions/ms-python.python-2020.10.332292344/pythonFiles/testing_tools/run_adapter.py discover pytest -- --rootdir /home/jfn/source/github.com/prometheus-adaptive-cards -s --cache-clear tests
ImportError while loading conftest '/home/jfn/source/github.com/prometheus-adaptive-cards/tests/conftest.py'.
tests/conftest.py:8: in <module>
from prometheus_adaptive_cards.config.logger import setup_logging
E ModuleNotFoundError: No module named 'prometheus_adaptive_cards'
Error: TypeError: Cannot read property 'testsuites' of null
The alternative test suite "Test explorer" works fine btw
@trallnag Yes, following a lead from the comment @karthiknadig gave, I found this issue ->https://github.com/microsoft/vscode-python/issues/14579#issuecomment-719643722
At the moment, using an older version of the extension solved my problem.