pytest runner fails to populate problems, throws TypeError
See original GitHub issueEnvironment data
- VS Code version: 1.42.0-insider (8d4cdbaa)
- Extension version (available under the Extensions sidebar): 2020.1.58038
- OS and version: Ubuntu 18.04
- Python version (& distribution if applicable, e.g. Anaconda): Python 3.6.9
- Type of virtual environment used (N/A | venv | virtualenv | conda | …): N/A
- Relevant/affected Python packages and their versions: pytest
- Jedi or Language Server? (i.e. what is
"python.jediEnabled"
set to; more info #3977): Language Server
Expected behaviour
Running pytest with a failing output should produce messages detailing the failure, via testMessageService.ts
, and populate the “problems” tab with the failing tests.
Actual behaviour
A message is displayed showing
The "path" argument must be of type string. Received type "undefined"
With the following stack trace
TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type undefined
at validateString (internal/validators.js:107)
at Object.isAbsolute (path.js:1027)
at f.isAbsolute [as getLocationStack] (/home/ubuntu/.vscode…ssageService.ts:111)
at processTicksAndRejections (internal/process/task_queues.js:89)
at f.locationStack [as getFilteredTestMessages] (/home/ubuntu/.vscode…essageService.ts:62)
at t.TestManager.messages [as runTestImpl] (/home/ubuntu/.vscode…g/pytest/main.ts:48)
Steps to reproduce:
[NOTE: Self-contained, minimal reproducing code samples are extremely helpful and will expedite addressing your issue]
- Checkout this minimal example project https://github.com/Arnatious/vscode-python-pytest-repro
- Change python interpreter if needed
- Discover and run tests.
Logs
Output for Python
in the Output
panel (View
→Output
, change the drop-down the upper-right of the Output
panel to Python
)
User belongs to experiment group 'AlwaysDisplayTestExplorer - control'
User belongs to experiment group 'ShowPlayIcon - start'
User belongs to experiment group 'ShowExtensionSurveyPrompt - enabled'
User belongs to experiment group 'DebugAdapterFactory - experiment'
User belongs to experiment group 'UseTerminalToGetActivatedEnvVars - control'
User belongs to experiment group 'WebHostNotebook - control'
> conda --version
> pyenv root
> python3.7 -c "import sys;print(sys.executable)"
> python3.6 -c "import sys;print(sys.executable)"
> python3 -c "import sys;print(sys.executable)"
> python2 -c "import sys;print(sys.executable)"
> python -c "import sys;print(sys.executable)"
> python -c "import sys;print(sys.executable)"
> conda info --json
Starting Microsoft Python language server.
> /usr/bin/python3 ~/.vscode-server-insiders/extensions/ms-python.python-2020.1.58038/pythonFiles/testing_tools/run_adapter.py discover pytest -- --rootdir ~/workspace/minimal_repro -s --cache-clear test
cwd: ~/workspace/minimal_repro
> /usr/bin/python3 ~/.vscode-server-insiders/extensions/ms-python.python-2020.1.58038/pythonFiles/testing_tools/run_adapter.py discover pytest -- --rootdir ~/workspace/minimal_repro -s --cache-clear test
cwd: ~/workspace/minimal_repro
> conda --version
> /usr/bin/python3 -m pytest --rootdir ~/workspace/minimal_repro --junitxml=/tmp/tmp-38321PLL2YDYzvzYH.xml test
cwd: ~/workspace/minimal_repro
> /usr/bin/python3 -m pytest --rootdir ~/workspace/minimal_repro --junitxml=/tmp/tmp-38321PLL2YDYzvzYH.xml test
cwd: ~/workspace/minimal_repro
Output from Console
under the Developer Tools
panel (toggle Developer Tools on under Help
; turn on source maps to make any tracebacks be useful by running Enable source map support for extension debugging
)
There was an error in running the tests.
onDidNotificationChange @ notificationsAlerts.ts:40
notificationsAlerts.ts:38 TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type undefined
at validateString (internal/validators.js:107)
at Object.isAbsolute (path.js:1027)
at f.isAbsolute [as getLocationStack] (/home/ubuntu/.vscode-server-insiders/extensions/ms-python.python-2020.1.58038/src/client/testing/pytest/services/testMessageService.ts:111)
at processTicksAndRejections (internal/process/task_queues.js:89)
at f.locationStack [as getFilteredTestMessages] (/home/ubuntu/.vscode-server-insiders/extensions/ms-python.python-2020.1.58038/src/client/testing/pytest/services/testMessageService.ts:62)
at t.TestManager.messages [as runTestImpl] (/home/ubuntu/.vscode-server-insiders/extensions/ms-python.python-2020.1.58038/src/client/testing/pytest/main.ts:48)
Additional info:
The directory structure is important to reproducing this bug, only when test and the module are in sibling directories does this error occur
Issue Analytics
- State:
- Created 4 years ago
- Reactions:5
- Comments:9 (3 by maintainers)
Top GitHub Comments
Can confirm this. When running pytest (5.4.1) with default settings I receive following deprecation warning
Setting
junit_family
manually toxunit2
generates the error - but only when some tests fail! Setting it toxunit1
and everything is fine.Since
xunit2
will be the new default this looks like it is only a temporary workaround and needs to be solved properly.I can reproduce the same error on windows with Python extension
2020.2.64397