Skip to content

Having PYTHONWARNINGS=default crashes pytest discovery #20259

Description

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 (View→Output, 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

Activity

  1. brettcannon commented on Nov 22, 2022

    @brettcannon
    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.

  2. added
    bugIssue identified by VS Code Team member as probable bug
    and removed
    triage-neededNeeds assignment to the proper sub-team
    on Dec 13, 2022
  3. eleanorjboyd commented on Jul 7, 2023

    @eleanorjboyd
    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!

  4. hoxbro commented on Jul 18, 2023

    @hoxbro
    Author

    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?

  5. brettcannon commented on Jul 18, 2023

    @brettcannon
    Member

    Do you want me to open a new issue?

    Simon Høxbro Hansen (@hoxbro) Yes please! Instructions can be found at https://aka.ms/pvsc-bug .

  6. locked as resolved and limited conversation to collaborators on Aug 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

area-testingbugIssue identified by VS Code Team member as probable bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions