Skip to content

error and skipped tests show as never ran #21579

Description

@lmgarret

Type: Bug

Behaviour

Expected vs. Actual

The new pytest runner does not handle properly error raised in test setup/fixture evaluation, nor skipping tests. When an error is raised, it should show a red circle with a red dot inside for the failed test, but it show a grey dot instead. Note that the test is not FAILED but is in ERROR. The same applies for skipped test, the same icon isued

Steps to reproduce:

  1. Write the following test file:
import pytest


@pytest.fixture
def raise_fixture():
    raise Exception("Dummy exception")


class TestSomething:

    def test_a(self, raise_fixture):
        assert True
  1. Run the test, it should ERROR
  2. Check the test explorer which shows:
    image
    instead of (using old test runner):
    image

Diagnostic data

  • Python version (& distribution if applicable, e.g. Anaconda): 3.9.2
  • Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): Venv
  • 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

Multiroot scenario, following user settings may not apply:

languageServer: "Pylance"

formatting
• provider: "yapf"

experiments
• optInto: ["pythonTestAdapter"]

Extension version: 2023.12.0
VS Code version: Code 1.80.0 (660393deaaa6d1996740ff4880f1bad43768c814, 2023-07-04T13:39:48.236Z)
OS version: Linux x64 5.15.0-75-generic
Modes:
Remote OS version: Linux x64 5.15.0-75-generic

A/B Experiments
vsliv368:30146709
vsreu685:30147344
python383:30185418
vspor879:30202332
vspor708:30202333
vspor363:30204092
vslsvsres303:30308271
vserr242cf:30382550
pythontb:30283811
vsjup518:30340749
pythonptprofiler:30281270
vshan820:30294714
vstes263:30335439
vscod805:30301674
binariesv615:30325510
bridge0708:30335490
bridge0723:30353136
vsaa593cf:30376535
pythonvs932:30410667
py29gd2263:30776702
vscaat:30438848
vsclangdc:30486549
c4g48928:30535728
dsvsc012:30540252
pynewext54:30695312
azure-dev_surveyone:30548225
vsccc:30610678
2e4cg342:30602488
pyind779:30671433
89544117:30613380
pythonsymbol12:30671437
2i9eh265:30646982
showlangstatbar:30737416
vsctsb:30748421
pythonms35:30701012
03d35959:30757346
pythonfmttext:30731395
pythoncmvfstrcf:30756944
fixshowwlkth:30771522
hideindicator:30766889
pythongtdpath:30769146
bgfeh915:30780428
pythonnosmt12:30779714
pythonidxpt:30784022
pythonnoceb:30776495
e537b577:30772215

Activity

  1. added
    triage-needed
    on Jul 7, 2023
  2. changed the title [-]Error in test setup is shown as if test never ran[/-] on Jul 7, 2023
  3. eleanorjboyd commented on Jul 10, 2023

    @eleanorjboyd

    Thanks again for the help! I can repro and I am putting in a fix now. Thanks

  4. eleanorjboyd commented on Jul 10, 2023

    @eleanorjboyd

    Hi! This will be out on the insiders build of the python extension tomorrow. If you would like to try and let me know if it works that would be great! Thanks

  5. added
    info-needed
    on Jul 10, 2023
  6. lmgarret commented on Jul 11, 2023

    @lmgarret
    Author

    Thanks for the quick action! It seems to fix the issue:

    • when a test function is skipped (proper icon now)
    • when a test fails during setup/fixture execution (red circle with a cross). I wonder if we shouldn't have a red circle with a dot as it was before (cf screenshot in the issue) here instead, to indicate a FAILED rather than an ERROR. I guess it's up to you/MSFT. At least it's way better now!

    There still is a bugged case: if a test class is skipped, the icon stays as if the test never ran (same as described in the issue).

  7. removed
    info-needed
    on Jul 11, 2023
  8. eleanorjboyd commented on Jul 11, 2023

    @eleanorjboyd

    Ah yes thank you for the additional note- will look into that now

  9. eleanorjboyd commented on Jul 12, 2023

    @eleanorjboyd

    The second fix will be out tomorrow on the nightly release of the extension. I made it work for the following test case which should encompass your scenario. If you could test it tomorrow that would be great and generally appreciate all the help!

    # With this test, the entire class is skipped.
    @pytest.mark.skip(reason="Skip TestClass")
    class TestClass:
        def test_class_function_a(self):
            assert True
    
        def test_class_function_b(self): 
            assert False
    
    
  10. lmgarret commented on Jul 13, 2023

    @lmgarret
    Author

    Good to hear thanks! I'll test it next week since I'm currently off

  11. lmgarret commented on Jul 19, 2023

    @lmgarret
    Author

    Just tested the latest version and it did fix it, thanks

  12. added
    verified
    author-verification-requested
    and removed
    triage-needed
    on Jul 19, 2023
  13. locked as resolved and limited conversation to collaborators on Aug 19, 2023
  14. added 2 commits that reference this issue on Mar 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

area-testingauthor-verification-requestedverified

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions