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

Django test discovery now indefinitely runs #24668

Closed
kymckay opened this issue Dec 31, 2024 · 12 comments
Closed

Django test discovery now indefinitely runs #24668

kymckay opened this issue Dec 31, 2024 · 12 comments
Labels
triage-needed Needs assignment to the proper sub-team

Comments

@kymckay
Copy link

kymckay commented Dec 31, 2024

Type: Bug

Behaviour

When I open the testing side panel it runs discovery forever. There have been no changes to my config or my python environment since this was last seen working.

I have MANAGE_PY_PATH and DJANGO_SETTINGS_MODULE set in my .env file and my .vscode/settings.json is like so:

{
  "python.testing.autoTestDiscoverOnSaveEnabled": false,
  "python.defaultInterpreterPath": ".venv/bin/python",
  "python.testing.unittestEnabled": true,
  "python.testing.unittestArgs": [
    "--keepdb"
  ]
}

Steps to reproduce:

  1. Configure test discovery for Django
  2. Open the testing side panel

Diagnostic data

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

2024-12-30 22:37:56.363 [info] Experiment 'pythonTestAdapter' is active
2024-12-30 22:37:56.363 [info] Experiment 'pythonRecommendTensorboardExt' is active
2024-12-30 22:37:56.363 [info] Experiment 'pythonSurveyNotification' is active
2024-12-30 22:37:56.363 [info] Experiment 'pythonTerminalEnvVarActivation' is active
2024-12-30 22:37:56.363 [warning] Dir "/Users/kylemckay/code/cinder/.pixi/envs" is not watchable (directory does not exist)
2024-12-30 22:37:56.363 [info] VS Code was launched from an activated environment: '.venv', selecting it as the interpreter for workspace.
2024-12-30 22:37:56.363 [info] Python interpreter path: ./.venv/bin/python
2024-12-30 22:37:57.461 [info] > pyenv which python
2024-12-30 22:37:57.461 [info] cwd: .
2024-12-30 22:37:57.885 [info] > . ./.venv/bin/activate && echo 'e8b39361-0157-4923-80e1-22d70d46dee6' && python ~/.vscode/extensions/ms-python.python-2024.22.1-darwin-arm64/python_files/printEnvVariables.py
2024-12-30 22:37:57.885 [info] shell: zsh
2024-12-30 22:37:57.962 [info] > /usr/bin/python3 ~/.vscode/extensions/ms-python.python-2024.22.1-darwin-arm64/python_files/printEnvVariables.py
2024-12-30 22:37:57.962 [info] shell: zsh
2024-12-30 22:37:58.246 [info] Prepending environment variable PATH in collection with /Users/kylemckay/.vscode/extensions/ms-python.python-2024.22.1-darwin-arm64/python_files/deactivate/zsh:/Users/kylemckay/code/cinder/.venv/bin: {"applyAtShellIntegration":true,"applyAtProcessCreation":true}
2024-12-30 22:37:58.246 [info] Setting environment variable VIRTUAL_ENV_PROMPT in collection to cinder-py3.11 {"applyAtShellIntegration":true,"applyAtProcessCreation":true}
2024-12-30 22:37:58.246 [info] Prepending environment variable PS1 in collection with cinder-py3.11 {"applyAtShellIntegration":true,"applyAtProcessCreation":false}
2024-12-30 22:37:58.246 [info] Send text to terminal: /usr/bin/python3 /Users/kylemckay/.vscode/extensions/ms-python.python-2024.22.1-darwin-arm64/python_files/printEnvVariablesToFile.py /Users/kylemckay/.vscode/extensions/ms-python.python-2024.22.1-darwin-arm64/python_files/deactivate/zsh/envVars.txt
2024-12-30 22:37:58.703 [info] Starting Pylance language server.
2024-12-30 22:38:42.108 [info] > conda info --json
2024-12-31 09:18:11.683 [info] Discover tests for workspace name: cinder - uri: /Users/kylemckay/code/cinder
2024-12-31 09:18:11.683 [info] Running discovery for unittest using the new test adapter.
2024-12-31 09:18:11.735 [info] > . ./.venv/bin/activate && echo 'e8b39361-0157-4923-80e1-22d70d46dee6' && python ~/.vscode/extensions/ms-python.python-2024.22.1-darwin-arm64/python_files/printEnvVariables.py
2024-12-31 09:18:11.735 [info] shell: bash
2024-12-31 09:18:11.770 [info] Discovering unittest tests for workspace /Users/kylemckay/code/cinder with arguments: /Users/kylemckay/.vscode/extensions/ms-python.python-2024.22.1-darwin-arm64/python_files/unittestadapter/discovery.py,--udiscovery,--keepdb

