Skip to content
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

Error while running tests: TypeError: Cannot read property 'testsuites' of null #18407

Closed
wkerzendorf opened this issue Feb 1, 2022 · 19 comments
Assignees
Labels
area-testing bug Issue identified by VS Code Team member as probable bug info-needed Issue requires more information from poster

Comments

@wkerzendorf
Copy link

wkerzendorf commented Feb 1, 2022

Issue Type: Bug

Behaviour

I've read through the various issues but am seeing the given problem again that when looking at the consoles - the discovery works Running test with arguments: --rootdir /Users/wkerzend/python/tardis --override-ini junit_family=xunit1 --junit-xml=/var/folders/d8/0jgrxkjs4yj6qpzvv22rdtsr0000gn/T/tmp-65044gldRayuo7omi.xml --tardis-refdata=/Users/wkerzend/python/tardis-refdata
but then

Run completed, parsing output
Error while running tests: tardis
TypeError: Cannot read property 'testsuites' of null

Expected vs. Actual Behaviour

I'm trying to get the xml files to look at them with an editor.

Steps to reproduce:

Getting tests setup for the open source project github.com/tardis-sn/tardis

Diagnostic data

  • Python version (& distribution if applicable, e.g. Anaconda): 3.7.12
  • Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): Conda
  • Value of the python.languageServer setting: Pylance
User Settings


defaultLS: {"defaultLSType":"Pylance"}

downloadLanguageServer: true

envFile: "<placeholder>"

venvPath: "<placeholder>"

venvFolders: "<placeholder>"

condaPath: "<placeholder>"

pipenvPath: "<placeholder>"

poetryPath: "<placeholder>"

languageServer: "Pylance"

linting
• enabled: true
• cwd: "<placeholder>"
• Flake8Args: "<placeholder>"
• flake8Enabled: false
• flake8Path: "<placeholder>"
• lintOnSave: true
• banditArgs: "<placeholder>"
• banditEnabled: false
• banditPath: "<placeholder>"
• mypyArgs: "<placeholder>"
• mypyEnabled: false
• mypyPath: "<placeholder>"
• pycodestyleArgs: "<placeholder>"
• pycodestyleEnabled: false
• pycodestylePath: "<placeholder>"
• prospectorArgs: "<placeholder>"
• prospectorEnabled: false
• prospectorPath: "<placeholder>"
• pydocstyleArgs: "<placeholder>"
• pydocstyleEnabled: false
• pydocstylePath: "<placeholder>"
• pylamaArgs: "<placeholder>"
• pylamaEnabled: false
• pylamaPath: "<placeholder>"
• pylintArgs: "<placeholder>"
• pylintPath: "<placeholder>"

sortImports
• args: "<placeholder>"
• path: "<placeholder>"

formatting
• autopep8Args: "<placeholder>"
• autopep8Path: "<placeholder>"
• provider: "black"
• blackArgs: "<placeholder>"
• blackPath: "<placeholder>"
• yapfArgs: "<placeholder>"
• yapfPath: "<placeholder>"

testing
• cwd: "<placeholder>"
• debugPort: 3000
• nosetestArgs: "<placeholder>"
• nosetestsEnabled: undefined
• nosetestPath: "<placeholder>"
• promptToConfigure: true
• pytestArgs: "<placeholder>"
• pytestEnabled: true
• pytestPath: "<placeholder>"
• unittestArgs: "<placeholder>"
• unittestEnabled: false
• autoTestDiscoverOnSaveEnabled: true

terminal
• activateEnvironment: true
• executeInFileDir: "<placeholder>"
• launchArgs: "<placeholder>"

experiments
• enabled: true
• optInto: []
• optOutFrom: []

insidersChannel: "off"

tensorBoard
• logDirectory: "<placeholder>"

Extension version: 2021.12.1559732655
VS Code version: Code 1.63.2 (899d46d82c4c95423fb7e10e68eba52050e30ba3, 2021-12-15T09:37:28.172Z)
OS version: Darwin x64 20.6.0
Restricted Mode: No

System Info
Item Value
CPUs Intel(R) Core(TM) i9-8950HK CPU @ 2.90GHz (12 x 2900)
GPU Status 2d_canvas: enabled
gpu_compositing: enabled
metal: disabled_off
multiple_raster_threads: enabled_on
oop_rasterization: enabled
opengl: enabled_on
rasterization: enabled
skia_renderer: disabled_off_ok
video_decode: enabled
webgl: enabled
webgl2: enabled
Load (avg) 7, 6, 6
Memory (System) 32.00GB (1.16GB free)
Process Argv --crash-reporter-id 2477d69f-b676-416f-92af-923d0fb7d793
Screen Reader no
VM 0%
A/B Experiments
vsliv368cf:30146710
vsreu685:30147344
python383:30185418
vspor879:30202332
vspor708:30202333
vspor363:30204092
pythonvspyl392:30425749
pythontb:30283811
pythonptprofiler:30281270
vshan820:30294714
vstes263cf:30335440
vscorecescf:30429732
pythondataviewer:30285071
vscod805:30301674
pythonvspyt200:30340761
binariesv615:30325510
bridge0708:30335490
bridge0723:30353136
vsaa593cf:30376535
vsc1dst:30428979
pythonvs932:30410667
vscop804cf:30404767
vscop453:30404998
vsrem710cf:30416617

