Robert Collins has backported one of my favourite Python 3 features to
unittest2: subtests!
See the Python 3 docs [1] for details, but the basic idea is to let you
easily split up a data driven test such that:
1. All iterations execute, even if some of the checks fail
2. Each failure is reported separately, with relevant details you provide
For example:
===================
class NumbersTest(unittest.TestCase):
def test_even(self):
"""
Test that numbers between 0 and 5 are all even.
"""
for i in range(0, 6):
with self.subTest(i=i):
self.assertEqual(i % 2, 0)
===================
Will check all values from 0 to 5, and report separate failures for 1, 3
and 5.
The only other particular notable new feature is the addition of the
"assertLogs" context manager to test cases, which makes it easier to
check logging within the current process is performed correctly as part
of unit tests.
Cheers,
Nick.
[1]
https://docs.python.org/3/library/unittest.html#distinguishing-test-itera...
--
Nick Coghlan
Red Hat Hosted & Shared Services
Software Engineering & Development, Brisbane
HSS Provisioning Architect