-
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
Inherited tests show run buttons in child test class #23069
Comments
sorry for the delay- i will look into this |
Where would you expect to see the inherited function? In |
I think they should not appear at all in the files themselves. tst_multiplication_abs is abstract and not a test file (it isn't hit by test discovery and could be inherited by 10, 20 or 100 other concrete test classes -- for example, our abstract test class for API actions has >100 different concrete test class implementations, and this issue happens on every single one). test_multiplication_two should not show it, since the test code being run by the test is in a different file, and it causes these confusing buttons shown above and below The abstract tests should only show up in the testing side-pane view In actual real code which uses abstract test classes, these abstract test buttons end up in completely nonsense locations, e.g. over fixtures or imports, which only makes things confusing Or, maybe instead of hiding altogether, all abstract tests for a class could be run with a single button on the line with the class keyword for that concrete implementation. This is maybe more elegant, but I could see it being confused for a 'run all tests in this class' button for people who don't know better |
Hi! I revisited this one and when I run
You can see from the output the lines returned from pytest, without the extension, point to line 14 and 15. In this way it seems like an upstream pytest issue that it returns the incorrect line for the abstract class. Potentially I could remove the line number manually for the abstract class but would have to somehow programmatically be able to detect the abstract class. If there is a way which a pytest plugin can detect the class being abstract I could look into adding that- so let me know if you have any ideas. Thanks! |
Type: Bug
Behaviour
Expected vs. Actual
Expected:
In test classes which inherit tests from parent classes, the inherited tests only appear in the testing side-pane, and do not appear as run-test buttons in the child test class in the code window
Actual:
The inherited tests display run test buttons in the child class, confusing what button is for what test.
Steps to reproduce:
./main.py
./tst_multiplication_abs.py
./test/test_multiplication_two.py
Green run button on line 14 is for TESTMultiplicationAbs.test_zero, and should not appear in this file
Granted, in this trivial example this is no big deal. But, in a more extensive codebase with many examples where dozens of tests are inherited from parent classes this becomes a bigger annoyance.
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: 2024.3.10660538
VS Code version: Code 1.86.1 (31c37ee8f63491495ac49e43b8544550fbae4533, 2024-02-07T09:08:20.941Z)
OS version: Windows_NT x64 10.0.19045
Modes:
System Info
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
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled
A/B Experiments
The text was updated successfully, but these errors were encountered: