Skip to content

FileNotFoundError when discovering tests #22950

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

Closed
kwood opened this issue Feb 21, 2024 · 2 comments
Closed

FileNotFoundError when discovering tests #22950

kwood opened this issue Feb 21, 2024 · 2 comments
Assignees
Labels
area-testing triage-needed Needs assignment to the proper sub-team

Comments

@kwood
Copy link

kwood commented Feb 21, 2024

Type: Bug

Behaviour

Expected vs. Actual

Expected: Pytest should be able to discover tests on the devcontainer
Actual: Python extension throws an error trying to read a tempfile it created, and no tests are discovered.

Steps to reproduce:

I'm not certain how to build a minimum reproduction case here—this is a Django project running in a devcontainer. I can run pytest just fine inside the container, and the exception is thrown inside python extension code.

Diagnostic data

  • Python version (& distribution if applicable, e.g. Anaconda): 3.11.8
  • Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): Global
  • Value of the python.languageServer setting: Default
Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

2024-02-21 15:25:12.197 [error] Error discovering pytest tests:
 n [Error]: Traceback (most recent call last):
  File "/home/eb/.vscode-server/extensions/ms-python.python-2024.0.1/pythonFiles/testing_tools/run_adapter.py", line 22, in <module>
    main(tool, cmd, subargs, toolargs)
  File "/home/eb/.vscode-server/extensions/ms-python.python-2024.0.1/pythonFiles/testing_tools/adapter/__main__.py", line 99, in main
    parents, result = run(toolargs, **subargs)
                      ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/eb/.vscode-server/extensions/ms-python.python-2024.0.1/pythonFiles/testing_tools/adapter/pytest/_discovery.py", line 29, in discover
    with util.hide_stdio() if hidestdio else util.noop_cm() as stdio:
  File "/usr/local/lib/python3.11/contextlib.py", line 144, in __exit__
    next(self.gen)
  File "/home/eb/.vscode-server/extensions/ms-python.python-2024.0.1/pythonFiles/testing_tools/adapter/util.py", line 251, in hide_stdio
    with _temp_io() as (sio, fileobj):
  File "/usr/local/lib/python3.11/contextlib.py", line 144, in __exit__
    next(self.gen)
  File "/home/eb/.vscode-server/extensions/ms-python.python-2024.0.1/pythonFiles/testing_tools/adapter/util.py", line 244, in _temp_io
    buff = tmp.read()
           ^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory

User Settings


languageServer: "Pylance"

testing
• pytestArgs: "<placeholder>"
• pytestEnabled: true
• unittestArgs: "<placeholder>"

experiments
• enabled: false

Extension version: 2024.0.1
VS Code version: Code 1.86.2 (903b1e9d8990623e3d7da1df3d33db3e42d80eda, 2024-02-13T19:42:12.210Z)
OS version: Darwin arm64 23.1.0
Modes:
Remote OS version: Linux arm64 6.6.12-linuxkit

System Info
Item Value
CPUs Apple M2 Max (12 x 24)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: enabled_on
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_graphite: disabled_off
video_decode: enabled
video_encode: enabled
webgl: enabled
webgl2: enabled
webgpu: enabled
Load (avg) 2, 3, 5
Memory (System) 32.00GB (0.06GB free)
Process Argv --crash-reporter-id 96ee63c6-c076-4359-87ab-090974f46b78
Screen Reader no
VM 0%
Item Value
Remote Dev Container: backend_dev @ desktop-linux
OS Linux arm64 6.6.12-linuxkit
CPUs unknown (12 x 0)
Memory (System) 15.60GB (12.20GB free)
VM 0%
A/B Experiments
vsliv368:30146709
vspor879:30202332
vspor708:30202333
vspor363:30204092
vscoreces:30445986
vscod805:30301674
binariesv615:30325510
vsaa593cf:30376535
py29gd2263:30899288
c4g48928:30535728
azure-dev_surveyonecf:30548226
2i9eh265:30646982
962ge761:30959799
pythongtdpath:30769146
welcomedialog:30910333
pythonidxpt:30866567
pythonnoceb:30805159
asynctok:30898717
pythontestfixt:30902429
pythonregdiag2:30936856
pyreplss1:30897532
pythonmypyd1:30879173
pythoncet0:30885854
2e7ec940:30968132
pythontbext0:30879054
dsvsc016:30899300
dsvsc017:30899301
dsvsc018:30899302
edj9j583:30969295
fegfb526:30961430
7j2b6412:30969109
bg6jg535:30958357

@github-actions github-actions bot added the triage-needed Needs assignment to the proper sub-team label Feb 21, 2024
@eleanorjboyd
Copy link
Member

Hello! It looks like you are on the old version of testing due to the path referenced -2024.0.1/pythonFiles/testing_tools/adapter/pytest/_discovery.py". Can you see if in your user settings you have disabled python experiments? You can also add "python.experiments.optInto": [
"pythonTestAdapter"
],

if you do this an reload, then you should see a different path / set of logs. See if that works, if not then please send me to logs from that run.

Thanks!

@github-actions github-actions bot added the info-needed Issue requires more information from poster label Feb 21, 2024
@kwood
Copy link
Author

kwood commented Feb 21, 2024

Yes, we have experiments disabled because of #22383

Our tests need to have sockets disabled, but it looks like if we upgrade pytest-socket and allow localhost we should be OK. Thanks for the help.

@kwood kwood closed this as completed Feb 21, 2024
@github-actions github-actions bot removed the info-needed Issue requires more information from poster label Feb 21, 2024
@kwood kwood reopened this Feb 21, 2024
@kwood kwood closed this as completed Feb 21, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 23, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-testing triage-needed Needs assignment to the proper sub-team
Projects
None yet
Development

No branches or pull requests

2 participants