Type: Performance Issue
Behaviour
When running a test for a given module, the whole codebase is unnecessarily imported, even if no import statements are present in said module or in __init__.py files. In codebase with slow imports, this can drastically slow down the testing/debugging process. This occurs once the tests are already discovered and on each test re-run (without code change).
Steps to reproduce:
- Create a dummy project with 2 files. One with a time.sleep(10), the other without
- Create 2 test files, one per dummy code file. Run the test for the file without the sleep command and you will observe that the "slow import" file is also imported
See vscode_py_test.zip
Diagnostic data
Output for Python in the Output panel (View→Output, change the drop-down the upper-right of the Output panel to Python)
2026-08-11 13:28:13.013 [info] [test-by-project] Executing tests across 1 project(s), debug=false
2026-08-11 13:28:13.014 [info] [test-by-project] Executing 1 test item(s) for project: vscode_py_test (Python 3.11)
2026-08-11 13:28:13.014 [info] [test-by-project] Running 1 test(s) for project: vscode_py_test (Python 3.11)
2026-08-11 13:28:13.015 [info] [test-by-project] Setting PROJECT_ROOT_PATH=d:\Users\JRL\vscode_py_test for unittest execution
2026-08-11 13:28:13.015 [info] Running UNITTEST execution for the following test ids: tests.fast_imp_test.TestFunc.test_func
2026-08-11 13:28:13.015 [info] Attempting to use temp directory for test ids file, file name: test-ids-a624b8e10959e9bce72b.txt
2026-08-11 13:28:13.021 [info] All environment variables set for unittest execution, PYTHONPATH: "d:\\Users\\JRL\\vscode_py_test"
2026-08-11 13:28:13.023 [info] Running unittest with arguments: c:\Users\z007459\.vscode\extensions\ms-python.python-2026.4.0-win32-x64\python_files\unittestadapter\execution.py --udiscovery -v -s ./tests -p *_test.py for workspace d:\Users\JRL\vscode_py_test
2026-08-11 13:28:23.457 [info] [test-by-project] All project executions completed
Extension version: 2026.4.0
VS Code version: Code 1.126.0 (7e7950df89d055b5a378379db9ee14290772148a, 2026-06-23T01:46:13Z)
OS version: Windows_NT x64 10.0.26100
Modes:
- Python version (& distribution if applicable, e.g. Anaconda): 3.11.9
- Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): System
- Value of the
python.languageServer setting: Pylance
User Settings
languageServer: "Pylance"
testing
• unittestArgs: "<placeholder>"
• unittestEnabled: true
Installed Extensions
| Extension Name |
Extension Id |
Version |
| black-formatter |
ms- |
2026.6.0 |
| continue |
Con |
2.0.0 |
| debugpy |
ms- |
2026.6.0 |
| git-graph |
mhu |
1.30.0 |
| githistory |
don |
0.6.20 |
| js-debug |
ms- |
1.117.0 |
| js-debug-companion |
ms- |
1.1.3 |
| jsts-chat-features |
Typ |
0.0.4 |
| jupyter |
ms- |
2025.9.1 |
| jupyter-keymap |
ms- |
1.1.2 |
| jupyter-renderers |
ms- |
1.3.0 |
| matlab |
Gim |
3.0.2 |
| oracle-java |
Ora |
26.0.0 |
| pylint |
ms- |
2026.6.0 |
| python |
ms- |
2026.4.0 |
| rewrap |
stk |
1.16.3 |
| vscode-js-profile-table |
ms- |
1.0.10 |
| vscode-jupyter-cell-tags |
ms- |
0.1.9 |
| vscode-jupyter-slideshow |
ms- |
0.1.6 |
| vscode-pdf |
mat |
0.1.11 |
| vscode-pylance |
ms- |
2026.3.1 |
| vscode-python-envs |
ms- |
1.36.0 |
Type: Performance Issue
Behaviour
When running a test for a given module, the whole codebase is unnecessarily imported, even if no import statements are present in said module or in
__init__.pyfiles. In codebase with slow imports, this can drastically slow down the testing/debugging process. This occurs once the tests are already discovered and on each test re-run (without code change).Steps to reproduce:
See vscode_py_test.zip
Diagnostic data
Output for
Pythonin theOutputpanel (View→Output, change the drop-down the upper-right of theOutputpanel toPython)Extension version: 2026.4.0
VS Code version: Code 1.126.0 (7e7950df89d055b5a378379db9ee14290772148a, 2026-06-23T01:46:13Z)
OS version: Windows_NT x64 10.0.26100
Modes:
python.languageServersetting: PylanceUser Settings
Installed Extensions