[Python-ideas] Unittest error message failure context lazy creation
Chris Angelico
rosuav at gmail.com
Sat Aug 26 22:03:57 EDT 2017
On Sun, Aug 27, 2017 at 4:25 AM, francismb <francismb at email.de> wrote:
> Hi all,
> while using `unittest` I see the pattern of creating an error message
> with the test context for the case that some `assert...` methods fails
> (to get a good error message). On the lines:
>
> class Test...(unittest.TestCase):
>
> longMessage = True
>
> def test_(self):
> ...
> for a, b, c ... in zip(A, B, C, ..):
> * call the function under test and get the result
> msg = "Some headline: {}{} ...".format(a, b, c,..)
> self.assert...( ,msg)
>
> The `msg` is just used in case the assert fails but its creation takes
> time and adds up.
Have you measured it, eg by replacing the message with a constant? By
what percentage does it speed up a successful test run?
ChrisA
More information about the Python-ideas
mailing list