Skip to content

Show unittest.subTest failures in the Test Explorer #15271

Closed as not planned
Closed as not planned

Description

@DolajoCZ

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

Activity

  1. jakebailey commented on Jan 29, 2021

    @jakebailey
    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.

  2. DolajoCZ commented on Jan 29, 2021

    @DolajoCZ
    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

  3. jakebailey commented on Jan 29, 2021

    @jakebailey
    Member

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

  4. ghost added
    triage-neededNeeds assignment to the proper sub-team
    on Jan 29, 2021
  5. changed the title [-]Support of unittest subTest[/-] [+]Show unittest.subTest failures in the Test Explorer[/+] on Feb 1, 2021
  6. ghost removed
    triage-neededNeeds assignment to the proper sub-team
    on Feb 1, 2021
  7. kimadeline commented on Feb 2, 2021

    @kimadeline

    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)
    
  8. added
    needs spikeLabel for issues that need investigation before they can be worked on.
    and removed on Feb 2, 2021
  9. DolajoCZ commented on Aug 11, 2021

    @DolajoCZ
    Author

    Any update?

  10. kimadeline commented on Aug 11, 2021

    @kimadeline

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

  11. DolajoCZ commented on Aug 11, 2021

    @DolajoCZ
    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 Kim-Adeline Miguel (@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)
  12. kimadeline commented on Aug 11, 2021

    @kimadeline

    We still haven't addressed it yet then.

  13. DolajoCZ commented on Aug 11, 2021

    @DolajoCZ
    Author

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

  14. kimadeline commented on Aug 11, 2021

    @kimadeline

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

  15. karrtikr commented on Dec 21, 2022

    @karrtikr

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

  16. locked as resolved and limited conversation to collaborators on Jan 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-testingbugIssue identified by VS Code Team member as probable bugneeds spikeLabel for issues that need investigation before they can be worked on.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions