microsoft / vscode-python

Python extension for Visual Studio Code
https://aka.ms/pvsc-marketplace
MIT License
4.29k stars 1.18k forks source link

Pytest node issue during test discovery #19334

Closed Mirandatz closed 2 years ago

Mirandatz commented 2 years ago

Issue Type: Bug

Behaviour

Expected vs. Actual

Expected: test discovery works. Actual: does not.

Steps to reproduce:

Click "Refresh tests" button.

Diagnostic data

Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

``` > /bin/python ~/.vscode-server/extensions/ms-python.python-2022.8.0/pythonFiles/testing_tools/run_adapter.py discover pytest -- --rootdir . -s --cache-clear gge cwd: . [ERROR 2022-5-20 14:2:2.230]: Error discovering pytest tests: [n [Error]: ============================= test session starts ============================== platform linux -- Python 3.10.4, pytest-7.1.2, pluggy-1.0.0 cachedir: /dev/shm/pytest_cache rootdir: /workspaces/gge, configfile: pyproject.toml plugins: hypothesis-6.46.11, typeguard-2.13.3, pspec-0.0.4, xdist-2.5.0, forked-1.4.0 The Python extension has run into an unexpected situation while processing a pytest node during test discovery. Please Please open an issue at: https://github.com/microsoft/vscode-python/issues and paste the following output there. nodeid: gge/tests/test_simplest.py::::test_halp kind: ('function', False) class: Function name: test_halp fspath: /workspaces/gge/gge/tests/test_simplest.py location: ('gge/tests/test_simplest.py', 0, 'test_halp') function: markers: [] user_properties: [] attrnames: ['_ALLOW_MARKERS', '__annotations__', '__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__slots__', '__str__', '__subclasshook__', '__weakref__', '_check_item_and_collector_diamond_inheritance', '_fixtureinfo', '_getobj', '_initrequest', '_nodeid', '_obj', '_prunetraceback', '_pyfuncitem', '_pytest_diamond_inheritance_warning_shown', '_report_sections', '_repr_failure_py', '_request', '_store', 'add_marker', 'add_report_section', 'addfinalizer', 'cls', 'config', 'extra_keyword_matches', 'fixturenames', 'from_parent', 'fspath', 'funcargs', 'function', 'get_closest_marker', 'getmodpath', 'getparent', 'ihook', 'instance', 'iter_markers', 'iter_markers_with_node', 'keywords', 'listchain', 'listextrakeywords', 'listnames', 'location', 'module', 'name', 'nextitem', 'nodeid', 'obj', 'originalname', 'own_markers', 'parent', 'path', 'reportinfo', 'repr_failure', 'runtest', 'session', 'setup', 'stash', 'teardown', 'user_properties', 'warn'] extra info: fullname: test_halp testfunc: .test_halp parameterized: traceback: File "/root/.vscode-server/extensions/ms-python.python-2022.8.0/pythonFiles/testing_tools/run_adapter.py", line 22, in main(tool, cmd, subargs, toolargs) File "/root/.vscode-server/extensions/ms-python.python-2022.8.0/pythonFiles/testing_tools/adapter/__main__.py", line 100, in main parents, result = run(toolargs, **subargs) File "/root/.vscode-server/extensions/ms-python.python-2022.8.0/pythonFiles/testing_tools/adapter/pytest/_discovery.py", line 30, in discover ec = _pytest_main(pytestargs, [_plugin]) File "/usr/local/lib/python3.10/site-packages/_pytest/config/__init__.py", line 164, in main ret: Union[ExitCode, int] = config.hook.pytest_cmdline_main( File "/usr/local/lib/python3.10/site-packages/pluggy/_hooks.py", line 265, in __call__ return self._hookexec(self.name, self.get_hookimpls(), kwargs, firstresult) File "/usr/local/lib/python3.10/site-packages/pluggy/_manager.py", line 80, in _hookexec return self._inner_hookexec(hook_name, methods, kwargs, firstresult) File "/usr/local/lib/python3.10/site-packages/pluggy/_callers.py", line 39, in _multicall res = hook_impl.function(*args) File "/usr/local/lib/python3.10/site-packages/_pytest/main.py", line 315, in pytest_cmdline_main return wrap_session(config, _main) File "/usr/local/lib/python3.10/site-packages/_pytest/main.py", line 268, in wrap_session session.exitstatus = doit(config, session) or 0 File "/usr/local/lib/python3.10/site-packages/_pytest/main.py", line 321, in _main config.hook.pytest_collection(session=session) File "/usr/local/lib/python3.10/site-packages/pluggy/_hooks.py", line 265, in __call__ return self._hookexec(self.name, self.get_hookimpls(), kwargs, firstresult) File "/usr/local/lib/python3.10/site-packages/pluggy/_manager.py", line 80, in _hookexec return self._inner_hookexec(hook_name, methods, kwargs, firstresult) File "/usr/local/lib/python3.10/site-packages/pluggy/_callers.py", line 39, in _multicall res = hook_impl.function(*args) File "/usr/local/lib/python3.10/site-packages/_pytest/main.py", line 332, in pytest_collection session.perform_collect() File "/usr/local/lib/python3.10/site-packages/_pytest/main.py", line 660, in perform_collect hook.pytest_collection_modifyitems( File "/usr/local/lib/python3.10/site-packages/pluggy/_hooks.py", line 265, in __call__ return self._hookexec(self.name, self.get_hookimpls(), kwargs, firstresult) File "/usr/local/lib/python3.10/site-packages/pluggy/_manager.py", line 80, in _hookexec return self._inner_hookexec(hook_name, methods, kwargs, firstresult) File "/usr/local/lib/python3.10/site-packages/pluggy/_callers.py", line 39, in _multicall res = hook_impl.function(*args) File "/root/.vscode-server/extensions/ms-python.python-2022.8.0/pythonFiles/testing_tools/adapter/pytest/_discovery.py", line 92, in pytest_collection_modifyitems test, parents = self.parse_item(item) File "/root/.vscode-server/extensions/ms-python.python-2022.8.0/pythonFiles/testing_tools/adapter/pytest/_discovery.py", line 77, in parse_item return parse_item(item) File "/root/.vscode-server/extensions/ms-python.python-2022.8.0/pythonFiles/testing_tools/adapter/pytest/_pytest_item.py", line 184, in parse_item raise should_never_reach_here( File "/root/.vscode-server/extensions/ms-python.python-2022.8.0/pythonFiles/testing_tools/adapter/pytest/_pytest_item.py", line 132, in should_never_reach_here traceback.print_stack() collected 1 item The Python extension has run into an unexpected situation while processing a pytest node during test discovery. Please Please open an issue at: https://github.com/microsoft/vscode-python/issues and paste the following output there. nodeid: gge/tests/test_simplest.py::::test_halp kind: ('function', False) class: Function name: test_halp fspath: /workspaces/gge/gge/tests/test_simplest.py location: ('gge/tests/test_simplest.py', 0, 'test_halp') function: markers: [] user_properties: [] attrnames: ['_ALLOW_MARKERS', '__annotations__', '__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__slots__', '__str__', '__subclasshook__', '__weakref__', '_check_item_and_collector_diamond_inheritance', '_fixtureinfo', '_getobj', '_initrequest', '_nodeid', '_obj', '_prunetraceback', '_pyfuncitem', '_pytest_diamond_inheritance_warning_shown', '_report_sections', '_repr_failure_py', '_request', '_store', 'add_marker', 'add_report_section', 'addfinalizer', 'cls', 'config', 'extra_keyword_matches', 'fixturenames', 'from_parent', 'fspath', 'funcargs', 'function', 'get_closest_marker', 'getmodpath', 'getparent', 'ihook', 'instance', 'iter_markers', 'iter_markers_with_node', 'keywords', 'listchain', 'listextrakeywords', 'listnames', 'location', 'module', 'name', 'nextitem', 'nodeid', 'obj', 'originalname', 'own_markers', 'parent', 'path', 'reportinfo', 'repr_failure', 'runtest', 'session', 'setup', 'stash', 'teardown', 'user_properties', 'warn'] extra info: fullname: test_halp testfunc: .test_halp parameterized: traceback: File "/root/.vscode-server/extensions/ms-python.python-2022.8.0/pythonFiles/testing_tools/run_adapter.py", line 22, in main(tool, cmd, subargs, toolargs) File "/root/.vscode-server/extensions/ms-python.python-2022.8.0/pythonFiles/testing_tools/adapter/__main__.py", line 100, in main parents, result = run(toolargs, **subargs) File "/root/.vscode-server/extensions/ms-python.python-2022.8.0/pythonFiles/testing_tools/adapter/pytest/_discovery.py", line 30, in discover ec = _pytest_main(pytestargs, [_plugin]) File "/usr/local/lib/python3.10/site-packages/_pytest/config/__init__.py", line 164, in main ret: Union[ExitCode, int] = config.hook.pytest_cmdline_main( File "/usr/local/lib/python3.10/site-packages/pluggy/_hooks.py", line 265, in __call__ return self._hookexec(self.name, self.get_hookimpls(), kwargs, firstresult) File "/usr/local/lib/python3.10/site-packages/pluggy/_manager.py", line 80, in _hookexec return self._inner_hookexec(hook_name, methods, kwargs, firstresult) File "/usr/local/lib/python3.10/site-packages/pluggy/_callers.py", line 39, in _multicall res = hook_impl.function(*args) File "/usr/local/lib/python3.10/site-packages/_pytest/main.py", line 315, in pytest_cmdline_main return wrap_session(config, _main) File "/usr/local/lib/python3.10/site-packages/_pytest/main.py", line 268, in wrap_session session.exitstatus = doit(config, session) or 0 File "/usr/local/lib/python3.10/site-packages/_pytest/main.py", line 321, in _main config.hook.pytest_collection(session=session) File "/usr/local/lib/python3.10/site-packages/pluggy/_hooks.py", line 265, in __call__ return self._hookexec(self.name, self.get_hookimpls(), kwargs, firstresult) File "/usr/local/lib/python3.10/site-packages/pluggy/_manager.py", line 80, in _hookexec return self._inner_hookexec(hook_name, methods, kwargs, firstresult) File "/usr/local/lib/python3.10/site-packages/pluggy/_callers.py", line 39, in _multicall res = hook_impl.function(*args) File "/usr/local/lib/python3.10/site-packages/_pytest/main.py", line 332, in pytest_collection session.perform_collect() File "/usr/local/lib/python3.10/site-packages/_pytest/main.py", line 664, in perform_collect hook.pytest_collection_finish(session=self) File "/usr/local/lib/python3.10/site-packages/pluggy/_hooks.py", line 265, in __call__ return self._hookexec(self.name, self.get_hookimpls(), kwargs, firstresult) File "/usr/local/lib/python3.10/site-packages/pluggy/_manager.py", line 80, in _hookexec return self._inner_hookexec(hook_name, methods, kwargs, firstresult) File "/usr/local/lib/python3.10/site-packages/pluggy/_callers.py", line 39, in _multicall res = hook_impl.function(*args) File "/root/.vscode-server/extensions/ms-python.python-2022.8.0/pythonFiles/testing_tools/adapter/pytest/_discovery.py", line 107, in pytest_collection_finish test, parents = self.parse_item(item) File "/root/.vscode-server/extensions/ms-python.python-2022.8.0/pythonFiles/testing_tools/adapter/pytest/_discovery.py", line 77, in parse_item return parse_item(item) File "/root/.vscode-server/extensions/ms-python.python-2022.8.0/pythonFiles/testing_tools/adapter/pytest/_pytest_item.py", line 184, in parse_item raise should_never_reach_here( File "/root/.vscode-server/extensions/ms-python.python-2022.8.0/pythonFiles/testing_tools/adapter/pytest/_pytest_item.py", line 132, in should_never_reach_here traceback.print_stack() INTERNALERROR> Traceback (most recent call last): INTERNALERROR> File "/usr/local/lib/python3.10/site-packages/_pytest/main.py", line 660, in perform_collect INTERNALERROR> hook.pytest_collection_modifyitems( INTERNALERROR> File "/usr/local/lib/python3.10/site-packages/pluggy/_hooks.py", line 265, in __call__ INTERNALERROR> return self._hookexec(self.name, self.get_hookimpls(), kwargs, firstresult) INTERNALERROR> File "/usr/local/lib/python3.10/site-packages/pluggy/_manager.py", line 80, in _hookexec INTERNALERROR> return self._inner_hookexec(hook_name, methods, kwargs, firstresult) INTERNALERROR> File "/usr/local/lib/python3.10/site-packages/pluggy/_callers.py", line 60, in _multicall INTERNALERROR> return outcome.get_result() INTERNALERROR> File "/usr/local/lib/python3.10/site-packages/pluggy/_result.py", line 60, in get_result INTERNALERROR> raise ex[1].with_traceback(ex[2]) INTERNALERROR> File "/usr/local/lib/python3.10/site-packages/pluggy/_callers.py", line 39, in _multicall INTERNALERROR> res = hook_impl.function(*args) INTERNALERROR> File "/root/.vscode-server/extensions/ms-python.python-2022.8.0/pythonFiles/testing_tools/adapter/pytest/_discovery.py", line 92, in pytest_collection_modifyitems INTERNALERROR> test, parents = self.parse_item(item) INTERNALERROR> File "/root/.vscode-server/extensions/ms-python.python-2022.8.0/pythonFiles/testing_tools/adapter/pytest/_discovery.py", line 77, in parse_item INTERNALERROR> return parse_item(item) INTERNALERROR> File "/root/.vscode-server/extensions/ms-python.python-2022.8.0/pythonFiles/testing_tools/adapter/pytest/_pytest_item.py", line 184, in parse_item INTERNALERROR> raise should_never_reach_here( INTERNALERROR> NotImplementedError: Unexpected pytest node (see printed output). INTERNALERROR> INTERNALERROR> During handling of the above exception, another exception occurred: INTERNALERROR> INTERNALERROR> Traceback (most recent call last): INTERNALERROR> File "/usr/local/lib/python3.10/site-packages/_pytest/main.py", line 268, in wrap_session INTERNALERROR> session.exitstatus = doit(config, session) or 0 INTERNALERROR> File "/usr/local/lib/python3.10/site-packages/_pytest/main.py", line 321, in _main INTERNALERROR> config.hook.pytest_collection(session=session) INTERNALERROR> File "/usr/local/lib/python3.10/site-packages/pluggy/_hooks.py", line 265, in __call__ INTERNALERROR> return self._hookexec(self.name, self.get_hookimpls(), kwargs, firstresult) INTERNALERROR> File "/usr/local/lib/python3.10/site-packages/pluggy/_manager.py", line 80, in _hookexec INTERNALERROR> return self._inner_hookexec(hook_name, methods, kwargs, firstresult) INTERNALERROR> File "/usr/local/lib/python3.10/site-packages/pluggy/_callers.py", line 60, in _multicall INTERNALERROR> return outcome.get_result() INTERNALERROR> File "/usr/local/lib/python3.10/site-packages/pluggy/_result.py", line 60, in get_result INTERNALERROR> raise ex[1].with_traceback(ex[2]) INTERNALERROR> File "/usr/local/lib/python3.10/site-packages/pluggy/_callers.py", line 39, in _multicall INTERNALERROR> res = hook_impl.function(*args) INTERNALERROR> File "/usr/local/lib/python3.10/site-packages/_pytest/main.py", line 332, in pytest_collection INTERNALERROR> session.perform_collect() INTERNALERROR> File "/usr/local/lib/python3.10/site-packages/_pytest/main.py", line 664, in perform_collect INTERNALERROR> hook.pytest_collection_finish(session=self) INTERNALERROR> File "/usr/local/lib/python3.10/site-packages/pluggy/_hooks.py", line 265, in __call__ INTERNALERROR> return self._hookexec(self.name, self.get_hookimpls(), kwargs, firstresult) INTERNALERROR> File "/usr/local/lib/python3.10/site-packages/pluggy/_manager.py", line 80, in _hookexec INTERNALERROR> return self._inner_hookexec(hook_name, methods, kwargs, firstresult) INTERNALERROR> File "/usr/local/lib/python3.10/site-packages/pluggy/_callers.py", line 60, in _multicall INTERNALERROR> return outcome.get_result() INTERNALERROR> File "/usr/local/lib/python3.10/site-packages/pluggy/_result.py", line 60, in get_result INTERNALERROR> raise ex[1].with_traceback(ex[2]) INTERNALERROR> File "/usr/local/lib/python3.10/site-packages/pluggy/_callers.py", line 39, in _multicall INTERNALERROR> res = hook_impl.function(*args) INTERNALERROR> File "/root/.vscode-server/extensions/ms-python.python-2022.8.0/pythonFiles/testing_tools/adapter/pytest/_discovery.py", line 107, in pytest_collection_finish INTERNALERROR> test, parents = self.parse_item(item) INTERNALERROR> File "/root/.vscode-server/extensions/ms-python.python-2022.8.0/pythonFiles/testing_tools/adapter/pytest/_discovery.py", line 77, in parse_item INTERNALERROR> return parse_item(item) INTERNALERROR> File "/root/.vscode-server/extensions/ms-python.python-2022.8.0/pythonFiles/testing_tools/adapter/pytest/_pytest_item.py", line 184, in parse_item INTERNALERROR> raise should_never_reach_here( INTERNALERROR> NotImplementedError: Unexpected pytest node (see printed output). ========================== 1 test collected in 0.02s =========================== Traceback (most recent call last): File "/root/.vscode-server/extensions/ms-python.python-2022.8.0/pythonFiles/testing_tools/run_adapter.py", line 22, in main(tool, cmd, subargs, toolargs) File "/root/.vscode-server/extensions/ms-python.python-2022.8.0/pythonFiles/testing_tools/adapter/__main__.py", line 100, in main parents, result = run(toolargs, **subargs) File "/root/.vscode-server/extensions/ms-python.python-2022.8.0/pythonFiles/testing_tools/adapter/pytest/_discovery.py", line 44, in discover raise Exception("pytest discovery failed (exit code {})".format(ec)) Exception: pytest discovery failed (exit code 3) at ChildProcess. (/root/.vscode-server/extensions/ms-python.python-2022.8.0/out/client/extension.js:2:232793) at Object.onceWrapper (node:events:510:26) at ChildProcess.emit (node:events:390:28) at maybeClose (node:internal/child_process:1064:16) at Socket. (node:internal/child_process:450:11) at Socket.emit (node:events:390:28) at Pipe. (node:net:687:12)] ```

User Settings

``` languageServer: "Jedi" linting • flake8Enabled: true • mypyArgs: "" • mypyEnabled: true sortImports • args: "" formatting • provider: "black" testing • pytestArgs: "" • pytestEnabled: true ```

Extension version: 2022.8.0 VS Code version: Code 1.68.1 (30d9c6cd9483b2cc586687151bcbcd635f373630, 2022-06-15T02:58:26.441Z) OS version: Linux x64 5.15.0-33-generic Restricted Mode: No Remote OS version: Linux x64 5.15.0-33-generic

System Info |Item|Value| |---|---| |CPUs|Intel(R) Core(TM) i7-10750H CPU @ 2.60GHz (12 x 2600)| |GPU Status|2d_canvas: enabled
canvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
oop_rasterization: disabled_off
opengl: enabled_on
rasterization: disabled_software
raw_draw: disabled_off_ok
skia_renderer: enabled_on
video_decode: disabled_software
video_encode: disabled_software
vulkan: disabled_off
webgl: enabled
webgl2: enabled| |Load (avg)|1, 2, 2| |Memory (System)|15.50GB (5.25GB free)| |Process Argv|--unity-launch --crash-reporter-id 2fd4e909-5d7a-4dd6-8163-dcde3e1c3c92| |Screen Reader|no| |VM|0%| |DESKTOP_SESSION|cinnamon| |XDG_CURRENT_DESKTOP|X-Cinnamon| |XDG_SESSION_DESKTOP|cinnamon| |XDG_SESSION_TYPE|x11| |Item|Value| |---|---| |Remote|Dev Container| |OS|Linux x64 5.15.0-33-generic| |CPUs|Intel(R) Core(TM) i7-10750H CPU @ 2.60GHz (12 x 4208)| |Memory (System)|15.50GB (5.25GB free)| |VM|0%|

