-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Parameterized pytest tests run in parallel when executed through the editor #21529
Comments
Hello! I will investigate this now but in the meantime if you would like to check to see if it can still be repro-ed on the new rewrite architecture we are releasing you can check by add this setting to your users Thanks, otherwise ill reach out when I investigate further. |
This is a tricky issue. The parameterized tests I have consume quite the memory. Having it run 50+ of those simultaneously completely hangs the environment. |
@FRidh Could you elaborate more? Are you also expecting a sequential test run and your tests are run in parallel? |
Exactly. Right clicking on the test in the code viewer and then |
able to repro- thank you! Will get a fix in |
@FRidh, how do you know the tests are running in parallel? On further investigation I have noticed that the parameterized tests are run in a different (possibly random) order when started from the gutter but the tests are still executed one at a time. |
I don't know for sure, but cpu usage and memory is massive in the cases where I encountered the issue. The test uses quite some memory and should sometimes spike in CPU usage. When I run it using |
@red8888, could you explain a bit more about your use case? By design tests should ideally be independent from each other and pytest tests do not actually have a default ordering or understanding of their order (this is a behavior that can be achieved through an additional plugin). The gutter could call run on the parameterize test as a whole instead of each individual test id (thus maintaining an order), but this would require a larger effort as the design change would affect all testing in vscode. Therefore I cannot say if that design change would even be approved and would require larger community/extension involvement. |
@eleanorjboyd thank you for investigating this. I created the original stack overflow issue for this that is referenced in this bug report. There is example code in the Stack Overflow post with output that demonstrates that the tests are running in parallel. |
@GCaw, can you try this on our new testing rewrite? You can do so by setting:
|
@FRidh if you set your python log level to trace and your vscode log level to trace you should see a line in your python output that looks something like this |
@eleanorjboyd running my example tests with the pythonTestAdapater experiment, I see the same behaviour as you: all the parameterized tests run as one test session, resulting in sequential running of the parameterized tests. This would seem to resolve the issue for me. |
@GCaw that is great to hear! Thank you for hopping on the issue to provide that example test case! |
Have confirmed this only spawns 1 pytest process for me in both the test explorer and with the editor gutter button 👍 |
Same. Issue is resolved for me as well with this setting. |
Same. Issue is resolved for me as well with this setting 🥳 Thx ! |
Great thanks everyone! |
Type: Bug
Behaviour
Expected vs. Actual
Python extension runs parameterized pytests sequentially (the expected default behavior) by default when run in test exporer AND the editor.
I uncovered this because I have a parameterized test that must run squetentially (it creates and cleans up files). When run in the editor I can see it fail due to a race condition resulting from the tests running in paralell. It never fails when run through test explorer or the pytest command line.
There is an SO post for this same issue with no responses: https://stackoverflow.com/questions/72204026/running-parametrize-pytests-in-vs-code-sometimes-runs-in-parallel-is-there-a-se
Steps to reproduce:
Diagnostic data
python.languageServer
setting: DefaultOutput for
Python
in theOutput
panel (View
→Output
, change the drop-down the upper-right of theOutput
panel toPython
)User Settings
Extension version: 2022.18.2
VS Code version: Code 1.73.1 (Universal) (6261075646f055b99068d3688932416f2346dd3b, 2022-11-09T02:08:38.961Z)
OS version: Darwin arm64 22.4.0
Modes:
Sandboxed: No
Remote OS version: Linux x64 5.15.49-linuxkit
System Info
canvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
metal: disabled_off
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_renderer: enabled_on
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: disabled_off
A/B Experiments
The text was updated successfully, but these errors were encountered: