1.. _`tbreportdemo`:
2
3Demo of Python failure reports with pytest
4==========================================
5
6Here is a nice run of several failures and how ``pytest`` presents things:
7
8.. code-block:: pytest
9
10    assertion $ pytest failure_demo.py
11    =========================== test session starts ============================
12    platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-0.x.y
13    cachedir: $PYTHON_PREFIX/.pytest_cache
14    rootdir: $REGENDOC_TMPDIR/assertion
15    collected 44 items
16
17    failure_demo.py FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF         [100%]
18
19    ================================= FAILURES =================================
20    ___________________________ test_generative[3-6] ___________________________
21
22    param1 = 3, param2 = 6
23
24        @pytest.mark.parametrize("param1, param2", [(3, 6)])
25        def test_generative(param1, param2):
26    >       assert param1 * 2 < param2
27    E       assert (3 * 2) < 6
28
29    failure_demo.py:19: AssertionError
30    _________________________ TestFailing.test_simple __________________________
31
32    self = <failure_demo.TestFailing object at 0xdeadbeef>
33
34        def test_simple(self):
35            def f():
36                return 42
37
38            def g():
39                return 43
40
41    >       assert f() == g()
42    E       assert 42 == 43
43    E        +  where 42 = <function TestFailing.test_simple.<locals>.f at 0xdeadbeef>()
44    E        +  and   43 = <function TestFailing.test_simple.<locals>.g at 0xdeadbeef>()
45
46    failure_demo.py:30: AssertionError
47    ____________________ TestFailing.test_simple_multiline _____________________
48
49    self = <failure_demo.TestFailing object at 0xdeadbeef>
50
51        def test_simple_multiline(self):
52    >       otherfunc_multi(42, 6 * 9)
53
54    failure_demo.py:33:
55    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
56
57    a = 42, b = 54
58
59        def otherfunc_multi(a, b):
60    >       assert a == b
61    E       assert 42 == 54
62
63    failure_demo.py:14: AssertionError
64    ___________________________ TestFailing.test_not ___________________________
65
66    self = <failure_demo.TestFailing object at 0xdeadbeef>
67
68        def test_not(self):
69            def f():
70                return 42
71
72    >       assert not f()
73    E       assert not 42
74    E        +  where 42 = <function TestFailing.test_not.<locals>.f at 0xdeadbeef>()
75
76    failure_demo.py:39: AssertionError
77    _________________ TestSpecialisedExplanations.test_eq_text _________________
78
79    self = <failure_demo.TestSpecialisedExplanations object at 0xdeadbeef>
80
81        def test_eq_text(self):
82    >       assert "spam" == "eggs"
83    E       AssertionError: assert 'spam' == 'eggs'
84    E         - eggs
85    E         + spam
86
87    failure_demo.py:44: AssertionError
88    _____________ TestSpecialisedExplanations.test_eq_similar_text _____________
89
90    self = <failure_demo.TestSpecialisedExplanations object at 0xdeadbeef>
91
92        def test_eq_similar_text(self):
93    >       assert "foo 1 bar" == "foo 2 bar"
94    E       AssertionError: assert 'foo 1 bar' == 'foo 2 bar'
95    E         - foo 2 bar
96    E         ?     ^
97    E         + foo 1 bar
98    E         ?     ^
99
100    failure_demo.py:47: AssertionError
101    ____________ TestSpecialisedExplanations.test_eq_multiline_text ____________
102
103    self = <failure_demo.TestSpecialisedExplanations object at 0xdeadbeef>
104
105        def test_eq_multiline_text(self):
106    >       assert "foo\nspam\nbar" == "foo\neggs\nbar"
107    E       AssertionError: assert 'foo\nspam\nbar' == 'foo\neggs\nbar'
108    E           foo
109    E         - eggs
110    E         + spam
111    E           bar
112
113    failure_demo.py:50: AssertionError
114    ______________ TestSpecialisedExplanations.test_eq_long_text _______________
115
116    self = <failure_demo.TestSpecialisedExplanations object at 0xdeadbeef>
117
118        def test_eq_long_text(self):
119            a = "1" * 100 + "a" + "2" * 100
120            b = "1" * 100 + "b" + "2" * 100
121    >       assert a == b
122    E       AssertionError: assert '111111111111...2222222222222' == '111111111111...2222222222222'
123    E         Skipping 90 identical leading characters in diff, use -v to show
124    E         Skipping 91 identical trailing characters in diff, use -v to show
125    E         - 1111111111b222222222
126    E         ?           ^
127    E         + 1111111111a222222222
128    E         ?           ^
129
130    failure_demo.py:55: AssertionError
131    _________ TestSpecialisedExplanations.test_eq_long_text_multiline __________
132
133    self = <failure_demo.TestSpecialisedExplanations object at 0xdeadbeef>
134
135        def test_eq_long_text_multiline(self):
136            a = "1\n" * 100 + "a" + "2\n" * 100
137            b = "1\n" * 100 + "b" + "2\n" * 100
138    >       assert a == b
139    E       AssertionError: assert '1\n1\n1\n1\n...n2\n2\n2\n2\n' == '1\n1\n1\n1\n...n2\n2\n2\n2\n'
140    E         Skipping 190 identical leading characters in diff, use -v to show
141    E         Skipping 191 identical trailing characters in diff, use -v to show
142    E           1
143    E           1
144    E           1
145    E           1
146    E           1...
147    E
148    E         ...Full output truncated (7 lines hidden), use '-vv' to show
149
150    failure_demo.py:60: AssertionError
151    _________________ TestSpecialisedExplanations.test_eq_list _________________
152
153    self = <failure_demo.TestSpecialisedExplanations object at 0xdeadbeef>
154
155        def test_eq_list(self):
156    >       assert [0, 1, 2] == [0, 1, 3]
157    E       assert [0, 1, 2] == [0, 1, 3]
158    E         At index 2 diff: 2 != 3
159    E         Use -v to get the full diff
160
161    failure_demo.py:63: AssertionError
162    ______________ TestSpecialisedExplanations.test_eq_list_long _______________
163
164    self = <failure_demo.TestSpecialisedExplanations object at 0xdeadbeef>
165
166        def test_eq_list_long(self):
167            a = [0] * 100 + [1] + [3] * 100
168            b = [0] * 100 + [2] + [3] * 100
169    >       assert a == b
170    E       assert [0, 0, 0, 0, 0, 0, ...] == [0, 0, 0, 0, 0, 0, ...]
171    E         At index 100 diff: 1 != 2
172    E         Use -v to get the full diff
173
174    failure_demo.py:68: AssertionError
175    _________________ TestSpecialisedExplanations.test_eq_dict _________________
176
177    self = <failure_demo.TestSpecialisedExplanations object at 0xdeadbeef>
178
179        def test_eq_dict(self):
180    >       assert {"a": 0, "b": 1, "c": 0} == {"a": 0, "b": 2, "d": 0}
181    E       AssertionError: assert {'a': 0, 'b': 1, 'c': 0} == {'a': 0, 'b': 2, 'd': 0}
182    E         Omitting 1 identical items, use -vv to show
183    E         Differing items:
184    E         {'b': 1} != {'b': 2}
185    E         Left contains 1 more item:
186    E         {'c': 0}
187    E         Right contains 1 more item:
188    E         {'d': 0}...
189    E
190    E         ...Full output truncated (2 lines hidden), use '-vv' to show
191
192    failure_demo.py:71: AssertionError
193    _________________ TestSpecialisedExplanations.test_eq_set __________________
194
195    self = <failure_demo.TestSpecialisedExplanations object at 0xdeadbeef>
196
197        def test_eq_set(self):
198    >       assert {0, 10, 11, 12} == {0, 20, 21}
199    E       AssertionError: assert {0, 10, 11, 12} == {0, 20, 21}
200    E         Extra items in the left set:
201    E         10
202    E         11
203    E         12
204    E         Extra items in the right set:
205    E         20
206    E         21...
207    E
208    E         ...Full output truncated (2 lines hidden), use '-vv' to show
209
210    failure_demo.py:74: AssertionError
211    _____________ TestSpecialisedExplanations.test_eq_longer_list ______________
212
213    self = <failure_demo.TestSpecialisedExplanations object at 0xdeadbeef>
214
215        def test_eq_longer_list(self):
216    >       assert [1, 2] == [1, 2, 3]
217    E       assert [1, 2] == [1, 2, 3]
218    E         Right contains one more item: 3
219    E         Use -v to get the full diff
220
221    failure_demo.py:77: AssertionError
222    _________________ TestSpecialisedExplanations.test_in_list _________________
223
224    self = <failure_demo.TestSpecialisedExplanations object at 0xdeadbeef>
225
226        def test_in_list(self):
227    >       assert 1 in [0, 2, 3, 4, 5]
228    E       assert 1 in [0, 2, 3, 4, 5]
229
230    failure_demo.py:80: AssertionError
231    __________ TestSpecialisedExplanations.test_not_in_text_multiline __________
232
233    self = <failure_demo.TestSpecialisedExplanations object at 0xdeadbeef>
234
235        def test_not_in_text_multiline(self):
236            text = "some multiline\ntext\nwhich\nincludes foo\nand a\ntail"
237    >       assert "foo" not in text
238    E       AssertionError: assert 'foo' not in 'some multil...nand a\ntail'
239    E         'foo' is contained here:
240    E           some multiline
241    E           text
242    E           which
243    E           includes foo
244    E         ?          +++
245    E           and a...
246    E
247    E         ...Full output truncated (2 lines hidden), use '-vv' to show
248
249    failure_demo.py:84: AssertionError
250    ___________ TestSpecialisedExplanations.test_not_in_text_single ____________
251
252    self = <failure_demo.TestSpecialisedExplanations object at 0xdeadbeef>
253
254        def test_not_in_text_single(self):
255            text = "single foo line"
256    >       assert "foo" not in text
257    E       AssertionError: assert 'foo' not in 'single foo line'
258    E         'foo' is contained here:
259    E           single foo line
260    E         ?        +++
261
262    failure_demo.py:88: AssertionError
263    _________ TestSpecialisedExplanations.test_not_in_text_single_long _________
264
265    self = <failure_demo.TestSpecialisedExplanations object at 0xdeadbeef>
266
267        def test_not_in_text_single_long(self):
268            text = "head " * 50 + "foo " + "tail " * 20
269    >       assert "foo" not in text
270    E       AssertionError: assert 'foo' not in 'head head h...l tail tail '
271    E         'foo' is contained here:
272    E           head head foo tail tail tail tail tail tail tail tail tail tail tail tail tail tail tail tail tail tail tail tail
273    E         ?           +++
274
275    failure_demo.py:92: AssertionError
276    ______ TestSpecialisedExplanations.test_not_in_text_single_long_term _______
277
278    self = <failure_demo.TestSpecialisedExplanations object at 0xdeadbeef>
279
280        def test_not_in_text_single_long_term(self):
281            text = "head " * 50 + "f" * 70 + "tail " * 20
282    >       assert "f" * 70 not in text
283    E       AssertionError: assert 'fffffffffff...ffffffffffff' not in 'head head h...l tail tail '
284    E         'ffffffffffffffffff...fffffffffffffffffff' is contained here:
285    E           head head fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffftail tail tail tail tail tail tail tail tail tail tail tail tail tail tail tail tail tail tail tail
286    E         ?           ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
287
288    failure_demo.py:96: AssertionError
289    ______________ TestSpecialisedExplanations.test_eq_dataclass _______________
290
291    self = <failure_demo.TestSpecialisedExplanations object at 0xdeadbeef>
292
293        def test_eq_dataclass(self):
294            from dataclasses import dataclass
295
296            @dataclass
297            class Foo:
298                a: int
299                b: str
300
301            left = Foo(1, "b")
302            right = Foo(1, "c")
303    >       assert left == right
304    E       AssertionError: assert TestSpecialis...oo(a=1, b='b') == TestSpecialis...oo(a=1, b='c')
305    E
306    E         Omitting 1 identical items, use -vv to show
307    E         Differing attributes:
308    E         ['b']
309    E
310    E         Drill down into differing attribute b:
311    E           b: 'b' != 'c'...
312    E
313    E         ...Full output truncated (3 lines hidden), use '-vv' to show
314
315    failure_demo.py:108: AssertionError
316    ________________ TestSpecialisedExplanations.test_eq_attrs _________________
317
318    self = <failure_demo.TestSpecialisedExplanations object at 0xdeadbeef>
319
320        def test_eq_attrs(self):
321            import attr
322
323            @attr.s
324            class Foo:
325                a = attr.ib()
326                b = attr.ib()
327
328            left = Foo(1, "b")
329            right = Foo(1, "c")
330    >       assert left == right
331    E       AssertionError: assert Foo(a=1, b='b') == Foo(a=1, b='c')
332    E
333    E         Omitting 1 identical items, use -vv to show
334    E         Differing attributes:
335    E         ['b']
336    E
337    E         Drill down into differing attribute b:
338    E           b: 'b' != 'c'...
339    E
340    E         ...Full output truncated (3 lines hidden), use '-vv' to show
341
342    failure_demo.py:120: AssertionError
343    ______________________________ test_attribute ______________________________
344
345        def test_attribute():
346            class Foo:
347                b = 1
348
349            i = Foo()
350    >       assert i.b == 2
351    E       assert 1 == 2
352    E        +  where 1 = <failure_demo.test_attribute.<locals>.Foo object at 0xdeadbeef>.b
353
354    failure_demo.py:128: AssertionError
355    _________________________ test_attribute_instance __________________________
356
357        def test_attribute_instance():
358            class Foo:
359                b = 1
360
361    >       assert Foo().b == 2
362    E       AssertionError: assert 1 == 2
363    E        +  where 1 = <failure_demo.test_attribute_instance.<locals>.Foo object at 0xdeadbeef>.b
364    E        +    where <failure_demo.test_attribute_instance.<locals>.Foo object at 0xdeadbeef> = <class 'failure_demo.test_attribute_instance.<locals>.Foo'>()
365
366    failure_demo.py:135: AssertionError
367    __________________________ test_attribute_failure __________________________
368
369        def test_attribute_failure():
370            class Foo:
371                def _get_b(self):
372                    raise Exception("Failed to get attrib")
373
374                b = property(_get_b)
375
376            i = Foo()
377    >       assert i.b == 2
378
379    failure_demo.py:146:
380    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
381
382    self = <failure_demo.test_attribute_failure.<locals>.Foo object at 0xdeadbeef>
383
384        def _get_b(self):
385    >       raise Exception("Failed to get attrib")
386    E       Exception: Failed to get attrib
387
388    failure_demo.py:141: Exception
389    _________________________ test_attribute_multiple __________________________
390
391        def test_attribute_multiple():
392            class Foo:
393                b = 1
394
395            class Bar:
396                b = 2
397
398    >       assert Foo().b == Bar().b
399    E       AssertionError: assert 1 == 2
400    E        +  where 1 = <failure_demo.test_attribute_multiple.<locals>.Foo object at 0xdeadbeef>.b
401    E        +    where <failure_demo.test_attribute_multiple.<locals>.Foo object at 0xdeadbeef> = <class 'failure_demo.test_attribute_multiple.<locals>.Foo'>()
402    E        +  and   2 = <failure_demo.test_attribute_multiple.<locals>.Bar object at 0xdeadbeef>.b
403    E        +    where <failure_demo.test_attribute_multiple.<locals>.Bar object at 0xdeadbeef> = <class 'failure_demo.test_attribute_multiple.<locals>.Bar'>()
404
405    failure_demo.py:156: AssertionError
406    __________________________ TestRaises.test_raises __________________________
407
408    self = <failure_demo.TestRaises object at 0xdeadbeef>
409
410        def test_raises(self):
411            s = "qwe"
412    >       raises(TypeError, int, s)
413    E       ValueError: invalid literal for int() with base 10: 'qwe'
414
415    failure_demo.py:166: ValueError
416    ______________________ TestRaises.test_raises_doesnt _______________________
417
418    self = <failure_demo.TestRaises object at 0xdeadbeef>
419
420        def test_raises_doesnt(self):
421    >       raises(OSError, int, "3")
422    E       Failed: DID NOT RAISE <class 'OSError'>
423
424    failure_demo.py:169: Failed
425    __________________________ TestRaises.test_raise ___________________________
426
427    self = <failure_demo.TestRaises object at 0xdeadbeef>
428
429        def test_raise(self):
430    >       raise ValueError("demo error")
431    E       ValueError: demo error
432
433    failure_demo.py:172: ValueError
434    ________________________ TestRaises.test_tupleerror ________________________
435
436    self = <failure_demo.TestRaises object at 0xdeadbeef>
437
438        def test_tupleerror(self):
439    >       a, b = [1]  # NOQA
440    E       ValueError: not enough values to unpack (expected 2, got 1)
441
442    failure_demo.py:175: ValueError
443    ______ TestRaises.test_reinterpret_fails_with_print_for_the_fun_of_it ______
444
445    self = <failure_demo.TestRaises object at 0xdeadbeef>
446
447        def test_reinterpret_fails_with_print_for_the_fun_of_it(self):
448            items = [1, 2, 3]
449            print("items is {!r}".format(items))
450    >       a, b = items.pop()
451    E       TypeError: cannot unpack non-iterable int object
452
453    failure_demo.py:180: TypeError
454    --------------------------- Captured stdout call ---------------------------
455    items is [1, 2, 3]
456    ________________________ TestRaises.test_some_error ________________________
457
458    self = <failure_demo.TestRaises object at 0xdeadbeef>
459
460        def test_some_error(self):
461    >       if namenotexi:  # NOQA
462    E       NameError: name 'namenotexi' is not defined
463
464    failure_demo.py:183: NameError
465    ____________________ test_dynamic_compile_shows_nicely _____________________
466
467        def test_dynamic_compile_shows_nicely():
468            import importlib.util
469            import sys
470
471            src = "def foo():\n assert 1 == 0\n"
472            name = "abc-123"
473            spec = importlib.util.spec_from_loader(name, loader=None)
474            module = importlib.util.module_from_spec(spec)
475            code = compile(src, name, "exec")
476            exec(code, module.__dict__)
477            sys.modules[name] = module
478    >       module.foo()
479
480    failure_demo.py:202:
481    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
482
483    >   ???
484    E   AssertionError
485
486    abc-123:2: AssertionError
487    ____________________ TestMoreErrors.test_complex_error _____________________
488
489    self = <failure_demo.TestMoreErrors object at 0xdeadbeef>
490
491        def test_complex_error(self):
492            def f():
493                return 44
494
495            def g():
496                return 43
497
498    >       somefunc(f(), g())
499
500    failure_demo.py:213:
501    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
502    failure_demo.py:10: in somefunc
503        otherfunc(x, y)
504    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
505
506    a = 44, b = 43
507
508        def otherfunc(a, b):
509    >       assert a == b
510    E       assert 44 == 43
511
512    failure_demo.py:6: AssertionError
513    ___________________ TestMoreErrors.test_z1_unpack_error ____________________
514
515    self = <failure_demo.TestMoreErrors object at 0xdeadbeef>
516
517        def test_z1_unpack_error(self):
518            items = []
519    >       a, b = items
520    E       ValueError: not enough values to unpack (expected 2, got 0)
521
522    failure_demo.py:217: ValueError
523    ____________________ TestMoreErrors.test_z2_type_error _____________________
524
525    self = <failure_demo.TestMoreErrors object at 0xdeadbeef>
526
527        def test_z2_type_error(self):
528            items = 3
529    >       a, b = items
530    E       TypeError: cannot unpack non-iterable int object
531
532    failure_demo.py:221: TypeError
533    ______________________ TestMoreErrors.test_startswith ______________________
534
535    self = <failure_demo.TestMoreErrors object at 0xdeadbeef>
536
537        def test_startswith(self):
538            s = "123"
539            g = "456"
540    >       assert s.startswith(g)
541    E       AssertionError: assert False
542    E        +  where False = <built-in method startswith of str object at 0xdeadbeef>('456')
543    E        +    where <built-in method startswith of str object at 0xdeadbeef> = '123'.startswith
544
545    failure_demo.py:226: AssertionError
546    __________________ TestMoreErrors.test_startswith_nested ___________________
547
548    self = <failure_demo.TestMoreErrors object at 0xdeadbeef>
549
550        def test_startswith_nested(self):
551            def f():
552                return "123"
553
554            def g():
555                return "456"
556
557    >       assert f().startswith(g())
558    E       AssertionError: assert False
559    E        +  where False = <built-in method startswith of str object at 0xdeadbeef>('456')
560    E        +    where <built-in method startswith of str object at 0xdeadbeef> = '123'.startswith
561    E        +      where '123' = <function TestMoreErrors.test_startswith_nested.<locals>.f at 0xdeadbeef>()
562    E        +    and   '456' = <function TestMoreErrors.test_startswith_nested.<locals>.g at 0xdeadbeef>()
563
564    failure_demo.py:235: AssertionError
565    _____________________ TestMoreErrors.test_global_func ______________________
566
567    self = <failure_demo.TestMoreErrors object at 0xdeadbeef>
568
569        def test_global_func(self):
570    >       assert isinstance(globf(42), float)
571    E       assert False
572    E        +  where False = isinstance(43, float)
573    E        +    where 43 = globf(42)
574
575    failure_demo.py:238: AssertionError
576    _______________________ TestMoreErrors.test_instance _______________________
577
578    self = <failure_demo.TestMoreErrors object at 0xdeadbeef>
579
580        def test_instance(self):
581            self.x = 6 * 7
582    >       assert self.x != 42
583    E       assert 42 != 42
584    E        +  where 42 = <failure_demo.TestMoreErrors object at 0xdeadbeef>.x
585
586    failure_demo.py:242: AssertionError
587    _______________________ TestMoreErrors.test_compare ________________________
588
589    self = <failure_demo.TestMoreErrors object at 0xdeadbeef>
590
591        def test_compare(self):
592    >       assert globf(10) < 5
593    E       assert 11 < 5
594    E        +  where 11 = globf(10)
595
596    failure_demo.py:245: AssertionError
597    _____________________ TestMoreErrors.test_try_finally ______________________
598
599    self = <failure_demo.TestMoreErrors object at 0xdeadbeef>
600
601        def test_try_finally(self):
602            x = 1
603            try:
604    >           assert x == 0
605    E           assert 1 == 0
606
607    failure_demo.py:250: AssertionError
608    ___________________ TestCustomAssertMsg.test_single_line ___________________
609
610    self = <failure_demo.TestCustomAssertMsg object at 0xdeadbeef>
611
612        def test_single_line(self):
613            class A:
614                a = 1
615
616            b = 2
617    >       assert A.a == b, "A.a appears not to be b"
618    E       AssertionError: A.a appears not to be b
619    E       assert 1 == 2
620    E        +  where 1 = <class 'failure_demo.TestCustomAssertMsg.test_single_line.<locals>.A'>.a
621
622    failure_demo.py:261: AssertionError
623    ____________________ TestCustomAssertMsg.test_multiline ____________________
624
625    self = <failure_demo.TestCustomAssertMsg object at 0xdeadbeef>
626
627        def test_multiline(self):
628            class A:
629                a = 1
630
631            b = 2
632    >       assert (
633                A.a == b
634            ), "A.a appears not to be b\nor does not appear to be b\none of those"
635    E       AssertionError: A.a appears not to be b
636    E         or does not appear to be b
637    E         one of those
638    E       assert 1 == 2
639    E        +  where 1 = <class 'failure_demo.TestCustomAssertMsg.test_multiline.<locals>.A'>.a
640
641    failure_demo.py:268: AssertionError
642    ___________________ TestCustomAssertMsg.test_custom_repr ___________________
643
644    self = <failure_demo.TestCustomAssertMsg object at 0xdeadbeef>
645
646        def test_custom_repr(self):
647            class JSON:
648                a = 1
649
650                def __repr__(self):
651                    return "This is JSON\n{\n  'foo': 'bar'\n}"
652
653            a = JSON()
654            b = 2
655    >       assert a.a == b, a
656    E       AssertionError: This is JSON
657    E         {
658    E           'foo': 'bar'
659    E         }
660    E       assert 1 == 2
661    E        +  where 1 = This is JSON\n{\n  'foo': 'bar'\n}.a
662
663    failure_demo.py:281: AssertionError
664    ========================= short test summary info ==========================
665    FAILED failure_demo.py::test_generative[3-6] - assert (3 * 2) < 6
666    FAILED failure_demo.py::TestFailing::test_simple - assert 42 == 43
667    FAILED failure_demo.py::TestFailing::test_simple_multiline - assert 42 == 54
668    FAILED failure_demo.py::TestFailing::test_not - assert not 42
669    FAILED failure_demo.py::TestSpecialisedExplanations::test_eq_text - Asser...
670    FAILED failure_demo.py::TestSpecialisedExplanations::test_eq_similar_text
671    FAILED failure_demo.py::TestSpecialisedExplanations::test_eq_multiline_text
672    FAILED failure_demo.py::TestSpecialisedExplanations::test_eq_long_text - ...
673    FAILED failure_demo.py::TestSpecialisedExplanations::test_eq_long_text_multiline
674    FAILED failure_demo.py::TestSpecialisedExplanations::test_eq_list - asser...
675    FAILED failure_demo.py::TestSpecialisedExplanations::test_eq_list_long - ...
676    FAILED failure_demo.py::TestSpecialisedExplanations::test_eq_dict - Asser...
677    FAILED failure_demo.py::TestSpecialisedExplanations::test_eq_set - Assert...
678    FAILED failure_demo.py::TestSpecialisedExplanations::test_eq_longer_list
679    FAILED failure_demo.py::TestSpecialisedExplanations::test_in_list - asser...
680    FAILED failure_demo.py::TestSpecialisedExplanations::test_not_in_text_multiline
681    FAILED failure_demo.py::TestSpecialisedExplanations::test_not_in_text_single
682    FAILED failure_demo.py::TestSpecialisedExplanations::test_not_in_text_single_long
683    FAILED failure_demo.py::TestSpecialisedExplanations::test_not_in_text_single_long_term
684    FAILED failure_demo.py::TestSpecialisedExplanations::test_eq_dataclass - ...
685    FAILED failure_demo.py::TestSpecialisedExplanations::test_eq_attrs - Asse...
686    FAILED failure_demo.py::test_attribute - assert 1 == 2
687    FAILED failure_demo.py::test_attribute_instance - AssertionError: assert ...
688    FAILED failure_demo.py::test_attribute_failure - Exception: Failed to get...
689    FAILED failure_demo.py::test_attribute_multiple - AssertionError: assert ...
690    FAILED failure_demo.py::TestRaises::test_raises - ValueError: invalid lit...
691    FAILED failure_demo.py::TestRaises::test_raises_doesnt - Failed: DID NOT ...
692    FAILED failure_demo.py::TestRaises::test_raise - ValueError: demo error
693    FAILED failure_demo.py::TestRaises::test_tupleerror - ValueError: not eno...
694    FAILED failure_demo.py::TestRaises::test_reinterpret_fails_with_print_for_the_fun_of_it
695    FAILED failure_demo.py::TestRaises::test_some_error - NameError: name 'na...
696    FAILED failure_demo.py::test_dynamic_compile_shows_nicely - AssertionError
697    FAILED failure_demo.py::TestMoreErrors::test_complex_error - assert 44 == 43
698    FAILED failure_demo.py::TestMoreErrors::test_z1_unpack_error - ValueError...
699    FAILED failure_demo.py::TestMoreErrors::test_z2_type_error - TypeError: c...
700    FAILED failure_demo.py::TestMoreErrors::test_startswith - AssertionError:...
701    FAILED failure_demo.py::TestMoreErrors::test_startswith_nested - Assertio...
702    FAILED failure_demo.py::TestMoreErrors::test_global_func - assert False
703    FAILED failure_demo.py::TestMoreErrors::test_instance - assert 42 != 42
704    FAILED failure_demo.py::TestMoreErrors::test_compare - assert 11 < 5
705    FAILED failure_demo.py::TestMoreErrors::test_try_finally - assert 1 == 0
706    FAILED failure_demo.py::TestCustomAssertMsg::test_single_line - Assertion...
707    FAILED failure_demo.py::TestCustomAssertMsg::test_multiline - AssertionEr...
708    FAILED failure_demo.py::TestCustomAssertMsg::test_custom_repr - Assertion...
709    ============================ 44 failed in 0.12s ============================
710