Extra info: I have a single test file: image

With the following code:

def test_halp() -> None:
    assert 2 == 2
karthiknadig commented 2 years ago

The node id gge/tests/test_simplest.py::::test_halp looks weird. Can you run pytest --collect-only and share the output?

Mirandatz commented 2 years ago

Output of pytest --collect-only

root@258139b447e5:/workspaces/gge# pytest --collect-only
==================================================== test session starts =====================================================
platform linux -- Python 3.10.4, pytest-7.1.2, pluggy-1.0.0
cachedir: /dev/shm/pytest_cache
rootdir: /workspaces/gge, configfile: pyproject.toml
plugins: hypothesis-6.46.11, typeguard-2.13.3, pspec-0.0.4, xdist-2.5.0, forked-1.4.0
collected 1 item                                                                                                             

<Module gge/tests/test_simplest.py>
  <Function test_halp>

================================================= 1 test collected in 5.93s ==================================================
Mirandatz commented 2 years ago

And output of pytest

root@258139b447e5:/workspaces/gge# pytest
==================================================== test session starts =====================================================
platform linux -- Python 3.10.4, pytest-7.1.2, pluggy-1.0.0
cachedir: /dev/shm/pytest_cache
rootdir: /workspaces/gge, configfile: pyproject.toml
plugins: hypothesis-6.46.11, typeguard-2.13.3, pspec-0.0.4, xdist-2.5.0, forked-1.4.0
collected 1 item                                                                                                             

