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

Test discovery tries to run pytest when disabled #22765

Closed
irishismyname opened this issue Jan 19, 2024 · 8 comments
Closed

Test discovery tries to run pytest when disabled #22765

irishismyname opened this issue Jan 19, 2024 · 8 comments
Assignees
Labels
area-testing needs PR Ready to be worked on

Comments

@irishismyname
Copy link

Type: Bug

Behaviour

Expected vs. Actual

With "python.testing.pytestEnabled": false in settings.json, the extensions still attempts to run

.\.venv\Scripts\python.exe -m pytest -p vscode_pytest --collect-only

which results in

[error] python.exe: No module named pytest

Steps to reproduce:

  1. Add

    "python.testing.pytestEnabled": false,
    "python.testing.unittestEnabled": true

    to settings.json

  2. Populate python.testing.unittestArgs to point to your unit tests.

  3. Tests are not discovered and you get error [error] python.exe: No module named pytest

Diagnostic data

  • Python version (& distribution if applicable, e.g. Anaconda): 3.11.6
  • Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): Venv
  • 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-01-19 11:33:07.338 [info] > .\.venv\Scripts\python.exe -m pytest -p vscode_pytest --collect-only
2024-01-19 11:33:07.338 [info] cwd: .
2024-01-19 11:33:07.482 [error] <redacted>\python.exe: No module named pytest

2024-01-19 11:33:07.494 [error] Subprocess exited unsuccessfully with exit code 1 and signal null on workspace <redacted>.
2024-01-19 11:33:07.494 [error] Subprocess exited unsuccessfully with exit code 1 and signal null on workspace <redacted>. Creating and sending error discovery payload
2024-01-19 11:33:07.495 [error] pytest test discovery error for workspace:  <redacted> 
  
 The python test process was terminated before it could exit on its own, the process errored with: Code: 1, Signal: null for workspace <redacted>
2024-01-19 11:33:07.495 [info] ResultResolver EOT received for discovery.
2024-01-19 11:33:07.495 [info] Disposing data receiver for <redacted> and deleting UUID; pytest discovery.

User Settings


languageServer: "Pylance"

testing
• unittestArgs: "-v -s /path/to/tests -p test_*.py"
• pytestEnabled: false
• unittestEnabled: true


Extension version: 2023.22.1
VS Code version: Code 1.85.2 (8b3775030ed1a69b13e4f4c628c612102e30a681, 2024-01-18T06:40:10.514Z)
OS version: Windows_NT x64 10.0.22621
Modes:

A/B Experiments
vsliv368cf:30146710
vspor879:30202332
vspor708:30202333
vspor363:30204092
vscod805:30301674
binariesv615:30325510
vsaa593cf:30376535
py29gd2263:30899288
vsclangdf:30486550
c4g48928:30535728
azure-dev_surveyone:30548225
a9j8j154:30646983
962ge761:30933248
pythongtdpath:30769146
welcomedialog:30910333
pythonidxpt:30866567
pythonnoceb:30805159
asynctok:30898717
pythontestfixt:30902429
pythonregdiag2:30936856
pyreplss1:30897532
pythonmypyd1:30879173
pythoncet0:30885854
pythontbext0:30879054
dsvsc016:30899300
dsvsc017:30899301
dsvsc018:30899302
dsvsc019acf:30933242

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

if you reload your vscode window and try again with the settings already set to unittest on and pytest off does this still occur?

@github-actions github-actions bot added the info-needed Issue requires more information from poster label Jan 19, 2024
@korompaiistvan
Copy link

korompaiistvan commented Feb 28, 2024

I just faced the same issue and reloading the window after setting the relevant lines solved the issue, tests were discovered appropriately.

VSCode: v1.86.2
Python extension: v2024.0.1
Running in DevContainer

@eleanorjboyd
Copy link
Member

Hi! I have found the issue here and am working on a fix! Thanks

Copy link

github-actions bot commented Jun 7, 2024

Because we have not heard back with the information we requested, we are closing this issue for now. If you are able to provide the info later on, then we will be happy to re-open this issue to pick up where we left off.

Happy Coding!

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jun 7, 2024
@eleanorjboyd eleanorjboyd reopened this Jun 7, 2024
@eleanorjboyd eleanorjboyd removed the info-needed Issue requires more information from poster label Jun 7, 2024
@eleanorjboyd eleanorjboyd added needs PR Ready to be worked on and removed triage-needed Needs assignment to the proper sub-team labels Jun 28, 2024
@eleanorjboyd
Copy link
Member

as an update this will be fixed by dynamic activation of test adapters which is currently blocked on our config redesign

@eleanorjboyd
Copy link
Member

Hello! Realized this is actually a duplicate of the following: #21688. I do have a solution but am looking for the right time to implement given some other projects in the same code area.

@eleanorjboyd eleanorjboyd closed this as not planned Won't fix, can't repro, duplicate, stale Jul 22, 2024
@shaojun
Copy link

shaojun commented Aug 5, 2024

I have the same issue here with latest version of vscode 1.92.0 at 2024, Aug.
my .vscode/settings.json is:

{
    "python.testing.unittestArgs": [
        "-v",
        "-s",
        "./tao_triton",
        "-p",
        "test_*.py"
    ],
    "python.testing.pytestEnabled": false,
    "python.testing.unittestEnabled": true
}

and when click refresh test button in testing panel, below logs show in OUTPUT:

2024-08-05 09:15:26.531 [warning] could not find a pixi interpreter for the interpreter at /home/shao/miniconda3/envs/devicehubpy10/bin/python
2024-08-05 09:15:26.543 [info] > conda run -n devicehubpy10 --no-capture-output python ~/.vscode-server/extensions/ms-python.python-2024.12.1/python_files/get_output_via_markers.py -m pytest -p vscode_pytest --collect-only
2024-08-05 09:15:26.544 [info] cwd: .
2024-08-05 09:15:27.365 [info] >>>PYTHON-EXEC-OUTPUT

2024-08-05 09:15:27.365 [info] <<<PYTHON-EXEC-OUTPUT

2024-08-05 09:15:27.365 [error] Traceback (most recent call last):
  File "/home/shao/.vscode-server/extensions/ms-python.python-2024.12.1/python_files/get_output_via_markers.py", line 23, in <module>
    runpy.run_module(module_name, run_name="__main__", alter_sys=True)
  File "/home/shao/miniconda3/envs/devicehubpy10/lib/python3.10/runpy.py", line 220, in run_module
    mod_name, mod_spec, code = _get_module_details(mod_name)
  File "/home/shao/miniconda3/envs/devicehubpy10/lib/python3.10/runpy.py", line 140, in _get_module_details
    raise error("No module named %s" % mod_name)
ImportError: No module named pytest

2024-08-05 09:15:27.368 [error] ERROR conda.cli.main_run:execute(124): `conda run python /home/shao/.vscode-server/extensions/ms-python.python-2024.12.1/python_files/get_output_via_markers.py -m pytest -p vscode_pytest --collect-only` failed. (See above for error)

2024-08-05 09:15:27.434 [error] Subprocess exited unsuccessfully with exit code 1 and signal null on workspace /home/shao/tao-toolkit-triton-apps.
2024-08-05 09:15:27.434 [error] Subprocess exited unsuccessfully with exit code 1 and signal null on workspace /home/shao/tao-toolkit-triton-apps. Creating and sending error discovery payload
2024-08-05 09:15:27.434 [error] pytest test discovery error for workspace:  /home/shao/tao-toolkit-triton-apps 
  
 The python test process was terminated before it could exit on its own, the process errored with: Code: 1, Signal: null for workspace /home/shao/tao-toolkit-triton-apps

@eleanorjboyd
Copy link
Member

@shaojun please try reloading again- it still says its attempting to access pytest

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 6, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-testing needs PR Ready to be worked on
Projects
None yet
Development

No branches or pull requests

4 participants