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

Show unittest.subTest failures in the Test Explorer #15271

Closed
DolajoCZ opened this issue Jan 29, 2021 · 11 comments
Closed

Show unittest.subTest failures in the Test Explorer #15271

DolajoCZ opened this issue Jan 29, 2021 · 11 comments
Labels
area-testing bug Issue identified by VS Code Team member as probable bug needs spike Label for issues that need investigation before they can be worked on.

Comments

@DolajoCZ
Copy link

Hello, can you please add support of unittest subTest. Thank you

@jakebailey
Copy link
Member

Can you describe what it is about this function that isn't working correctly? At first glance, I don't know what might be broken (and we get unittest stubs from the typeshed project). A code example would be helpful.

@DolajoCZ
Copy link
Author

If I use code from picture below, status of test is unknown (left top corner) although it should fail as it is shown on next image - result from command line.

image

image

If I use code without subTest everything is ok - test fail.

image

@jakebailey
Copy link
Member

Oh, this isn't a Pylance thing, this is the text explorer in the Python extension. I'll transfer it.

@jakebailey jakebailey transferred this issue from microsoft/pylance-release Jan 29, 2021
@ghost ghost added the triage-needed Needs assignment to the proper sub-team label Jan 29, 2021
@brettcannon brettcannon changed the title Support of unittest subTest Show unittest.subTest failures in the Test Explorer Feb 1, 2021
@brettcannon brettcannon added area-testing reason-preexisting bug Issue identified by VS Code Team member as probable bug labels Feb 1, 2021
@ghost ghost removed the triage-needed Needs assignment to the proper sub-team label Feb 1, 2021
@karthiknadig karthiknadig added triage-needed Needs assignment to the proper sub-team area-testing and removed area-testing reason-preexisting triage-needed Needs assignment to the proper sub-team labels Feb 1, 2021
@kimadeline
Copy link

Hi @DolajoCZ,

Thank you for reaching out! I can confirm that this issue hasn't been introduced recently, I could reproduce it using Python 3.9.0 and the following versions of the extension:

  • 2021.1.502429796
  • 2020.12.424452561
  • 2020.11.371526539

We'll have to investigate it.


Notes:

  1. When running tests using the subtest feature, a "No tests were ran" notification appears:

image

  1. the output is slightly different when having tests that don't use subtests, especially the Content part:

successful tests:

test (test_file.test)
Content ... ok

----------------------------------------------------------------------
Ran 1 test in 0.000s

OK

failing tests:

test (test_file.test)
Content ... FAIL
NoneType: None

======================================================================
FAIL: test (test_file.test)
Content
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/kimiguel/Documents/Sandbox/unittest-subtest/test_file.py", line 13, in test
    self.assertEqual(i % 2, 0)
AssertionError: 1 != 0

----------------------------------------------------------------------
Ran 1 test in 0.002s

FAILED (failures=1)

failing tests with subtests:

test (test_file.test)
Content ... 
======================================================================
FAIL: test (test_file.test) (i=1)
Content
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/kimiguel/Documents/Sandbox/unittest-subtest/test_file.py", line 13, in test
    self.assertEqual(i % 2, 0)
AssertionError: 1 != 0

======================================================================
FAIL: test (test_file.test) (i=3)
Content
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/kimiguel/Documents/Sandbox/unittest-subtest/test_file.py", line 13, in test
    self.assertEqual(i % 2, 0)
AssertionError: 1 != 0

======================================================================
FAIL: test (test_file.test) (i=5)
Content
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/kimiguel/Documents/Sandbox/unittest-subtest/test_file.py", line 13, in test
    self.assertEqual(i % 2, 0)
AssertionError: 1 != 0

----------------------------------------------------------------------
Ran 1 test in 0.001s

FAILED (failures=3)

@kimadeline kimadeline added needs spike Label for issues that need investigation before they can be worked on. and removed triage labels Feb 2, 2021
@kimadeline kimadeline removed their assignment Feb 2, 2021
@DolajoCZ
Copy link
Author

Any update?

@kimadeline
Copy link

We made some testing-related changes in the latest version of the extension, is it still not working? #16769

@DolajoCZ
Copy link
Author

Unfortunatelly not. I used example bellow but without succes. My version of Python extension is 2021.8.1105858891 and Python in version 3.9.2. Can you please share with me working code and potential additonal setting if necessary? Thank you @kimadeline

"""Test module."""
import unittest


class TestSbTest(unittest.TestCase):
    """Unittest"""

    def test_fail_case(self) -> None:
        """Test fail case."""
        for i in range(6):
            with self.subTest(i=i):
                self.assertEqual(i % 2, 0)

            # self.assertEqual(i % 2, 0)

@kimadeline
Copy link

We still haven't addressed it yet then.

@DolajoCZ
Copy link
Author

Sorry, I misinterpreted your comment. I thought that this fix was already released.

@kimadeline
Copy link

Sorry for the confusion! This will be addressed as part of #16936.

@karrtikr
Copy link

Closing in favor of #16936 where we'll keep this issue in mind while fixing.

@karrtikr karrtikr closed this as not planned Won't fix, can't repro, duplicate, stale Dec 21, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 21, 2023
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 needs spike Label for issues that need investigation before they can be worked on.
Projects
None yet
Development

No branches or pull requests

6 participants