gge/tests/test_simplest.py .                                                                                           [100%]

===================================================== 1 passed in 5.52s ======================================================
karthiknadig commented 2 years ago

@Mirandatz Can you run pytest with -v so I can see the individual test ids?

Mirandatz commented 2 years ago
root@258139b447e5:/workspaces/gge# pytest -v
==================================================== test session starts =====================================================
platform linux -- Python 3.10.4, pytest-7.1.2, pluggy-1.0.0 -- /usr/bin/python
cachedir: /dev/shm/pytest_cache
hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('/workspaces/gge/.hypothesis/examples')
rootdir: /workspaces/gge, configfile: pyproject.toml
plugins: hypothesis-6.46.11, typeguard-2.13.3, pspec-0.0.4, xdist-2.5.0, forked-1.4.0
collected 1 item                                                                                                             

gge/tests/test_simplest.py::::test_halp PASSED                                                                         [100%]

===================================================== 1 passed in 5.31s ======================================================
karthiknadig commented 2 years ago

@Mirandatz We have a fix for the crash. It should be in the next pre-release tomorrow.

Mirandatz commented 2 years ago

I updated VS Code to 1.69.1, but now this happens:

image

Should I create a new issue? Is this related? Obs: invoking pytest from the builtin terminal still works:

(venv) thiago@e2c096c0e9b5:/workspaces/gge$ pytest .
================================================================ test session starts =================================================================
platform linux -- Python 3.10.4, pytest-7.1.2, pluggy-1.0.0
cachedir: /dev/shm/pytest_cache
rootdir: /workspaces/gge, configfile: pyproject.toml
plugins: xdist-2.5.0, hypothesis-6.48.3, forked-1.4.0, typeguard-2.13.3, pspec-0.0.4
collected 1 item                                                                                                                                     

