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

Having PYTHONWARNINGS=default crashes pytest discovery #20259

Closed
hoxbro opened this issue Nov 21, 2022 · 4 comments
Closed

Having PYTHONWARNINGS=default crashes pytest discovery #20259

hoxbro opened this issue Nov 21, 2022 · 4 comments
Assignees
Labels
area-testing bug Issue identified by VS Code Team member as probable bug

Comments

@hoxbro
Copy link

hoxbro commented Nov 21, 2022

Type: Bug

Behaviour

Expected vs. Actual

When opening vscode with PYTHONWARNINGS=default and a warning is given it will fail discovering and error out. I would assume it could handle the warning.

Steps to reproduce:

  1. Set export PYTHONWARNINGS=default
  2. Open code from terminal with code .
  3. Have a module with a warning in it (for me it is playwright-pytest).
    • I have used the following environment:
mamba create -n tmp python=3.10 pytest
mamba install playwright -c microsoft -y 
pip install pytest-playwright

Diagnostic data

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

> conda run -n tmp --no-capture-output python ~/.vscode/extensions/ms-python.python-2022.18.2/pythonFiles/get_output_via_markers.py ~/.vscode/extensions/ms-python.python-2022.18.2/pythonFiles/printEnvVariables.py
> conda run -n tmp --no-capture-output python ~/.vscode/extensions/ms-python.python-2022.18.2/pythonFiles/get_output_via_markers.py ~/.vscode/extensions/ms-python.python-2022.18.2/pythonFiles/testing_tools/run_adapter.py discover pytest -- --rootdir . -s --cache-clear .
cwd: .
[ERROR 2022-10-21 21:58:29.261]: Error discovering pytest tests:
 [n [Error]: <frozen importlib._bootstrap>:914: ImportWarning: _SixMetaPathImporter.find_spec() not found; falling back to find_module()
<frozen importlib._bootstrap>:914: ImportWarning: _SixMetaPathImporter.find_spec() not found; falling back to find_module()
<frozen importlib._bootstrap>:914: ImportWarning: _SixMetaPathImporter.find_spec() not found; falling back to find_module()
<frozen importlib._bootstrap>:914: ImportWarning: _SixMetaPathImporter.find_spec() not found; falling back to find_module()
<frozen importlib._bootstrap>:914: ImportWarning: _SixMetaPathImporter.find_spec() not found; falling back to find_module()
<frozen importlib._bootstrap>:914: ImportWarning: _SixMetaPathImporter.find_spec() not found; falling back to find_module()
<frozen importlib._bootstrap>:914: ImportWarning: _SixMetaPathImporter.find_spec() not found; falling back to find_module()
<frozen importlib._bootstrap>:914: ImportWarning: _SixMetaPathImporter.find_spec() not found; falling back to find_module()
<frozen importlib._bootstrap>:914: ImportWarning: _SixMetaPathImporter.find_spec() not found; falling back to find_module()
<frozen importlib._bootstrap>:914: ImportWarning: _SixMetaPathImporter.find_spec() not found; falling back to find_module()
<frozen importlib._bootstrap>:914: ImportWarning: _SixMetaPathImporter.find_spec() not found; falling back to find_module()
<frozen importlib._bootstrap>:914: ImportWarning: _SixMetaPathImporter.find_spec() not found; falling back to find_module()
/home/shh/miniconda3/envs/tmp/lib/python3.10/tempfile.py:860: ResourceWarning: Implicitly cleaning up <TemporaryDirectory '/tmp/playwright-pytest-bus6_mv3'>
  _warnings.warn(warn_message, ResourceWarning)

	at ChildProcess.<anonymous> (/home/shh/.vscode/extensions/ms-python.python-2022.18.2/out/client/extension.js:2:242843)
	at Object.onceWrapper (node:events:646:26)
	at ChildProcess.emit (node:events:526:28)
	at maybeClose (node:internal/child_process:1092:16)
	at ChildProcess._handle.onexit (node:internal/child_process:302:5)]

User Settings


languageServer: "Pylance"

linting
• flake8Args: "<placeholder>"
• flake8Enabled: true
• mypyArgs: "<placeholder>"
• mypyEnabled: true

formatting
• provider: "black"

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

Extension version: 2022.18.2
VS Code version: Code 1.73.1 (6261075646f055b99068d3688932416f2346dd3b, 2022-11-09T03:54:53.913Z)
OS version: Linux x64 6.0.6-76060006-generic
Modes:
Sandboxed: No

System Info
Item Value
CPUs AMD Ryzen 9 5900X 12-Core Processor (24 x 4171)
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
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_renderer: enabled_on
video_decode: disabled_software
video_encode: disabled_software
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: disabled_off
Load (avg) 1, 1, 1
Memory (System) 125.72GB (116.09GB free)
Process Argv /home/shh/bin
Screen Reader no
VM 0%
DESKTOP_SESSION pop
XDG_CURRENT_DESKTOP Unity
XDG_SESSION_DESKTOP pop
XDG_SESSION_TYPE x11
@github-actions github-actions bot added the triage-needed Needs assignment to the proper sub-team label Nov 21, 2022
@brettcannon
Copy link
Member

This is due to us parsing the output from pytest at the moment. We are working on rewriting our pytest support so that our integration is via a pytest plug-in, but that work is still ongoing.

@eleanorjboyd eleanorjboyd added bug Issue identified by VS Code Team member as probable bug area-testing and removed triage-needed Needs assignment to the proper sub-team labels Dec 13, 2022
@eleanorjboyd
Copy link
Member

Hello! We have just finished our testing rewrite and are beginning the roll out to users. I have tested this issue with the re-write and I am no longer reproducing the bug! If you would like to try it yourself, you need to add this setting to your users settings.json "python.experiments.optInto": ["pythonTestAdapter"]. Let me know if it doesn’t work for you and we can re-open this issue. Thanks!

@hoxbro
Copy link
Author

hoxbro commented Jul 18, 2023

I'm still seeing problems with the new test adapter. I think it can't handle skipping tests:

2023-07-18 20:05:08.167 [info] Experiment 'pythonTestAdapter' is active
2023-07-18 20:05:08.167 [info] Test server listening.
2023-07-18 20:05:08.167 [info] Python interpreter path: ~/miniconda3/envs/holoviz/bin/python
...
2023-07-18 20:05:21.099 [error] pytest test discovery error 
 unittest.case.SkipTest: Could not import cuDF, skipping cuDFInterface tests.
 Check Python Test Logs for more details.

Emitted here: https://github.com/holoviz/holoviews/blob/003be4133a13949bf9bf081729e8fd2014cb511b/holoviews/tests/core/data/test_cudfinterface.py#L10

Do you want me to open a new issue?

@brettcannon
Copy link
Member

Do you want me to open a new issue?

@hoxbro Yes please! Instructions can be found at https://aka.ms/pvsc-bug .

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 18, 2023
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
Projects
None yet
Development

No branches or pull requests

3 participants