Message352882
+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) |
|
Date |
User |
Action |
Args |
2019-09-20 19:18:32 | moormaster | set | recipients:
+ moormaster, terry.reedy, spiv, exarkun, ncoghlan, pitrou, ezio.melotti, eric.araujo, r.david.murray, michael.foord, hpk, fperez, chris.jerdonek, Yaroslav.Halchenko, santoso.wijaya, nchauvat, kynan, Julian, abingham, eric.snow, martin.panter, zach.ware, borja.ruiz, bfroehle, Miklós.Fazekas |
2019-09-20 19:18:32 | moormaster | set | messageid: <1569007112.64.0.317708621569.issue7897@roundup.psfhosted.org> |
2019-09-20 19:18:32 | moormaster | link | issue7897 messages |
2019-09-20 19:18:32 | moormaster | create | |
|