gge/tests/test_simplest.py .                                                                                                                   [100%]

================================================================= 1 passed in 0.02s ==================================================================
karthiknadig commented 2 years ago

This is a known issue with how id's are handled when using plugins like hypothesis. We have a separate issue tracking ptyest issue with plugins, we have plans to address this with a new test adapter for pytest https://github.com/microsoft/vscode-python/issues/16852

karthiknadig commented 2 years ago

@Mirandatz When you run tests it generates a xml file with test results, would it be possible to find it and share the contents from it? You should be able to see the path in the output logs.

Mirandatz commented 2 years ago

I can't find this .xml, where is it stored by default?

image

karthiknadig commented 2 years ago

It is stored in the /tmp directory somewhere. You have to look the Output > python log, it will show you the exact path:

"./.venv/bin/python" -m pytest --rootdir "." --override-ini junit_family=xunit1 --junit-xml=/tmp/tmp-31644lyIU69gTMwqJ.xml ./tests/tests
Mirandatz commented 2 years ago

The log output shows

> /gge/venv/bin/python -m pytest --rootdir . --override-ini junit_family=xunit1 --junit-xml=/tmp/tmp-261pkSEVvxk0FhS.xml
cwd: .

But when I try to cp the file tmp-261pkSEVvxk0FhS.xml is errors out:

