Type: Bug # Behaviour *NOTE: not sure if it's a bug report or feature request to solve a bug* Hi! I am JD from the developer experience team at [Rippling](https://www.rippling.com/), and we are exploring moving the company's official editor from Pycharm to VSCode, but we are running on some critical issues when trying to use the test runner/debugger feature. For at least the pytest runs, test discovery currently functions by running pytest with the --collect-only flag to gather data about all current tests. For reasonable codebases, this works quite well, reasonably quick, and is a clever way of not re-inventing the wheel with test discovery. For large codebases with ~60K tests and ~300 dependencies, this becomes a problem. In our ci with larger machines, pytest --collect-only takes a little over 3 minutes to run, and ~10 minutes in the developer VMs we tested this out on. During this time, the editor's child process also consume updwards of 16GB of RAM. Moreover, afterwards the test line placement was wrong and the editor begins to show a myriad of ui errors, to the point of just restarting it from the frustration.  It is not a big leap of imagination to consider that the issue comes from the fact that we're trying to collect an insane number of tests in one go. We understand why this default strategy was chosen, but are hard-pressed to find alternatives. One solution which we've poc'd following [this guide](https://code.visualstudio.com/api/extension-guides/testing) was to not rely on pytest for the test discovery, but rather do a primitive syntax scan on the currently open python files and dynamically identify the tests following the simple innate rules: 1. [Does the file fit the regex “test_*.py”?](https://docs.pytest.org/en/7.1.x/reference/reference.html#confval-python_files) 2. [Does the class start with “Test”?](https://docs.pytest.org/en/7.1.x/reference/reference.html#confval-python_classes) 3. [Does the function start with “test”?](https://docs.pytest.org/en/7.1.x/reference/reference.html#confval-python_files) We found that this discovery strategy is quite snappy, takes up pretty much no resources, and works for almost all test cases (unless you're doing something really advanced with pytest/conftest). Our ask is: 1. Is there such a feature already available that we missed? 2. If there isn't, is there something on the short-term road map for this? 3. If there isn't, is can you help us out in making a PR to add this as an optional discovery strategy? (like point us to what part of the code needs to be updated for this to function-- I think it is pythonFiles/tests/testing_tools/adapter/pytest/test_discovery.py or pythonFiles/tests/pytestadapter/test_discovery.py or src/client/testing/testController/pytest/pytestDiscoveryAdapter.ts but I am not sure) ## Expected vs. Actual For the currently open test files, Pytest discovery 1. Works quickly (10 seconds) 2. Works correctly 3. Does not consume ~16GB of ram Actual: freezes for 10 minutes and then breaks ## Steps to reproduce: 1. Get a codebase with ~60K tests and ~300 dependencies. 2. Setup the venv everything usual there. 3. Do the regular flow to configure test runner with pytest. 4. Watch as your editor stalls for 10 minutes and then enters a broken state. # Diagnostic data - Python version (& distribution if applicable, e.g. Anaconda): 3.10.11 - Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): Poetry - Value of the `python.languageServer` setting: Default Output for Python in the Output panel (View→Output, change the drop-down the upper-right of the Output panel to Python) ``` XXX ``` User Settings ``` languageServer: "Pylance" testing • pytestArgs: "" • pytestEnabled: true ``` Extension version: 2023.14.0 VS Code version: Code 1.81.1 (Universal) (6c3e3dba23e8fadc360aed75ce363ba185c49794, 2023-08-09T22:20:33.924Z) OS version: Darwin arm64 22.6.0 Modes: System Info |Item|Value| |---|---| |CPUs|Apple M1 Pro (10 x 24)| |GPU Status|2d_canvas: enabledcanvas_oop_rasterization: disabled_offdirect_rendering_display_compositor: disabled_off_okgpu_compositing: enabledmetal: disabled_offmultiple_raster_threads: enabled_onopengl: enabled_onrasterization: enabledraw_draw: disabled_off_okvideo_decode: enabledvideo_encode: enabledvulkan: disabled_offwebgl: enabledwebgl2: enabledwebgpu: enabled| |Load (avg)|5, 5, 5| |Memory (System)|32.00GB (0.32GB free)| |Process Argv|. --crash-reporter-id 93d076a8-2779-4634-a060-d784b251ef33| |Screen Reader|no| |VM|0%| A/B Experiments ``` vsliv368cf:30146710 vsreu685:30147344 python383:30185418 vspor879:30202332 vspor708:30202333 vspor363:30204092 vswsl492cf:30256860 vslsvsres303:30308271 vserr242:30382549 pythontb:30283811 vsjup518:30340749 pythonptprofiler:30281270 vsdfh931:30280409 vshan820:30294714 vstes263cf:30335440 vscoreces:30445986 vscod805cf:30301675 binariesv615:30325510 bridge0708:30335490 bridge0723:30353136 vsaa593:30376534 pythonvs932:30410667 vsclangdf:30486550 c4g48928:30535728 dsvsc012:30540252 pynewext54:30695312 azure-dev_surveyone:30548225 vscccc:30803845 2e4cg342:30602488 f6dab269:30613381 a9j8j154:30646983 showlangstatbar:30737416 03d35959:30757346 pythonfmttext:30731395 fixshowwlkth:30771522 showindicator:30805244 pythongtdpath:30769146 i26e3531:30792625 pythonnosmt12:30797651 pythonidxpt:30805730 pythonnoceb:30805159 dsvsc013:30795093 dsvsc014:30804076 diffeditorv2:30821572 ```