@github-actions github-actions bot added the triage-needed Needs assignment to the proper sub-team label Feb 1, 2022
@wkerzendorf
Copy link
Author

wkerzendorf commented Feb 1, 2022

In output python - I see that it is calling ~/miniconda/envs/tardis-devel/bin/python -m pytest --rootdir ~/python/tardis --override-ini junit_family=xunit1 --junit-xml=/var/folders/d8/0jgrxkjs4yj6qpzvv22rdtsr0000gn/T/tmp-68113nKam1JOrYDMz.xml --tardis-refdata=/Users/wkerzend/python/tardis-refdata which is missing what folder it should run on

~/miniconda/envs/tardis-devel/bin/python -m pytest --rootdir ~/python/tardis --override-ini junit_family=xunit1 --junit-xml=/var/folders/d8/0jgrxkjs4yj6qpzvv22rdtsr0000gn/T/tmp-68113nKam1JOrYDMz.xml --tardis-refdata=/Users/wkerzend/python/tardis-refdata tardis works when running it in the terminal.

Ultimately - I don't quite understand why it's emitting the folder to search the tests in.

@wkerzendorf
Copy link
Author

tmp-69895toGxmaN6Q10d.xml.please_remove_extension.zip

^^ it has troubles with this XML file (actual XML file and not zip - just rename)

@karthiknadig karthiknadig added area-testing bug Issue identified by VS Code Team member as probable bug triage and removed triage-needed Needs assignment to the proper sub-team labels Feb 1, 2022
@kimadeline
Copy link

Hi @wkerzendorf, thank you for reaching out.

What is the content of your python.testing.pytestArgs workspace setting?

Run completed, parsing output
Error while running tests: tardis
TypeError: Cannot read property 'testsuites' of null

Where is that output from?

Do you also have a minimal example I could use to try and replicate the issue?

@kimadeline kimadeline added the info-needed Issue requires more information from poster label Feb 1, 2022
@wkerzendorf
Copy link
Author

@wkerzendorf
Copy link
Author

I also have some questions about the settings. There are user setting which are presumable stored somewhere in the home dir. Then there are workspace setting which are stored in the given file. Then there are folder settings for multiroot workspaces - I don't see where they are stored.

@wkerzendorf
Copy link
Author

@kimadeline

"python.testing.pytestArgs": [
			"--tardis-refdata=/Users/wkerzend/python/tardis-refdata",
			"--no-cov",
			"tardis"
		],
		"python.testing.pytestEnabled": true,
		"python.testing.cwd": "/Users/wkerzend/python/tardis",

@kimadeline
Copy link

Then there are folder settings for multiroot workspaces - I don't see where they are stored.

They are stored in the .vscode/settings.json for each folder.

If you don't have a minimal example I could use to try and replicate the issue, could you paste here the entirety of the output in the Python output when you try running the tests?

Thanks!

@wkerzendorf
Copy link
Author

We are the tardis code at github.com/tardis-sn/tardis. In there is a tardis_env3.yml that contains the environment (as a conda environment).

> ~/miniconda/envs/tardis-devel/bin/python -c "import sys;print(sys.executable)"
> conda info --json
> ". /Users/wkerzend/miniconda/bin/activate && conda activate tardis-devel && echo 'e8b39361-0157-4923-80e1-22d70d46dee6' && python /Users/wkerzend/.vscode/extensions/ms-python.python-2021.12.1559732655/pythonFiles/printEnvVariables.py"
> ". /Users/wkerzend/miniconda/bin/activate && conda activate starkit && echo 'e8b39361-0157-4923-80e1-22d70d46dee6' && python /Users/wkerzend/.vscode/extensions/ms-python.python-2021.12.1559732655/pythonFiles/printEnvVariables.py"
> ~/miniconda/envs/starkit/bin/python ~/.vscode/extensions/ms-python.python-2021.12.1559732655/pythonFiles/testing_tools/run_adapter.py discover pytest -- --rootdir ~/python/tardis -s --cache-clear --tardis-refdata=/Users/wkerzend/python/tardis-refdata --no-cov tardis
cwd: ~/python/tardis
> ~/miniconda/envs/tardis-devel/bin/python ~/.vscode/extensions/ms-python.python-2021.12.1559732655/pythonFiles/testing_tools/run_adapter.py discover pytest -- --rootdir ~/python/tardis -s --cache-clear --tardis-refdata=/Users/wkerzend/python/tardis-refdata --no-cov tardis
cwd: ~/python/tardis
[ERROR 2022-1-2 21:36:45.49]: Error discovering pytest tests:
 [SyntaxError: Unexpected end of JSON input
	at JSON.parse (<anonymous>)
	at a.runTestDiscovery (/Users/wkerzend/.vscode/extensions/ms-python.python-2021.12.1559732655/out/client/extension.js:74:83854)
	at runMicrotasks (<anonymous>)
	at processTicksAndRejections (internal/process/task_queues.js:93:5)
	at async Promise.all (index 0)
	at async E.refreshTestData (/Users/wkerzend/.vscode/extensions/ms-python.python-2021.12.1559732655/out/client/extension.js:74:95452)
	at async v.refreshTestDataInternal (/Users/wkerzend/.vscode/extensions/ms-python.python-2021.12.1559732655/out/client/extension.js:74:86846)
	at async Promise.all (index 1)
	at async v.resolveChildren (/Users/wkerzend/.vscode/extensions/ms-python.python-2021.12.1559732655/out/client/extension.js:74:88181)] {
  stdout: ''
}


