vscode-python: Error when running tests: Cannot read property 'testsuites' of null
Environment data
- VS Code version: 1.49.2 (user setup)
- Extension version (available under the Extensions sidebar): v2020.9.111407
- OS and version: Windows_NT x64 10.0.18363
- Python version (& distribution if applicable, e.g. Anaconda): 3.7.9 64-bit
- Type of virtual environment used (N/A | venv | virtualenv | conda | …): N/A
- Relevant/affected Python packages and their versions: pytest==6.0.2
- Value of the
python.languageServer
setting: Pylance
Expected behaviour
Test are run after >Python: Run All Tests command
Actual behaviour
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:\Users\Vaust XIII\AppData\Local\Programs\Python\Python37\python.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
Steps to reproduce:
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"
Additional info
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
Logs
Output for 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
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 15 (3 by maintainers)
Commits related to this issue
- https://github.com/microsoft/vscode-python/issues/14107 — committed to permitio/opal by orweis 3 years ago
I have an
__init__.py
in my tests folder and I am still getting this issue. Downgraded to2020.9.114305
per https://github.com/microsoft/vscode-python/issues/14579 and still had the issue.At this point I have given up and I am just running my tests using
pytest
in the Terminal :pAdding an
__init__.py
file inside my tests folder is solving the issue for me currently on Version: 1.52.1 for MacOS -> https://github.com/microsoft/vscode-python/issues/14579#issuecomment-725837711Having trouble with multiple tests from the VSCode UI. Is there a fix or workaround available yet?
Error: TypeError: Cannot read property ‘testsuites’ of null
Python
3.9.4 (tags/v3.9.4:1f2e308, Apr 6 2021, 13:40:21) [MSC v.1928 64 bit (AMD64)]
Package Version
atomicwrites 1.4.0 attrs 20.3.0 colorama 0.4.4 iniconfig 1.1.1 numpy 1.20.2 packaging 20.9 pandas 1.2.4 pip 21.1 pluggy 0.13.1 py 1.10.0 pyparsing 2.4.7 pytest 6.2.3 python-dateutil 2.8.1 pytz 2021.1 pywin32 300 setuptools 49.2.1 six 1.15.0 toml 0.10.2
VSCode
Version: 1.55.2 (user setup) Commit: 3c4e3df9e89829dce27b7b5c24508306b151f30d Date: 2021-04-13T09:35:57.887Z Electron: 11.3.0 Chrome: 87.0.4280.141 Node.js: 12.18.3 V8: 8.7.220.31-electron.0 OS: Windows_NT x64 10.0.17763
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:
python.languageServer
setting: PylanceCan we reopen this issue?
I’m also having the same issue when debugging individual tests.
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.
This fixed the issue for me on Windows 10 WSL
@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.