Andre Herbst <moormas...@gmx.net> added the comment:

+1 for the feature

Subtests make the test results of all asserts visible at test execution time 
but decrease the readability of a test:

@parameterized([2,4,6])
def test_method_whenCalled_returnsNone(self, a):
    # 1) arrange
    something = Something()

    # 2) act
    result = something.method(a)

    # 3) assert
    self.assertIsNone(result)

When using subtests the phases of 1) arrange, 2) act, 3) assert are not clearly 
separated, the unit test contains logic and two additional indentation levels 
that could be avoided with parameterized tests:

def test_method_whenCalled_returnsNone(self, a):
    # 1) arrange
    something = Something()

    for a in [2,4,6]:
        with self.subTest(a=a):
            # 2) act
            result = something.method(a)

            # 3) assert
            self.assertIsNone(result)

----------
nosy: +moormaster

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue7897>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to