cp: cannot stat '/tmp/tmp-261pkSEVvxk0FhS.xml': No such file or directory

I think this file is automatically deleted? Or may it is not generate at all? I don't know.

When I executed the command manually (instead of relying on VS Code) the .xml file contents were:

<?xml version="1.0" encoding="utf-8"?><testsuites><testsuite name="pytest" errors="0" failures="0" skipped="0" tests="1" time="0.049" timestamp="2022-07-15T16:41:45.361932" hostname="50427b435524"><testcase classname="gge.tests.test_simplest." name="test_halp" file="gge/tests/test_simplest.py" line="0" time="0.001" /></testsuite></testsuites>
karthiknadig commented 2 years ago

@Mirandatz it gets created as a temp file, I guess it is getting cleaned up when the process exits. Thanks for running it manually. One more favor, can you run the discovery script also manually. Both together should pinpoint the problem. Make sure the script path is correct for your machine.

/gge/venv/bin/python ~/.vscode/extensions/ms-python.python-2022.10.0/pythonFiles/testing_tools/run_adapter.py discover pytest -- --rootdir . -s --cache-clear
Mirandatz commented 2 years ago

I was unable to run that command:

/gge/venv/bin/python ~/.vscode/extensions/ms-python.python-2022.10.0/pythonFiles/testing_tools/run_adapter.py discover pytest -- --rootdir . -s --cache-clear
/gge/venv/bin/python: can't open file '/home/thiago/.vscode/extensions/ms-python.python-2022.10.0/pythonFiles/testing_tools/run_adapter.py': [Errno 2] No such file or directory

But adapting it to use .vscode-server instead of .vscode and ms-python.python-2022.10.1 instead ofms-python.python-2022.10.0 result in:

/gge/venv/bin/python ~/.vscode-server/extensions/ms-python.python-2022.10.1/pythonFiles/testing_tools/run_adapter.py discover pytest -- --rootdir . -s --cache-clear
[{"rootid": ".", "root": "/workspaces/gge", "parents": [{"id": "./gge", "kind": "folder", "name": "gge", "parentid": ".", "relpath": "./gge"}, {"id": "./gge/tests", "kind": "folder", "name": "tests", "parentid": "./gge", "relpath": "./gge/tests"}, {"id": "./gge/tests/test_simplest.py", "kind": "file", "name": "test_simplest.py", "parentid": "./gge/tests", "relpath": "./gge/tests/test_simplest.py"}], "tests": [{"id": "./gge/tests/test_simplest.py::test_halp", "name": "test_halp", "source": "./gge/tests/test_simplest.py:1", "markers": [], "parentid": "./gge/tests/test_simplest.py"}]}]