pytest-sugar icon indicating copy to clipboard operation
pytest-sugar copied to clipboard

Integration with pytest-subtests

Open C0DK opened this issue 5 years ago • 4 comments
trafficstars

When using pytest-subtests and pytest-sugar, the actual subtest name is not reported in the results.

example:

import unittest


class T(unittest.TestCase):
    def test_foo(self):
        for i in range(5):
            with self.subTest("custom message", i=i):
                self.assertEqual(i % 2, 0)


if __name__ == "__main__":
    unittest.main()

output

Test session starts (platform: linux, Python 3.8.3, pytest 5.4.3, pytest-sugar 0.9.4)
rootdir: /home/cdk/dev/expecthon
plugins: django-3.9.0, sugar-0.9.4, cov-2.10.0, black-0.3.10, subtests-0.3.2
 bla.py ⨯✓                                                                              100% ██████████
======================================= short test summary info =======================================
FAILED bla.py::T::test_foo - AssertionError: 1 != 0
FAILED bla.py::T::test_foo - AssertionError: 1 != 0

Results (0.13s):
       1 passed
       2 failed
         - bla.py:5 T.test_foo
         - bla.py:5 T.test_foo

Expected output

Test session starts (platform: linux, Python 3.8.3, pytest 5.4.3, pytest-sugar 0.9.4)
rootdir: /home/cdk/dev/expecthon
plugins: django-3.9.0, sugar-0.9.4, cov-2.10.0, black-0.3.10, subtests-0.3.2
 bla.py ⨯✓                                                                              100% ██████████
======================================= short test summary info =======================================
FAILED bla.py::T::test_foo (custom message, i=1) - AssertionError: 1 != 0
FAILED bla.py::T::test_foo (custom message, i=3) - AssertionError: 1 != 0

Results (0.13s):
       1 passed
       2 failed
         - bla.py:5 T.test_foo
           - (custom message, i=1)
           - (custom message, i=3)

C0DK avatar Aug 10 '20 08:08 C0DK

Maybe you could try --old-summary as a fallback

Teemu avatar Aug 25 '20 17:08 Teemu

Can i do something regarding the PR? @Teemu

C0DK avatar Oct 21 '20 17:10 C0DK

I just need to do general maintenance on this project first

Teemu avatar Oct 21 '20 20:10 Teemu

Alright. Say the word if you need help.

C0DK avatar Oct 21 '20 20:10 C0DK