2024-12-31 09:18:11.770 [info] > ./.venv/bin/python ~/.vscode/extensions/ms-python.python-2024.22.1-darwin-arm64/python_files/unittestadapter/discovery.py --udiscovery --keepdb
2024-12-31 09:18:11.770 [info] cwd: .
2024-12-31 09:18:11.816 [info] MANAGE_PY_PATH is set, running Django discovery with path to manage.py as: $./manage.py

2024-12-31 09:18:11.816 [info] Running Django tests with command: ['/Users/kylemckay/code/cinder/.venv/bin/python', './manage.py', 'test', '--testrunner=django_test_runner.CustomDiscoveryTestRunner', '--keepdb']

Extension version: 2024.22.1
VS Code version: Code 1.96.2 (Universal) (fabdb6a30b49f79a7aba0f2ad9df9b399473380f, 2024-12-19T10:22:47.216Z)
OS version: Darwin arm64 24.2.0
Modes:

  • Python version (& distribution if applicable, e.g. Anaconda): 3.11.4
  • Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): Poetry
  • Value of the python.languageServer setting: Default
User Settings


languageServer: "Pylance"

testing
• unittestArgs: "<placeholder>"
• unittestEnabled: true
• autoTestDiscoverOnSaveEnabled: false

experiments
• optInto: ["pythonTestAdapter"]

Installed Extensions
Extension Name Extension Id Version
.NET Install Tool ms-dotnettools.vscode-dotnet-runtime 2.2.3
Biome biomejs.biome 2.3.0
C/C++ ms-vscode.cpptools 1.22.11
C# ms-dotnettools.csharp 2.55.29
Docker ms-azuretools.vscode-docker 1.29.3
EditorConfig for VS Code EditorConfig.EditorConfig 0.16.4
ESLint dbaeumer.vscode-eslint 3.0.10
Even Better TOML tamasfe.even-better-toml 0.21.2
GitHub Copilot GitHub.copilot 1.254.0
GitHub Copilot Chat GitHub.copilot-chat 0.23.2
GitLens — Git supercharged eamodio.gitlens 16.1.1
Go golang.go 0.44.0
GraphQL mquandalle.graphql 0.1.2
HashiCorp Terraform hashicorp.terraform 2.34.2
isort ms-python.isort 2023.10.1
JavaScript Debugger ms-vscode.js-debug 1.96.0
JavaScript Debugger Companion Extension ms-vscode.js-debug-companion 1.1.3
Jupyter ms-toolsai.jupyter 2024.11.0
Jupyter Cell Tags ms-toolsai.vscode-jupyter-cell-tags 0.1.9
Jupyter Keymap ms-toolsai.jupyter-keymap 1.1.2
Jupyter Notebook Renderers ms-toolsai.jupyter-renderers 1.0.21
Jupyter Slide Show ms-toolsai.vscode-jupyter-slideshow 0.1.6
Kubernetes ms-kubernetes-tools.vscode-kubernetes-tools 1.3.18
Pylance ms-python.vscode-pylance 2024.12.1
Python ms-python.python 2024.22.1
Python Debugger ms-python.debugpy 2024.14.0
Ruff charliermarsh.ruff 2024.56.0
Simple React Snippets burkeholland.simple-react-snippets 1.2.8
Table Visualizer for JavaScript Profiles ms-vscode.vscode-js-profile-table 1.0.10
YAML redhat.vscode-yaml 1.15.0
System Info
Item Value
CPUs Apple M2 Pro (10 x 2400)
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
webnn: disabled_off
Load (avg) 2, 2, 3
Memory (System) 16.00GB (0.21GB free)
Process Argv . --crash-reporter-id 8ef3b5b9-2249-469d-bec0-04835ab05199
Screen Reader no
VM 0%
A/B Experiments
vsliv368:30146709
vspor879:30202332
vspor708:30202333
vspor363:30204092
pythonvspyt551:31179978
vscod805cf:30301675
binariesv615:30325510
vsaa593:30376534
py29gd2263:31024239
c4g48928:30535728
azure-dev_surveyonecf:30548226
962ge761:30959799
pythonnoceb:30805159
pythonmypyd1:30879173
h48ei257:31000450
pythontbext0:30879054
cppperfnew:31000557
dsvsc020:30976470
pythonait:31006305
dsvsc021:30996838
dvdeprecation:31068756
dwnewjupytercf:31046870
nativerepl1:31139838
pythonrstrctxt:31112756
nativeloc2:31192216
cf971741:31144450
iacca1:31171482
notype1cf:31157160
5fd0e150:31155592
dwcopilot:31170013
stablechunks:31184530
6074i472:31201624