@kimadeline
Copy link

What is shown in the terminal if you run ~/miniconda/envs/tardis-devel/bin/python ~/.vscode/extensions/ms-python.python-2021.12.1559732655/pythonFiles/testing_tools/run_adapter.py discover pytest -- --rootdir ~/python/tardis -s --cache-clear --tardis-refdata=/Users/wkerzend/python/tardis-refdata --no-cov tardis in the terminal?

@wkerzendorf
Copy link
Author

excerpt

widgets/tests/test_shell_info.py:88", "markers": [], "parentid": "./tardis/visualization/widgets/tests/test_shell_info.py::TestHDFShellInfo::test_level_count_data"}, {"id": "./tardis/visualization/widgets/tests/test_shell_info.py::TestShellInfoWidget::test_selection_on_shells_table", "name": "test_selection_on_shells_table", "source": "./tardis/visualization/widgets/tests/test_shell_info.py:146", "markers": [], "parentid": "./tardis/visualization/widgets/tests/test_shell_info.py::TestShellInfoWidget"}, {"id": "./tardis/visualization/widgets/tests/test_shell_info.py::TestShellInfoWidget::test_selection_on_element_count_table", "name": "test_selection_on_element_count_table", "source": "./tardis/visualization/widgets/tests/test_shell_info.py:174", "markers": [], "parentid": "./tardis/visualization/widgets/tests/test_shell_info.py::TestShellInfoWidget"}, {"id": "./tardis/visualization/widgets/tests/test_shell_info.py::TestShellInfoWidget::test_selection_on_ion_count_table", "name": "test_selection_on_ion_count_table", "source": "./tardis/visualization/widgets/tests/test_shell_info.py:197", "markers": [], "parentid": "./tardis/visualization/widgets/tests/test_shell_info.py::TestShellInfoWidget"}]}]

tmp.zip

I piped it into the tmp.zip (not a real zip 😉 )

@wkerzendorf
Copy link
Author

@kimadeline let me know if I can help more

@kimadeline
Copy link

I cloned the repos at https://github.com/tardis-sn/tardis and https://github.com/tardis-sn/tardis-refdata to try and pinpoint the issue.

I did not get the TypeError: Cannot read property 'testsuites' of null error you initially encountered, however the fact that the last tardis argument was being truncated was probably causing issues.

It is done on this line:

let testArgs = removePositionalFoldersAndFiles(options.args);

Where we remove certain types of arguments (you can see the function that does it here).

Long story short, if you update your code to use something like --dir=tardis instead of just tardis we won't truncate it, and treat it as an argument to forward to the testing script.

Let me know if this workaround works for now.

@wkerzendorf
Copy link
Author

I will work on this in the next days as I just migrated laptops and need to finish a proposal 😄

@wkerzendorf
Copy link
Author

[ERROR 2022-1-10 18:28:53.524]: Error discovering pytest tests:
 [r [Error]: ERROR: usage: run_adapter.py [options] [file_or_dir] [file_or_dir] [...]
run_adapter.py: error: unrecognized arguments: --tardis-refdata=/Users/wkerzend/python/tardis-refdata --dir=tardis
  inifile: /Users/wkerzend/python/tardis/setup.cfg
  rootdir: /Users/wkerzend/python/tardis

@kimadeline it doesn't like it for the run_adapter script

@wkerzendorf
Copy link
Author

seems to be a known problem : #11736

@kimadeline
Copy link

Hi there, sorry for the delay!

Is the --tardis-refdata argument still in python.testing.pytestArgs?

@wkerzendorf
Copy link
Author

uhm - haven't checked in a while.

@kimadeline
Copy link

Is the issue still happening? Or did you find a workaround?

@brettcannon
Copy link
Member

Because we have not heard back with the information we requested, we are closing this issue for now. If you are able to provide the info later on then we will be happy to re-open this issue to pick up where we left off.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 29, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-testing bug Issue identified by VS Code Team member as probable bug info-needed Issue requires more information from poster
Projects
None yet
Development

No branches or pull requests

4 participants