test: use TestCase.subTest for more verbose error messages

This commit is contained in:
Jędrzej Boczar 2020-03-25 12:32:36 +01:00
parent b06e946d09
commit a1b1abe329
2 changed files with 17 additions and 10 deletions

View File

@ -63,8 +63,9 @@ class TestRefresh(unittest.TestCase):
self.assertEqual(dut.errors, 0)
def test_refresh_timer(self):
for i in range(1, 32):
self.refresh_timer_test(i)
for trefi in range(1, 32):
with self.subTest(trefi=trefi):
self.refresh_timer_test(trefi)
def refresher_test(self, postponing):
class Obj: pass
@ -104,5 +105,6 @@ class TestRefresh(unittest.TestCase):
self.assertEqual(dut.errors, 0)
def test_refresher(self):
for i in [1, 2, 4, 8]:
self.refresher_test(postponing=i)
for postponing in [1, 2, 4, 8]:
with self.subTest(postponing=postponing):
self.refresher_test(postponing)

View File

@ -75,8 +75,9 @@ class TestTiming(unittest.TestCase):
self.assertEqual(min(dut.ready_gaps), txxd)
def test_txxd_controller_random(self):
for i in range(2, 32):
self.txxd_controller_random_test(i, 512)
for txxd in range(2, 32):
with self.subTest(txxd=txxd):
self.txxd_controller_random_test(txxd, 512)
def tfaw_controller_test(self, txxd, valids, readys):
@ -96,19 +97,23 @@ class TestTiming(unittest.TestCase):
tfaw = 8
valids = "_----___________"
readys = "-----______-----"
self.tfaw_controller_test(tfaw, valids, readys)
with self.subTest(tfaw=tfaw, valids=valids, readys=readys):
self.tfaw_controller_test(tfaw, valids, readys)
tfaw = 8
valids = "_-_-_-_-________"
readys = "--------___-----"
self.tfaw_controller_test(tfaw, valids, readys)
with self.subTest(tfaw=tfaw, valids=valids, readys=readys):
self.tfaw_controller_test(tfaw, valids, readys)
tfaw = 8
valids = "_-_-___-_-______"
readys = "----------_-----"
self.tfaw_controller_test(tfaw, valids, readys)
with self.subTest(tfaw=tfaw, valids=valids, readys=readys):
self.tfaw_controller_test(tfaw, valids, readys)
tfaw = 8
valids = "_-_-____-_-______"
readys = "-----------------"
self.tfaw_controller_test(tfaw, valids, readys)
with self.subTest(tfaw=tfaw, valids=valids, readys=readys):
self.tfaw_controller_test(tfaw, valids, readys)