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

Nested test classes not displaying pytest #22520

Closed
JamesHutchison opened this issue Nov 23, 2023 · 3 comments · Fixed by #22681
Closed

Nested test classes not displaying pytest #22520

JamesHutchison opened this issue Nov 23, 2023 · 3 comments · Fixed by #22681
Assignees
Labels
area-testing bug Issue identified by VS Code Team member as probable bug verification-needed Verification of issue is requested verified Verification succeeded

Comments

@JamesHutchison
Copy link

JamesHutchison commented Nov 23, 2023

Type: Bug

Create a pytest structure like this:

class TestMyClass
    def test_mytest

    class TestSubCategory
        def test_another_test

Extension version: 2023.20.0
VS Code version: Code 1.84.2 (1a5daa3a0231a0fbba4f14db7ec463cf99d7768e, 2023-11-09T10:51:52.184Z)
OS version: Windows_NT x64 10.0.19045
Modes:
Remote OS version: Linux x64 6.2.0-1016-azure

System Info
Item Value
CPUs Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz (8 x 2808)
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
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled
Load (avg) undefined
Memory (System) 15.89GB (6.27GB free)
Process Argv --crash-reporter-id ae591a24-d374-4309-8087-11db7f271645
Screen Reader no
VM 0%
Item Value
Remote Codespaces: orange giggle
OS Linux x64 6.2.0-1016-azure
CPUs AMD EPYC 7763 64-Core Processor (2 x 2432)
Memory (System) 7.74GB (5.29GB free)
VM 0%
A/B Experiments
vsliv368cf:30146710
vsreu685:30147344
python383:30185418
vspor879:30202332
vspor708:30202333
vspor363:30204092
vswsl492:30256859
vslsvsres303:30308271
vserr242cf:30382550
pythontb:30283811
vsjup518:30340749
pythonptprofiler:30281270
vshan820:30294714
vstes263cf:30335440
vscorecescf:30445987
vscod805cf:30301675
binariesv615:30325510
bridge0708:30335490
bridge0723:30353136
vsaa593:30376534
pythonvs932:30410667
py29gd2263:30880072
vsclangdf:30486550
c4g48928:30535728
dsvsc012cf:30540253
pynewext54:30695312
azure-dev_surveyone:30548225
2e4cg342:30602488
89544117:30613380
2i9eh265:30646982
showlangstatbar:30737416
pythonfmttext:30731395
fixshowwlkth:30771522
showindicator:30805244
pythongtdpath:30769146
i26e3531:30792625
pythonnosmt12:30797651
pythonidxpt:30866567
pythonnoceb:30805159
synctok:30869157
dsvsc013:30795093
dsvsc014:30804076
dsvsc015:30845448
pythontestfixtcf:30871695
pythonregdiag2:30871582
pyreplss1:30897532
pythonmypyd1:30879173
pythoncet0:30885854
h48ei257:30885898
pythontbext0:30879054
accentitlementsc:30887149
dsvsc016:30886110
dsvsc017cf:30886113
dsvsc018:30886114
aa_t_chat:30882232

test_bug

You can easily reproduce this bug in a codespace for megamock

https://github.com/JamesHutchison/megamock

Logs indicate pytest is correctly finding the tests so it appears this is a bug in how the results are interpreted

2023-11-23 18:06:55.946 [info]       <Function test_allows_for_setting_different_type>
      <Function test_assert_called_once_with>
      <Function test_return_value_equality_set_in_params>
      <Function test_return_value_equality_set_via_attribute>
      <Function test_meganame>
      <Function test_nested_assignment>

2023-11-23 18:06:55.946 [info]       <Class TestGenerateMockName>
        <Function test_name_of_class>
        <Function test_name_of_method>
        <Function test_name_of_mock_with_no_spec>
        <Function test_child_of_mock_with_no_spec>
@github-actions github-actions bot added the triage-needed Needs assignment to the proper sub-team label Nov 23, 2023
@JamesHutchison JamesHutchison changed the title Mid-level tests not displayed / counted Mid-level tests not displayed / counted (pytest) Nov 23, 2023
@eleanorjboyd
Copy link
Member

I honestly didn't know you could nest classes like this! Do you think it is necessary to handle an unknown number of nested classes or is going 2 levels down sufficient? Will investigate a fix. Thanks

@github-actions github-actions bot added the info-needed Issue requires more information from poster label Nov 27, 2023
@JamesHutchison
Copy link
Author

I would support up to at least 3, with supporting more (or an arbitrary amount) being better. I haven't needed to write 3 levels deep, but nested classes are an organization thing and it seems plausible there's some edge cases in some repos where it goes beyond 2. Like a user might do this:

class TestMyClass:
    def test_something_integration(self):
        ...
    class TestAMethod:
        def test_ungrouped_test(self):
            ...
        class TestGroupA:
        
        class TestGroupB:
        

@github-actions github-actions bot removed the info-needed Issue requires more information from poster label Nov 27, 2023
@eleanorjboyd eleanorjboyd added bug Issue identified by VS Code Team member as probable bug area-testing needs PR Ready to be worked on and removed triage-needed Needs assignment to the proper sub-team labels Nov 27, 2023
@eleanorjboyd
Copy link
Member

sweet thanks! Added this as a bug but no promises on a timeline for when I can work on this.

@eleanorjboyd eleanorjboyd changed the title Mid-level tests not displayed / counted (pytest) Nested test classes not displaying pytest Dec 5, 2023
@github-actions github-actions bot removed the needs PR Ready to be worked on label Dec 19, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 19, 2024
@eleanorjboyd eleanorjboyd added the verification-needed Verification of issue is requested label Jan 22, 2024
@eleanorjboyd eleanorjboyd added this to the December / January 2024 milestone Jan 22, 2024
@rzhao271 rzhao271 added the verified Verification succeeded label Jan 24, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-testing bug Issue identified by VS Code Team member as probable bug verification-needed Verification of issue is requested verified Verification succeeded
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants