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.

Error when running tests: Cannot read property 'testsuites' of null

See original GitHub issue

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 (ViewOutput, 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

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:15 (3 by maintainers)

github_iconTop GitHub Comments

5reactions
sometimescaseycommented, Jun 23, 2021

I have an __init__.py in my tests folder and I am still getting this issue. Downgraded to 2020.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 :p

5reactions
ChrisCcommented, Jan 30, 2021

Adding 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-725837711

Read more comments on GitHub >

github_iconTop Results From Across the Web

VSCode + Pytest: "Error: TypeError: Cannot read property '$' of ...
I'm on Windows 10, Python 3.7.4, using latest version of VSCode. On first attempting to run the tests (using the latest version of...
Read more >
Runtime error when running tests: TypeError: Cannot read ...
How do you deal with Runtime error when running tests: TypeError: Cannot read properties of null (reading 'errorMessage') in your Power Apps ...
Read more >
Error trying to set up tests with Vitest. TypeError - Reddit
When I try to run my tests I get the following error: TypeError: Cannot read properties of null (reading 'useRef').
Read more >
Intermittent test suite failures, TypeError: Cannot read property ...
Here is an example of an error message: 05:34:45 INFO - Error: Not connected. ... Cannot read property 'deleteSession' of null → Intermittent...
Read more >
Jest error:- TypeError: Cannot read properties of null (reading ...
this.dispatchEvent(searchEvent); near the top of the unit test won't work. You need to dispatch the event from an element.
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