@github-actions github-actions bot added the triage-needed Needs assignment to the proper sub-team label Dec 31, 2024
@goudyj
Copy link

goudyj commented Dec 31, 2024

I had the same problem for my Python project (not related to Django) and went back to the previous version v2024.22.0 @kymckay

@gtsugarfunk
Copy link

Had the same issue, discovery was fine, added a new test function, refreshed tests and discovery would never complete. Re-installed VSCode and all extensions with no joy. Rolled back to previous version v2024.22.0 and test discovery fully working

@dtomlinson91
Copy link

Something has definitely borked up the testing discovery in the latest update, I'm using just pytest no plugins. I add 19 tests it discovers fine, I add a 20th test and it breaks.

@christiansegercrantz
Copy link

Chiming in with the above, same problem and rollback solved the problem. I did not notice if I did anything previous to refreshing, but once I did nothing made the refresh complete. In the output view I could see the results be printed.

@hellej
Copy link

hellej commented Jan 2, 2025

Something has definitely borked up the testing discovery in the latest update, I'm using just pytest no plugins. I add 19 tests it discovers fine, I add a 20th test and it breaks.

Same here - test discoveries never finish since ~2 weeks ago. I can see in the Python output that the pytest --collect-only command successfully prints the list of all tests but the Testing tab remains in loading state:
Image

(python: 3.12.7 / conda, python extension: 2024.22.1, VSCode: 1.96.2 (Universal))

{
  "python.testing.pytestArgs": ["tests", "--asyncio-mode=auto"],
  "python.testing.unittestEnabled": false,
  "python.testing.pytestEnabled": true
}

@dvirbech
Copy link

dvirbech commented Jan 2, 2025

It happened to me as well, running tests would fail, and new test discovery is running indefinitely. rolled back to v2024.22.0 and everything is working again.

@raiyan396
Copy link

Thank you guys for this discussion! Rolling back the python extension version to v2024.22.0 also fixed my indefinite test discovery for my python project.

My python project was also unrelated to Django.

@nyxgear
Copy link

nyxgear commented Jan 2, 2025

Exact same scenario for me.
The tests discovery hangs indefinitely after the python output tab successfully shows the tests discovery tree.
pytest --collect-only works as expected w/o issues.
My project is unrelated to Django.

Problematic version: v2024.22.1.
Rolling back to v2024.22.0 fixed the issue.

May be helpful for troubleshooting, with the v2024.22.1, if the project contains only a few test files, the tests are eventually loaded in the sidebar.

@jeff-m-sullivan
Copy link

Was having the same issue with a non-django project; just regular Python data science stack. Reverting the Python plugin to v2024.22.0 fixed it immediately.

Running tests using CLI had no issues.

Total of 327 tests, with many parameterized. Command-line pytest --collect-only completes in 0.60 second.

@dvirbech
Copy link

dvirbech commented Jan 2, 2025

Guys I guess it's the same thing as #24656

@errietta
Copy link

errietta commented Jan 3, 2025

Same here!! Please fix this
Sorry I made a duplicate issue here
#24672

@kymckay
Copy link
Author

kymckay commented Jan 3, 2025

Thanks @dvirbech, closing this as a duplicate of that issue. Any future travellers should go add reactions / support to it.

@kymckay kymckay closed this as completed Jan 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage-needed Needs assignment to the proper sub-team
Projects
None yet
Development

No branches or pull requests