Repository navigation
Support pytest-describe in testing rewrite #21705
Description
Type: Bug
Behaviour
Expected vs. Actual
With the following dependencies:
"pytest==7.4.0"
"pytest-describe==2.1.0"
Considering the following test file:
# test_pytest_describe.py
def describe_A():
def test_1():
pass
def test_2():
pass
def describe_B():
def test_1():
pass
def test_2():
passWhen discovering tests (with the new adapter, "python.experiments.optInto": ["pythonTestAdapter"]), only the last describe block is registered, here describe_B.
By "registered", I mean :
- displayed in the tests explorer
- having a "run/debug test" quick action in the editor
Neither the describe_A block, nor its tests appear anywhere. FWIW, I tested with different test names, not conflicting between describe blocks (describe_B, test_3/test_4 instead of test_1/test_2), the issue sill occurs.
In the Output for Python section below, I added an extract of the test collection output which includes the describe_A block. I assume it means the test collection works well but there is an issue down the line?
Steps to reproduce:
- See above
Diagnostic data
- Python version (& distribution if applicable, e.g. Anaconda): 3.9.16
- Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): Venv
- Value of the
python.languageServersetting: Pylance
Output for Python in the Output panel (View→Output, change the drop-down the upper-right of the Output panel to Python)
collected xx items
<Package test>
[...]
<Module test_pytest_describe.py>
<DescribeBlock 'describe_A'>
<Function test_1>
<Function test_2>
<DescribeBlock 'describe_B'>
<Function test_1>
<Function test_2>
[...]
User Settings
Multiroot scenario, following user settings may not apply:
venvPath: "<placeholder>"
languageServer: "Pylance"
linting
• flake8Enabled: true
• mypyArgs: "<placeholder>"
• mypyEnabled: true
formatting
• provider: "black"
• blackArgs: "<placeholder>"
testing
• autoTestDiscoverOnSaveEnabled: false
experiments
• optInto: ["pythonTestAdapter"]
Extension version: 2023.12.0
VS Code version: Code 1.80.2 (Universal) (2ccd690cbff1569e4a83d7c43d45101f817401dc, 2023-07-27T21:05:41.366Z)
OS version: Darwin arm64 22.5.0
Modes:
System Info
| Item | Value |
|---|---|
| CPUs | Apple M1 (8 x 24) |
| GPU Status | 2d_canvas: enabled 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 video_decode: enabled video_encode: enabled vulkan: disabled_off webgl: enabled webgl2: enabled webgpu: enabled |
| Load (avg) | 3, 3, 2 |
| Memory (System) | 16.00GB (0.07GB free) |
| Process Argv | |
| Screen Reader | no |
| VM | 0% |


Activity
[-]When using pytest-describe, test discovery only register the last `describe` block[/-][+]When using pytest-describe, test discovery only register the last `describe` block in each file[/+]eleanorjboyd commentedon Jul 31, 2023
will investigate, thank you for filing!
eleanorjboyd commentedon Jul 31, 2023
What args are required for pytest to recognize describe blocks? I am not seeing even pytest from the CLI recognize it with the sample code you provided. Thanks
QuentinFchx commentedon Aug 2, 2023
Unless I'm mistaken, no particular arguments are required.
What can I do to help you reproduce, do you need a sample repository? (is there a sample repository with a boilerplate I can start from?)
Otherwise I can try to give you more information about the issue, are there any flags I can use to debug directly in my IDE?
eleanorjboyd commentedon Aug 2, 2023
A sample repro would be extremely helpful! Just a folder with a python file (with the tests) then the .vscode folder (with the setttings.json) is what I should need. Thanks!
QuentinFchx commentedon Aug 3, 2023
I created https://github.com/QuentinFchx/pytestbug, can you tell me if that's working for you?
The interesting part is that on this repository the issue still occurs, but now only the first describe block is taken into account (and not only the last).
eleanorjboyd commentedon Oct 4, 2023
Sorry for the delay on this- trying to determine prioritization with the rewrite. Is this a regression on the new rewrite? If so I can get to this more quickly, if it has never worked then I might have to mark this as a feature request. Thanks
27 remaining items
Nathaniel-Reeves commentedon Feb 14, 2024
+1
dinzone commentedon Feb 14, 2024
+1
nkotzrenko commentedon Feb 14, 2024
+1
alexkubica commentedon Feb 15, 2024
+1 🙏
brettcannon commentedon Feb 22, 2024
Thank you to everyone who upvoted this issue! Since the community showed interest in this feature request we will leave this issue open as something to consider implementing at some point in the future.
We do encourage people to continue 👍 the first/opening comment as it helps us prioritize our work based on what the community seems to want the most.
add support for pytest describe (#24400)
eleanorjboyd commentedon Dec 2, 2024
Verification Steps:
DonJayamanne commentedon Dec 4, 2024
Eleanor Boyd (@eleanorjboyd) The steps provided by the user was already great enough, but no harm .
Works perfectly fine.