2010-11-25 19:11:10 +08:00
|
|
|
.. _`tbreportdemo`:
|
2014-01-18 19:31:33 +08:00
|
|
|
|
|
|
|
Demo of Python failure reports with pytest
|
2019-04-11 17:38:55 +08:00
|
|
|
==========================================
|
2010-11-25 19:11:10 +08:00
|
|
|
|
2019-04-11 17:38:55 +08:00
|
|
|
Here is a nice run of several failures and how ``pytest`` presents things:
|
2018-11-24 13:41:22 +08:00
|
|
|
|
|
|
|
.. code-block:: pytest
|
2010-11-26 03:06:42 +08:00
|
|
|
|
2016-09-01 08:30:06 +08:00
|
|
|
assertion $ pytest failure_demo.py
|
2019-01-06 03:19:40 +08:00
|
|
|
=========================== test session starts ============================
|
2024-01-02 16:58:20 +08:00
|
|
|
platform linux -- Python 3.x.y, pytest-8.x.y, pluggy-1.x.y
|
2021-10-04 14:56:26 +08:00
|
|
|
rootdir: /home/sweet/project/assertion
|
2019-01-05 23:21:49 +08:00
|
|
|
collected 44 items
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2019-01-06 03:19:40 +08:00
|
|
|
failure_demo.py FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF [100%]
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2019-01-06 03:19:40 +08:00
|
|
|
================================= FAILURES =================================
|
|
|
|
___________________________ test_generative[3-6] ___________________________
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2010-11-25 19:11:10 +08:00
|
|
|
param1 = 3, param2 = 6
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2018-11-14 05:01:51 +08:00
|
|
|
@pytest.mark.parametrize("param1, param2", [(3, 6)])
|
2010-11-25 19:11:10 +08:00
|
|
|
def test_generative(param1, param2):
|
|
|
|
> assert param1 * 2 < param2
|
|
|
|
E assert (3 * 2) < 6
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2020-07-09 05:51:01 +08:00
|
|
|
failure_demo.py:19: AssertionError
|
2019-01-06 03:19:40 +08:00
|
|
|
_________________________ TestFailing.test_simple __________________________
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2021-10-04 14:56:26 +08:00
|
|
|
self = <failure_demo.TestFailing object at 0xdeadbeef0001>
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2010-11-25 19:11:10 +08:00
|
|
|
def test_simple(self):
|
|
|
|
def f():
|
|
|
|
return 42
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2010-11-25 19:11:10 +08:00
|
|
|
def g():
|
|
|
|
return 43
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2010-11-25 19:11:10 +08:00
|
|
|
> assert f() == g()
|
|
|
|
E assert 42 == 43
|
2021-10-04 14:56:26 +08:00
|
|
|
E + where 42 = <function TestFailing.test_simple.<locals>.f at 0xdeadbeef0002>()
|
|
|
|
E + and 43 = <function TestFailing.test_simple.<locals>.g at 0xdeadbeef0003>()
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2020-07-09 05:51:01 +08:00
|
|
|
failure_demo.py:30: AssertionError
|
2019-01-06 03:19:40 +08:00
|
|
|
____________________ TestFailing.test_simple_multiline _____________________
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2021-10-04 14:56:26 +08:00
|
|
|
self = <failure_demo.TestFailing object at 0xdeadbeef0004>
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2010-11-25 19:11:10 +08:00
|
|
|
def test_simple_multiline(self):
|
2018-06-05 09:11:27 +08:00
|
|
|
> otherfunc_multi(42, 6 * 9)
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2020-07-09 05:51:01 +08:00
|
|
|
failure_demo.py:33:
|
2019-01-06 03:19:40 +08:00
|
|
|
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2010-11-25 19:11:10 +08:00
|
|
|
a = 42, b = 54
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2018-06-05 09:11:27 +08:00
|
|
|
def otherfunc_multi(a, b):
|
|
|
|
> assert a == b
|
2010-11-25 19:11:10 +08:00
|
|
|
E assert 42 == 54
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2020-07-09 05:51:01 +08:00
|
|
|
failure_demo.py:14: AssertionError
|
2019-01-06 03:19:40 +08:00
|
|
|
___________________________ TestFailing.test_not ___________________________
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2021-10-04 14:56:26 +08:00
|
|
|
self = <failure_demo.TestFailing object at 0xdeadbeef0005>
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2010-11-25 19:11:10 +08:00
|
|
|
def test_not(self):
|
|
|
|
def f():
|
|
|
|
return 42
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2010-11-25 19:11:10 +08:00
|
|
|
> assert not f()
|
|
|
|
E assert not 42
|
2023-04-09 05:49:26 +08:00
|
|
|
E + where 42 = <function TestFailing.test_not.<locals>.f at 0xdeadbeef0006>()
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2020-07-09 05:51:01 +08:00
|
|
|
failure_demo.py:39: AssertionError
|
2019-01-06 03:19:40 +08:00
|
|
|
_________________ TestSpecialisedExplanations.test_eq_text _________________
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2023-04-09 05:49:26 +08:00
|
|
|
self = <failure_demo.TestSpecialisedExplanations object at 0xdeadbeef0007>
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2010-11-25 19:11:10 +08:00
|
|
|
def test_eq_text(self):
|
2018-06-05 09:11:27 +08:00
|
|
|
> assert "spam" == "eggs"
|
2017-03-14 06:41:20 +08:00
|
|
|
E AssertionError: assert 'spam' == 'eggs'
|
2024-01-02 16:58:20 +08:00
|
|
|
E
|
2020-02-04 21:38:18 +08:00
|
|
|
E - eggs
|
|
|
|
E + spam
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2020-07-09 05:51:01 +08:00
|
|
|
failure_demo.py:44: AssertionError
|
2019-01-06 03:19:40 +08:00
|
|
|
_____________ TestSpecialisedExplanations.test_eq_similar_text _____________
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2023-04-09 05:49:26 +08:00
|
|
|
self = <failure_demo.TestSpecialisedExplanations object at 0xdeadbeef0008>
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2010-11-25 19:11:10 +08:00
|
|
|
def test_eq_similar_text(self):
|
2018-06-05 09:11:27 +08:00
|
|
|
> assert "foo 1 bar" == "foo 2 bar"
|
2017-03-14 06:41:20 +08:00
|
|
|
E AssertionError: assert 'foo 1 bar' == 'foo 2 bar'
|
2024-01-02 16:58:20 +08:00
|
|
|
E
|
2020-02-04 21:38:18 +08:00
|
|
|
E - foo 2 bar
|
2010-11-25 19:11:10 +08:00
|
|
|
E ? ^
|
2020-02-04 21:38:18 +08:00
|
|
|
E + foo 1 bar
|
2010-11-25 19:11:10 +08:00
|
|
|
E ? ^
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2020-07-09 05:51:01 +08:00
|
|
|
failure_demo.py:47: AssertionError
|
2019-01-06 03:19:40 +08:00
|
|
|
____________ TestSpecialisedExplanations.test_eq_multiline_text ____________
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2023-04-09 05:49:26 +08:00
|
|
|
self = <failure_demo.TestSpecialisedExplanations object at 0xdeadbeef0009>
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2010-11-25 19:11:10 +08:00
|
|
|
def test_eq_multiline_text(self):
|
2018-06-05 09:11:27 +08:00
|
|
|
> assert "foo\nspam\nbar" == "foo\neggs\nbar"
|
2017-03-14 06:41:20 +08:00
|
|
|
E AssertionError: assert 'foo\nspam\nbar' == 'foo\neggs\nbar'
|
2024-01-02 16:58:20 +08:00
|
|
|
E
|
2010-11-25 19:11:10 +08:00
|
|
|
E foo
|
2020-02-04 21:38:18 +08:00
|
|
|
E - eggs
|
|
|
|
E + spam
|
2010-11-25 19:11:10 +08:00
|
|
|
E bar
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2020-07-09 05:51:01 +08:00
|
|
|
failure_demo.py:50: AssertionError
|
2019-01-06 03:19:40 +08:00
|
|
|
______________ TestSpecialisedExplanations.test_eq_long_text _______________
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2023-04-09 05:49:26 +08:00
|
|
|
self = <failure_demo.TestSpecialisedExplanations object at 0xdeadbeef000a>
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2010-11-25 19:11:10 +08:00
|
|
|
def test_eq_long_text(self):
|
2018-06-05 09:11:27 +08:00
|
|
|
a = "1" * 100 + "a" + "2" * 100
|
|
|
|
b = "1" * 100 + "b" + "2" * 100
|
2010-11-25 19:11:10 +08:00
|
|
|
> assert a == b
|
2019-08-16 08:00:09 +08:00
|
|
|
E AssertionError: assert '111111111111...2222222222222' == '111111111111...2222222222222'
|
2024-01-02 16:58:20 +08:00
|
|
|
E
|
2013-04-30 18:26:30 +08:00
|
|
|
E Skipping 90 identical leading characters in diff, use -v to show
|
|
|
|
E Skipping 91 identical trailing characters in diff, use -v to show
|
2020-02-04 21:38:18 +08:00
|
|
|
E - 1111111111b222222222
|
2010-11-25 19:11:10 +08:00
|
|
|
E ? ^
|
2020-02-04 21:38:18 +08:00
|
|
|
E + 1111111111a222222222
|
2010-11-25 19:11:10 +08:00
|
|
|
E ? ^
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2020-07-09 05:51:01 +08:00
|
|
|
failure_demo.py:55: AssertionError
|
2019-01-06 03:19:40 +08:00
|
|
|
_________ TestSpecialisedExplanations.test_eq_long_text_multiline __________
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2023-04-09 05:49:26 +08:00
|
|
|
self = <failure_demo.TestSpecialisedExplanations object at 0xdeadbeef000b>
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2010-11-25 19:11:10 +08:00
|
|
|
def test_eq_long_text_multiline(self):
|
2018-06-05 09:11:27 +08:00
|
|
|
a = "1\n" * 100 + "a" + "2\n" * 100
|
|
|
|
b = "1\n" * 100 + "b" + "2\n" * 100
|
2010-11-25 19:11:10 +08:00
|
|
|
> assert a == b
|
2019-08-16 08:00:09 +08:00
|
|
|
E AssertionError: assert '1\n1\n1\n1\n...n2\n2\n2\n2\n' == '1\n1\n1\n1\n...n2\n2\n2\n2\n'
|
2024-01-02 16:58:20 +08:00
|
|
|
E
|
2013-04-30 18:26:30 +08:00
|
|
|
E Skipping 190 identical leading characters in diff, use -v to show
|
|
|
|
E Skipping 191 identical trailing characters in diff, use -v to show
|
2010-11-25 19:11:10 +08:00
|
|
|
E 1
|
|
|
|
E 1
|
|
|
|
E 1
|
2017-05-13 04:17:40 +08:00
|
|
|
E 1...
|
2018-06-20 08:34:03 +08:00
|
|
|
E
|
2024-01-02 16:58:20 +08:00
|
|
|
E ...Full output truncated (7 lines hidden), use '-vv' to show
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2020-07-09 05:51:01 +08:00
|
|
|
failure_demo.py:60: AssertionError
|
2019-01-06 03:19:40 +08:00
|
|
|
_________________ TestSpecialisedExplanations.test_eq_list _________________
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2023-04-09 05:49:26 +08:00
|
|
|
self = <failure_demo.TestSpecialisedExplanations object at 0xdeadbeef000c>
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2010-11-25 19:11:10 +08:00
|
|
|
def test_eq_list(self):
|
|
|
|
> assert [0, 1, 2] == [0, 1, 3]
|
|
|
|
E assert [0, 1, 2] == [0, 1, 3]
|
2024-01-02 16:58:20 +08:00
|
|
|
E
|
2010-11-25 19:11:10 +08:00
|
|
|
E At index 2 diff: 2 != 3
|
2022-03-13 22:58:05 +08:00
|
|
|
E Use -v to get more diff
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2020-07-09 05:51:01 +08:00
|
|
|
failure_demo.py:63: AssertionError
|
2019-01-06 03:19:40 +08:00
|
|
|
______________ TestSpecialisedExplanations.test_eq_list_long _______________
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2023-04-09 05:49:26 +08:00
|
|
|
self = <failure_demo.TestSpecialisedExplanations object at 0xdeadbeef000d>
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2010-11-25 19:11:10 +08:00
|
|
|
def test_eq_list_long(self):
|
2018-06-05 09:11:27 +08:00
|
|
|
a = [0] * 100 + [1] + [3] * 100
|
|
|
|
b = [0] * 100 + [2] + [3] * 100
|
2010-11-25 19:11:10 +08:00
|
|
|
> assert a == b
|
|
|
|
E assert [0, 0, 0, 0, 0, 0, ...] == [0, 0, 0, 0, 0, 0, ...]
|
2024-01-02 16:58:20 +08:00
|
|
|
E
|
2010-11-25 19:11:10 +08:00
|
|
|
E At index 100 diff: 1 != 2
|
2022-03-13 22:58:05 +08:00
|
|
|
E Use -v to get more diff
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2020-07-09 05:51:01 +08:00
|
|
|
failure_demo.py:68: AssertionError
|
2019-01-06 03:19:40 +08:00
|
|
|
_________________ TestSpecialisedExplanations.test_eq_dict _________________
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2023-04-09 05:49:26 +08:00
|
|
|
self = <failure_demo.TestSpecialisedExplanations object at 0xdeadbeef000e>
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2010-11-25 19:11:10 +08:00
|
|
|
def test_eq_dict(self):
|
2018-06-05 09:11:27 +08:00
|
|
|
> assert {"a": 0, "b": 1, "c": 0} == {"a": 0, "b": 2, "d": 0}
|
2017-03-14 06:41:20 +08:00
|
|
|
E AssertionError: assert {'a': 0, 'b': 1, 'c': 0} == {'a': 0, 'b': 2, 'd': 0}
|
2024-01-02 16:58:20 +08:00
|
|
|
E
|
2017-05-13 04:17:40 +08:00
|
|
|
E Omitting 1 identical items, use -vv to show
|
2013-04-30 18:26:30 +08:00
|
|
|
E Differing items:
|
|
|
|
E {'b': 1} != {'b': 2}
|
2019-05-09 05:50:08 +08:00
|
|
|
E Left contains 1 more item:
|
2013-04-30 18:26:30 +08:00
|
|
|
E {'c': 0}
|
2019-05-09 05:50:08 +08:00
|
|
|
E Right contains 1 more item:
|
2023-03-17 16:32:08 +08:00
|
|
|
E {'d': 0}
|
|
|
|
E Use -v to get more diff
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2020-07-09 05:51:01 +08:00
|
|
|
failure_demo.py:71: AssertionError
|
2019-01-06 03:19:40 +08:00
|
|
|
_________________ TestSpecialisedExplanations.test_eq_set __________________
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2023-04-09 05:49:26 +08:00
|
|
|
self = <failure_demo.TestSpecialisedExplanations object at 0xdeadbeef000f>
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2010-11-25 19:11:10 +08:00
|
|
|
def test_eq_set(self):
|
2018-06-05 09:11:27 +08:00
|
|
|
> assert {0, 10, 11, 12} == {0, 20, 21}
|
2023-03-17 16:32:08 +08:00
|
|
|
E assert {0, 10, 11, 12} == {0, 20, 21}
|
2024-01-02 16:58:20 +08:00
|
|
|
E
|
2010-11-25 19:11:10 +08:00
|
|
|
E Extra items in the left set:
|
|
|
|
E 10
|
|
|
|
E 11
|
|
|
|
E 12
|
|
|
|
E Extra items in the right set:
|
|
|
|
E 20
|
2023-03-17 16:32:08 +08:00
|
|
|
E 21
|
|
|
|
E Use -v to get more diff
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2020-07-09 05:51:01 +08:00
|
|
|
failure_demo.py:74: AssertionError
|
2019-01-06 03:19:40 +08:00
|
|
|
_____________ TestSpecialisedExplanations.test_eq_longer_list ______________
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2023-04-09 05:49:26 +08:00
|
|
|
self = <failure_demo.TestSpecialisedExplanations object at 0xdeadbeef0010>
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2010-11-25 19:11:10 +08:00
|
|
|
def test_eq_longer_list(self):
|
2018-06-05 09:11:27 +08:00
|
|
|
> assert [1, 2] == [1, 2, 3]
|
2010-11-25 19:11:10 +08:00
|
|
|
E assert [1, 2] == [1, 2, 3]
|
2024-01-02 16:58:20 +08:00
|
|
|
E
|
2019-05-09 05:50:08 +08:00
|
|
|
E Right contains one more item: 3
|
2022-03-13 22:58:05 +08:00
|
|
|
E Use -v to get more diff
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2020-07-09 05:51:01 +08:00
|
|
|
failure_demo.py:77: AssertionError
|
2019-01-06 03:19:40 +08:00
|
|
|
_________________ TestSpecialisedExplanations.test_in_list _________________
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2023-04-09 05:49:26 +08:00
|
|
|
self = <failure_demo.TestSpecialisedExplanations object at 0xdeadbeef0011>
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2010-11-25 19:11:10 +08:00
|
|
|
def test_in_list(self):
|
|
|
|
> assert 1 in [0, 2, 3, 4, 5]
|
|
|
|
E assert 1 in [0, 2, 3, 4, 5]
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2020-07-09 05:51:01 +08:00
|
|
|
failure_demo.py:80: AssertionError
|
2019-01-06 03:19:40 +08:00
|
|
|
__________ TestSpecialisedExplanations.test_not_in_text_multiline __________
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2023-04-09 05:49:26 +08:00
|
|
|
self = <failure_demo.TestSpecialisedExplanations object at 0xdeadbeef0012>
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2011-02-03 22:14:50 +08:00
|
|
|
def test_not_in_text_multiline(self):
|
2018-06-05 09:11:27 +08:00
|
|
|
text = "some multiline\ntext\nwhich\nincludes foo\nand a\ntail"
|
|
|
|
> assert "foo" not in text
|
2019-08-16 08:00:09 +08:00
|
|
|
E AssertionError: assert 'foo' not in 'some multil...nand a\ntail'
|
2024-01-02 16:58:20 +08:00
|
|
|
E
|
2011-02-03 22:14:50 +08:00
|
|
|
E 'foo' is contained here:
|
|
|
|
E some multiline
|
|
|
|
E text
|
|
|
|
E which
|
|
|
|
E includes foo
|
|
|
|
E ? +++
|
2023-03-17 16:32:08 +08:00
|
|
|
E and a
|
|
|
|
E tail
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2020-07-09 05:51:01 +08:00
|
|
|
failure_demo.py:84: AssertionError
|
2019-01-06 03:19:40 +08:00
|
|
|
___________ TestSpecialisedExplanations.test_not_in_text_single ____________
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2023-04-09 05:49:26 +08:00
|
|
|
self = <failure_demo.TestSpecialisedExplanations object at 0xdeadbeef0013>
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2011-02-03 22:14:50 +08:00
|
|
|
def test_not_in_text_single(self):
|
2018-06-05 09:11:27 +08:00
|
|
|
text = "single foo line"
|
|
|
|
> assert "foo" not in text
|
2017-03-14 06:41:20 +08:00
|
|
|
E AssertionError: assert 'foo' not in 'single foo line'
|
2024-01-02 16:58:20 +08:00
|
|
|
E
|
2011-02-03 22:14:50 +08:00
|
|
|
E 'foo' is contained here:
|
|
|
|
E single foo line
|
|
|
|
E ? +++
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2020-07-09 05:51:01 +08:00
|
|
|
failure_demo.py:88: AssertionError
|
2019-01-06 03:19:40 +08:00
|
|
|
_________ TestSpecialisedExplanations.test_not_in_text_single_long _________
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2023-04-09 05:49:26 +08:00
|
|
|
self = <failure_demo.TestSpecialisedExplanations object at 0xdeadbeef0014>
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2011-02-03 22:14:50 +08:00
|
|
|
def test_not_in_text_single_long(self):
|
2018-06-05 09:11:27 +08:00
|
|
|
text = "head " * 50 + "foo " + "tail " * 20
|
|
|
|
> assert "foo" not in text
|
2019-08-16 08:00:09 +08:00
|
|
|
E AssertionError: assert 'foo' not in 'head head h...l tail tail '
|
2024-01-02 16:58:20 +08:00
|
|
|
E
|
2011-02-03 22:14:50 +08:00
|
|
|
E 'foo' is contained here:
|
2018-06-20 08:34:03 +08:00
|
|
|
E head head foo tail tail tail tail tail tail tail tail tail tail tail tail tail tail tail tail tail tail tail tail
|
2011-02-03 22:14:50 +08:00
|
|
|
E ? +++
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2020-07-09 05:51:01 +08:00
|
|
|
failure_demo.py:92: AssertionError
|
2019-01-06 03:19:40 +08:00
|
|
|
______ TestSpecialisedExplanations.test_not_in_text_single_long_term _______
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2023-04-09 05:49:26 +08:00
|
|
|
self = <failure_demo.TestSpecialisedExplanations object at 0xdeadbeef0015>
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2011-02-03 22:14:50 +08:00
|
|
|
def test_not_in_text_single_long_term(self):
|
2018-06-05 09:11:27 +08:00
|
|
|
text = "head " * 50 + "f" * 70 + "tail " * 20
|
|
|
|
> assert "f" * 70 not in text
|
2019-08-16 08:00:09 +08:00
|
|
|
E AssertionError: assert 'fffffffffff...ffffffffffff' not in 'head head h...l tail tail '
|
2024-01-02 16:58:20 +08:00
|
|
|
E
|
2011-02-03 22:14:50 +08:00
|
|
|
E 'ffffffffffffffffff...fffffffffffffffffff' is contained here:
|
2018-06-20 08:34:03 +08:00
|
|
|
E head head fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffftail tail tail tail tail tail tail tail tail tail tail tail tail tail tail tail tail tail tail tail
|
2011-02-03 22:14:50 +08:00
|
|
|
E ? ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2020-07-09 05:51:01 +08:00
|
|
|
failure_demo.py:96: AssertionError
|
2019-01-06 03:19:40 +08:00
|
|
|
______________ TestSpecialisedExplanations.test_eq_dataclass _______________
|
2019-01-05 23:21:49 +08:00
|
|
|
|
2023-04-09 05:49:26 +08:00
|
|
|
self = <failure_demo.TestSpecialisedExplanations object at 0xdeadbeef0016>
|
2019-01-05 23:21:49 +08:00
|
|
|
|
|
|
|
def test_eq_dataclass(self):
|
2019-01-06 01:32:16 +08:00
|
|
|
from dataclasses import dataclass
|
2019-01-05 23:21:49 +08:00
|
|
|
|
2019-01-06 01:32:16 +08:00
|
|
|
@dataclass
|
2019-06-29 05:39:53 +08:00
|
|
|
class Foo:
|
2019-01-06 01:32:16 +08:00
|
|
|
a: int
|
|
|
|
b: str
|
|
|
|
|
|
|
|
left = Foo(1, "b")
|
|
|
|
right = Foo(1, "c")
|
|
|
|
> assert left == right
|
2019-08-16 08:00:09 +08:00
|
|
|
E AssertionError: assert TestSpecialis...oo(a=1, b='b') == TestSpecialis...oo(a=1, b='c')
|
2020-07-09 05:51:01 +08:00
|
|
|
E
|
2019-01-06 01:32:16 +08:00
|
|
|
E Omitting 1 identical items, use -vv to show
|
|
|
|
E Differing attributes:
|
2020-07-09 05:51:01 +08:00
|
|
|
E ['b']
|
|
|
|
E
|
|
|
|
E Drill down into differing attribute b:
|
2023-03-17 16:32:08 +08:00
|
|
|
E b: 'b' != 'c'
|
|
|
|
E - c
|
|
|
|
E + b
|
2019-01-06 01:32:16 +08:00
|
|
|
|
2020-07-09 05:51:01 +08:00
|
|
|
failure_demo.py:108: AssertionError
|
2019-01-06 03:19:40 +08:00
|
|
|
________________ TestSpecialisedExplanations.test_eq_attrs _________________
|
2019-01-05 23:21:49 +08:00
|
|
|
|
2023-04-09 05:49:26 +08:00
|
|
|
self = <failure_demo.TestSpecialisedExplanations object at 0xdeadbeef0017>
|
2019-01-05 23:21:49 +08:00
|
|
|
|
|
|
|
def test_eq_attrs(self):
|
|
|
|
import attr
|
|
|
|
|
|
|
|
@attr.s
|
2019-06-29 05:39:53 +08:00
|
|
|
class Foo:
|
2019-01-05 23:21:49 +08:00
|
|
|
a = attr.ib()
|
|
|
|
b = attr.ib()
|
|
|
|
|
|
|
|
left = Foo(1, "b")
|
|
|
|
right = Foo(1, "c")
|
|
|
|
> assert left == right
|
|
|
|
E AssertionError: assert Foo(a=1, b='b') == Foo(a=1, b='c')
|
2020-07-09 05:51:01 +08:00
|
|
|
E
|
2019-01-05 23:21:49 +08:00
|
|
|
E Omitting 1 identical items, use -vv to show
|
|
|
|
E Differing attributes:
|
2020-07-09 05:51:01 +08:00
|
|
|
E ['b']
|
|
|
|
E
|
|
|
|
E Drill down into differing attribute b:
|
2023-03-17 16:32:08 +08:00
|
|
|
E b: 'b' != 'c'
|
|
|
|
E - c
|
|
|
|
E + b
|
2019-01-05 23:21:49 +08:00
|
|
|
|
2020-07-09 05:51:01 +08:00
|
|
|
failure_demo.py:120: AssertionError
|
2019-01-06 03:19:40 +08:00
|
|
|
______________________________ test_attribute ______________________________
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2010-11-25 19:11:10 +08:00
|
|
|
def test_attribute():
|
2019-06-29 05:39:53 +08:00
|
|
|
class Foo:
|
2010-11-25 19:11:10 +08:00
|
|
|
b = 1
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2010-11-25 19:11:10 +08:00
|
|
|
i = Foo()
|
|
|
|
> assert i.b == 2
|
|
|
|
E assert 1 == 2
|
2023-04-09 05:49:26 +08:00
|
|
|
E + where 1 = <failure_demo.test_attribute.<locals>.Foo object at 0xdeadbeef0018>.b
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2020-07-09 05:51:01 +08:00
|
|
|
failure_demo.py:128: AssertionError
|
2019-01-06 03:19:40 +08:00
|
|
|
_________________________ test_attribute_instance __________________________
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2010-11-25 19:11:10 +08:00
|
|
|
def test_attribute_instance():
|
2019-06-29 05:39:53 +08:00
|
|
|
class Foo:
|
2010-11-25 19:11:10 +08:00
|
|
|
b = 1
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2010-11-25 19:11:10 +08:00
|
|
|
> assert Foo().b == 2
|
2017-03-14 06:41:20 +08:00
|
|
|
E AssertionError: assert 1 == 2
|
2023-04-09 05:49:26 +08:00
|
|
|
E + where 1 = <failure_demo.test_attribute_instance.<locals>.Foo object at 0xdeadbeef0019>.b
|
|
|
|
E + where <failure_demo.test_attribute_instance.<locals>.Foo object at 0xdeadbeef0019> = <class 'failure_demo.test_attribute_instance.<locals>.Foo'>()
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2020-07-09 05:51:01 +08:00
|
|
|
failure_demo.py:135: AssertionError
|
2019-01-06 03:19:40 +08:00
|
|
|
__________________________ test_attribute_failure __________________________
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2010-11-25 19:11:10 +08:00
|
|
|
def test_attribute_failure():
|
2019-06-29 05:39:53 +08:00
|
|
|
class Foo:
|
2010-11-25 19:11:10 +08:00
|
|
|
def _get_b(self):
|
2018-06-05 09:11:27 +08:00
|
|
|
raise Exception("Failed to get attrib")
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2010-11-25 19:11:10 +08:00
|
|
|
b = property(_get_b)
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2010-11-25 19:11:10 +08:00
|
|
|
i = Foo()
|
|
|
|
> assert i.b == 2
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2020-07-09 05:51:01 +08:00
|
|
|
failure_demo.py:146:
|
2019-01-06 03:19:40 +08:00
|
|
|
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2023-04-09 05:49:26 +08:00
|
|
|
self = <failure_demo.test_attribute_failure.<locals>.Foo object at 0xdeadbeef001a>
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2010-11-25 19:11:10 +08:00
|
|
|
def _get_b(self):
|
2018-06-05 09:11:27 +08:00
|
|
|
> raise Exception("Failed to get attrib")
|
2010-11-25 19:11:10 +08:00
|
|
|
E Exception: Failed to get attrib
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2020-07-09 05:51:01 +08:00
|
|
|
failure_demo.py:141: Exception
|
2019-01-06 03:19:40 +08:00
|
|
|
_________________________ test_attribute_multiple __________________________
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2010-11-25 19:11:10 +08:00
|
|
|
def test_attribute_multiple():
|
2019-06-29 05:39:53 +08:00
|
|
|
class Foo:
|
2010-11-25 19:11:10 +08:00
|
|
|
b = 1
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2019-06-29 05:39:53 +08:00
|
|
|
class Bar:
|
2010-11-25 19:11:10 +08:00
|
|
|
b = 2
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2010-11-25 19:11:10 +08:00
|
|
|
> assert Foo().b == Bar().b
|
2017-03-14 06:41:20 +08:00
|
|
|
E AssertionError: assert 1 == 2
|
2023-04-09 05:49:26 +08:00
|
|
|
E + where 1 = <failure_demo.test_attribute_multiple.<locals>.Foo object at 0xdeadbeef001b>.b
|
|
|
|
E + where <failure_demo.test_attribute_multiple.<locals>.Foo object at 0xdeadbeef001b> = <class 'failure_demo.test_attribute_multiple.<locals>.Foo'>()
|
|
|
|
E + and 2 = <failure_demo.test_attribute_multiple.<locals>.Bar object at 0xdeadbeef001c>.b
|
|
|
|
E + where <failure_demo.test_attribute_multiple.<locals>.Bar object at 0xdeadbeef001c> = <class 'failure_demo.test_attribute_multiple.<locals>.Bar'>()
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2020-07-09 05:51:01 +08:00
|
|
|
failure_demo.py:156: AssertionError
|
2019-01-06 03:19:40 +08:00
|
|
|
__________________________ TestRaises.test_raises __________________________
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2023-04-09 05:49:26 +08:00
|
|
|
self = <failure_demo.TestRaises object at 0xdeadbeef001d>
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2010-11-25 19:11:10 +08:00
|
|
|
def test_raises(self):
|
2019-01-05 23:21:49 +08:00
|
|
|
s = "qwe"
|
|
|
|
> raises(TypeError, int, s)
|
|
|
|
E ValueError: invalid literal for int() with base 10: 'qwe'
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2020-07-09 05:51:01 +08:00
|
|
|
failure_demo.py:166: ValueError
|
2019-01-06 03:19:40 +08:00
|
|
|
______________________ TestRaises.test_raises_doesnt _______________________
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2023-04-09 05:49:26 +08:00
|
|
|
self = <failure_demo.TestRaises object at 0xdeadbeef001e>
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2010-11-25 19:11:10 +08:00
|
|
|
def test_raises_doesnt(self):
|
2020-03-27 23:40:23 +08:00
|
|
|
> raises(OSError, int, "3")
|
2016-03-01 04:52:56 +08:00
|
|
|
E Failed: DID NOT RAISE <class 'OSError'>
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2020-07-09 05:51:01 +08:00
|
|
|
failure_demo.py:169: Failed
|
2019-01-06 03:19:40 +08:00
|
|
|
__________________________ TestRaises.test_raise ___________________________
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2023-04-09 05:49:26 +08:00
|
|
|
self = <failure_demo.TestRaises object at 0xdeadbeef001f>
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2010-11-25 19:11:10 +08:00
|
|
|
def test_raise(self):
|
|
|
|
> raise ValueError("demo error")
|
|
|
|
E ValueError: demo error
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2020-07-09 05:51:01 +08:00
|
|
|
failure_demo.py:172: ValueError
|
2019-01-06 03:19:40 +08:00
|
|
|
________________________ TestRaises.test_tupleerror ________________________
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2023-04-09 05:49:26 +08:00
|
|
|
self = <failure_demo.TestRaises object at 0xdeadbeef0020>
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2010-11-25 19:11:10 +08:00
|
|
|
def test_tupleerror(self):
|
2018-06-05 09:11:27 +08:00
|
|
|
> a, b = [1] # NOQA
|
2016-05-31 17:15:57 +08:00
|
|
|
E ValueError: not enough values to unpack (expected 2, got 1)
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2020-07-09 05:51:01 +08:00
|
|
|
failure_demo.py:175: ValueError
|
2019-01-06 03:19:40 +08:00
|
|
|
______ TestRaises.test_reinterpret_fails_with_print_for_the_fun_of_it ______
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2023-04-09 05:49:26 +08:00
|
|
|
self = <failure_demo.TestRaises object at 0xdeadbeef0021>
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2010-11-25 19:11:10 +08:00
|
|
|
def test_reinterpret_fails_with_print_for_the_fun_of_it(self):
|
2018-06-05 09:11:27 +08:00
|
|
|
items = [1, 2, 3]
|
2020-12-13 05:21:28 +08:00
|
|
|
print(f"items is {items!r}")
|
2018-06-05 09:11:27 +08:00
|
|
|
> a, b = items.pop()
|
2020-03-11 22:23:25 +08:00
|
|
|
E TypeError: cannot unpack non-iterable int object
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2020-07-09 05:51:01 +08:00
|
|
|
failure_demo.py:180: TypeError
|
2019-01-06 03:19:40 +08:00
|
|
|
--------------------------- Captured stdout call ---------------------------
|
2018-06-05 09:11:27 +08:00
|
|
|
items is [1, 2, 3]
|
2019-01-06 03:19:40 +08:00
|
|
|
________________________ TestRaises.test_some_error ________________________
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2023-04-09 05:49:26 +08:00
|
|
|
self = <failure_demo.TestRaises object at 0xdeadbeef0022>
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2010-11-25 19:11:10 +08:00
|
|
|
def test_some_error(self):
|
2018-06-05 09:11:27 +08:00
|
|
|
> if namenotexi: # NOQA
|
2015-09-22 22:52:35 +08:00
|
|
|
E NameError: name 'namenotexi' is not defined
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2020-07-09 05:51:01 +08:00
|
|
|
failure_demo.py:183: NameError
|
2019-01-06 03:19:40 +08:00
|
|
|
____________________ test_dynamic_compile_shows_nicely _____________________
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2010-11-25 19:11:10 +08:00
|
|
|
def test_dynamic_compile_shows_nicely():
|
2019-06-28 01:59:58 +08:00
|
|
|
import importlib.util
|
2018-01-31 03:47:56 +08:00
|
|
|
import sys
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2018-06-05 09:11:27 +08:00
|
|
|
src = "def foo():\n assert 1 == 0\n"
|
|
|
|
name = "abc-123"
|
2019-06-28 01:59:58 +08:00
|
|
|
spec = importlib.util.spec_from_loader(name, loader=None)
|
|
|
|
module = importlib.util.module_from_spec(spec)
|
2020-07-09 05:51:01 +08:00
|
|
|
code = compile(src, name, "exec")
|
2019-05-07 14:07:39 +08:00
|
|
|
exec(code, module.__dict__)
|
2017-12-27 11:47:26 +08:00
|
|
|
sys.modules[name] = module
|
2010-11-25 19:11:10 +08:00
|
|
|
> module.foo()
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2020-07-09 05:51:01 +08:00
|
|
|
failure_demo.py:202:
|
2019-01-06 03:19:40 +08:00
|
|
|
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2020-07-09 05:51:01 +08:00
|
|
|
> ???
|
|
|
|
E AssertionError
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2020-07-09 05:51:01 +08:00
|
|
|
abc-123:2: AssertionError
|
2019-01-06 03:19:40 +08:00
|
|
|
____________________ TestMoreErrors.test_complex_error _____________________
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2023-04-09 05:49:26 +08:00
|
|
|
self = <failure_demo.TestMoreErrors object at 0xdeadbeef0023>
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2010-11-25 19:11:10 +08:00
|
|
|
def test_complex_error(self):
|
|
|
|
def f():
|
|
|
|
return 44
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2010-11-25 19:11:10 +08:00
|
|
|
def g():
|
|
|
|
return 43
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2010-11-25 19:11:10 +08:00
|
|
|
> somefunc(f(), g())
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2020-07-09 05:51:01 +08:00
|
|
|
failure_demo.py:213:
|
2019-01-06 03:19:40 +08:00
|
|
|
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
|
2020-07-09 05:51:01 +08:00
|
|
|
failure_demo.py:10: in somefunc
|
2018-06-05 09:11:27 +08:00
|
|
|
otherfunc(x, y)
|
2019-01-06 03:19:40 +08:00
|
|
|
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2010-11-25 19:11:10 +08:00
|
|
|
a = 44, b = 43
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2018-06-05 09:11:27 +08:00
|
|
|
def otherfunc(a, b):
|
|
|
|
> assert a == b
|
2010-11-25 19:11:10 +08:00
|
|
|
E assert 44 == 43
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2020-07-09 05:51:01 +08:00
|
|
|
failure_demo.py:6: AssertionError
|
2019-01-06 03:19:40 +08:00
|
|
|
___________________ TestMoreErrors.test_z1_unpack_error ____________________
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2023-04-09 05:49:26 +08:00
|
|
|
self = <failure_demo.TestMoreErrors object at 0xdeadbeef0024>
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2010-11-25 19:11:10 +08:00
|
|
|
def test_z1_unpack_error(self):
|
2018-06-05 09:11:27 +08:00
|
|
|
items = []
|
|
|
|
> a, b = items
|
2016-05-31 17:15:57 +08:00
|
|
|
E ValueError: not enough values to unpack (expected 2, got 0)
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2020-07-09 05:51:01 +08:00
|
|
|
failure_demo.py:217: ValueError
|
2019-01-06 03:19:40 +08:00
|
|
|
____________________ TestMoreErrors.test_z2_type_error _____________________
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2023-04-09 05:49:26 +08:00
|
|
|
self = <failure_demo.TestMoreErrors object at 0xdeadbeef0025>
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2010-11-25 19:11:10 +08:00
|
|
|
def test_z2_type_error(self):
|
2018-06-05 09:11:27 +08:00
|
|
|
items = 3
|
|
|
|
> a, b = items
|
2020-03-11 22:23:25 +08:00
|
|
|
E TypeError: cannot unpack non-iterable int object
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2020-07-09 05:51:01 +08:00
|
|
|
failure_demo.py:221: TypeError
|
2019-01-06 03:19:40 +08:00
|
|
|
______________________ TestMoreErrors.test_startswith ______________________
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2023-04-09 05:49:26 +08:00
|
|
|
self = <failure_demo.TestMoreErrors object at 0xdeadbeef0026>
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2010-11-25 19:11:10 +08:00
|
|
|
def test_startswith(self):
|
|
|
|
s = "123"
|
|
|
|
g = "456"
|
|
|
|
> assert s.startswith(g)
|
2017-03-14 06:41:20 +08:00
|
|
|
E AssertionError: assert False
|
2023-04-09 05:49:26 +08:00
|
|
|
E + where False = <built-in method startswith of str object at 0xdeadbeef0027>('456')
|
|
|
|
E + where <built-in method startswith of str object at 0xdeadbeef0027> = '123'.startswith
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2020-07-09 05:51:01 +08:00
|
|
|
failure_demo.py:226: AssertionError
|
2019-01-06 03:19:40 +08:00
|
|
|
__________________ TestMoreErrors.test_startswith_nested ___________________
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2023-04-09 05:49:26 +08:00
|
|
|
self = <failure_demo.TestMoreErrors object at 0xdeadbeef0028>
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2010-11-25 19:11:10 +08:00
|
|
|
def test_startswith_nested(self):
|
|
|
|
def f():
|
|
|
|
return "123"
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2010-11-25 19:11:10 +08:00
|
|
|
def g():
|
|
|
|
return "456"
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2010-11-25 19:11:10 +08:00
|
|
|
> assert f().startswith(g())
|
2017-03-14 06:41:20 +08:00
|
|
|
E AssertionError: assert False
|
2023-04-09 05:49:26 +08:00
|
|
|
E + where False = <built-in method startswith of str object at 0xdeadbeef0027>('456')
|
|
|
|
E + where <built-in method startswith of str object at 0xdeadbeef0027> = '123'.startswith
|
2023-09-08 03:10:19 +08:00
|
|
|
E + where '123' = <function TestMoreErrors.test_startswith_nested.<locals>.f at 0xdeadbeef0029>()
|
|
|
|
E + and '456' = <function TestMoreErrors.test_startswith_nested.<locals>.g at 0xdeadbeef002a>()
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2020-07-09 05:51:01 +08:00
|
|
|
failure_demo.py:235: AssertionError
|
2019-01-06 03:19:40 +08:00
|
|
|
_____________________ TestMoreErrors.test_global_func ______________________
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2023-09-08 03:10:19 +08:00
|
|
|
self = <failure_demo.TestMoreErrors object at 0xdeadbeef002b>
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2010-11-25 19:11:10 +08:00
|
|
|
def test_global_func(self):
|
|
|
|
> assert isinstance(globf(42), float)
|
2016-08-02 02:46:34 +08:00
|
|
|
E assert False
|
|
|
|
E + where False = isinstance(43, float)
|
|
|
|
E + where 43 = globf(42)
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2020-07-09 05:51:01 +08:00
|
|
|
failure_demo.py:238: AssertionError
|
2019-01-06 03:19:40 +08:00
|
|
|
_______________________ TestMoreErrors.test_instance _______________________
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2023-09-08 03:10:19 +08:00
|
|
|
self = <failure_demo.TestMoreErrors object at 0xdeadbeef002c>
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2010-11-25 19:11:10 +08:00
|
|
|
def test_instance(self):
|
2018-06-05 09:11:27 +08:00
|
|
|
self.x = 6 * 7
|
2010-11-25 19:11:10 +08:00
|
|
|
> assert self.x != 42
|
|
|
|
E assert 42 != 42
|
2023-09-08 03:10:19 +08:00
|
|
|
E + where 42 = <failure_demo.TestMoreErrors object at 0xdeadbeef002c>.x
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2020-07-09 05:51:01 +08:00
|
|
|
failure_demo.py:242: AssertionError
|
2019-01-06 03:19:40 +08:00
|
|
|
_______________________ TestMoreErrors.test_compare ________________________
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2023-09-08 03:10:19 +08:00
|
|
|
self = <failure_demo.TestMoreErrors object at 0xdeadbeef002d>
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2010-11-25 19:11:10 +08:00
|
|
|
def test_compare(self):
|
|
|
|
> assert globf(10) < 5
|
|
|
|
E assert 11 < 5
|
|
|
|
E + where 11 = globf(10)
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2020-07-09 05:51:01 +08:00
|
|
|
failure_demo.py:245: AssertionError
|
2019-01-06 03:19:40 +08:00
|
|
|
_____________________ TestMoreErrors.test_try_finally ______________________
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2023-09-08 03:10:19 +08:00
|
|
|
self = <failure_demo.TestMoreErrors object at 0xdeadbeef002e>
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2010-11-25 19:11:10 +08:00
|
|
|
def test_try_finally(self):
|
|
|
|
x = 1
|
|
|
|
try:
|
|
|
|
> assert x == 0
|
|
|
|
E assert 1 == 0
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2020-07-09 05:51:01 +08:00
|
|
|
failure_demo.py:250: AssertionError
|
2019-01-06 03:19:40 +08:00
|
|
|
___________________ TestCustomAssertMsg.test_single_line ___________________
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2023-09-08 03:10:19 +08:00
|
|
|
self = <failure_demo.TestCustomAssertMsg object at 0xdeadbeef002f>
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2014-09-24 20:46:56 +08:00
|
|
|
def test_single_line(self):
|
2019-06-29 05:39:53 +08:00
|
|
|
class A:
|
2014-09-24 20:46:56 +08:00
|
|
|
a = 1
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2014-09-24 20:46:56 +08:00
|
|
|
b = 2
|
|
|
|
> assert A.a == b, "A.a appears not to be b"
|
|
|
|
E AssertionError: A.a appears not to be b
|
|
|
|
E assert 1 == 2
|
2015-09-22 22:52:35 +08:00
|
|
|
E + where 1 = <class 'failure_demo.TestCustomAssertMsg.test_single_line.<locals>.A'>.a
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2020-07-09 05:51:01 +08:00
|
|
|
failure_demo.py:261: AssertionError
|
2019-01-06 03:19:40 +08:00
|
|
|
____________________ TestCustomAssertMsg.test_multiline ____________________
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2023-09-08 03:10:19 +08:00
|
|
|
self = <failure_demo.TestCustomAssertMsg object at 0xdeadbeef0030>
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2014-09-24 20:46:56 +08:00
|
|
|
def test_multiline(self):
|
2019-06-29 05:39:53 +08:00
|
|
|
class A:
|
2014-09-24 20:46:56 +08:00
|
|
|
a = 1
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2014-09-24 20:46:56 +08:00
|
|
|
b = 2
|
2018-06-05 09:11:27 +08:00
|
|
|
> assert (
|
|
|
|
A.a == b
|
2018-10-11 01:28:31 +08:00
|
|
|
), "A.a appears not to be b\nor does not appear to be b\none of those"
|
2014-09-24 20:46:56 +08:00
|
|
|
E AssertionError: A.a appears not to be b
|
|
|
|
E or does not appear to be b
|
|
|
|
E one of those
|
|
|
|
E assert 1 == 2
|
2015-09-22 22:52:35 +08:00
|
|
|
E + where 1 = <class 'failure_demo.TestCustomAssertMsg.test_multiline.<locals>.A'>.a
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2020-07-09 05:51:01 +08:00
|
|
|
failure_demo.py:268: AssertionError
|
2019-01-06 03:19:40 +08:00
|
|
|
___________________ TestCustomAssertMsg.test_custom_repr ___________________
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2023-09-08 03:10:19 +08:00
|
|
|
self = <failure_demo.TestCustomAssertMsg object at 0xdeadbeef0031>
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2014-09-24 20:46:56 +08:00
|
|
|
def test_custom_repr(self):
|
2019-06-29 05:39:53 +08:00
|
|
|
class JSON:
|
2014-09-24 20:46:56 +08:00
|
|
|
a = 1
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2014-09-24 20:46:56 +08:00
|
|
|
def __repr__(self):
|
|
|
|
return "This is JSON\n{\n 'foo': 'bar'\n}"
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2014-09-24 20:46:56 +08:00
|
|
|
a = JSON()
|
|
|
|
b = 2
|
|
|
|
> assert a.a == b, a
|
|
|
|
E AssertionError: This is JSON
|
|
|
|
E {
|
|
|
|
E 'foo': 'bar'
|
|
|
|
E }
|
|
|
|
E assert 1 == 2
|
|
|
|
E + where 1 = This is JSON\n{\n 'foo': 'bar'\n}.a
|
2018-06-20 08:34:03 +08:00
|
|
|
|
2020-07-09 05:51:01 +08:00
|
|
|
failure_demo.py:281: AssertionError
|
2020-03-11 22:23:25 +08:00
|
|
|
========================= short test summary info ==========================
|
|
|
|
FAILED failure_demo.py::test_generative[3-6] - assert (3 * 2) < 6
|
|
|
|
FAILED failure_demo.py::TestFailing::test_simple - assert 42 == 43
|
|
|
|
FAILED failure_demo.py::TestFailing::test_simple_multiline - assert 42 == 54
|
|
|
|
FAILED failure_demo.py::TestFailing::test_not - assert not 42
|
|
|
|
FAILED failure_demo.py::TestSpecialisedExplanations::test_eq_text - Asser...
|
|
|
|
FAILED failure_demo.py::TestSpecialisedExplanations::test_eq_similar_text
|
|
|
|
FAILED failure_demo.py::TestSpecialisedExplanations::test_eq_multiline_text
|
|
|
|
FAILED failure_demo.py::TestSpecialisedExplanations::test_eq_long_text - ...
|
|
|
|
FAILED failure_demo.py::TestSpecialisedExplanations::test_eq_long_text_multiline
|
|
|
|
FAILED failure_demo.py::TestSpecialisedExplanations::test_eq_list - asser...
|
|
|
|
FAILED failure_demo.py::TestSpecialisedExplanations::test_eq_list_long - ...
|
|
|
|
FAILED failure_demo.py::TestSpecialisedExplanations::test_eq_dict - Asser...
|
2023-03-17 16:32:08 +08:00
|
|
|
FAILED failure_demo.py::TestSpecialisedExplanations::test_eq_set - assert...
|
2020-03-11 22:23:25 +08:00
|
|
|
FAILED failure_demo.py::TestSpecialisedExplanations::test_eq_longer_list
|
|
|
|
FAILED failure_demo.py::TestSpecialisedExplanations::test_in_list - asser...
|
|
|
|
FAILED failure_demo.py::TestSpecialisedExplanations::test_not_in_text_multiline
|
|
|
|
FAILED failure_demo.py::TestSpecialisedExplanations::test_not_in_text_single
|
|
|
|
FAILED failure_demo.py::TestSpecialisedExplanations::test_not_in_text_single_long
|
|
|
|
FAILED failure_demo.py::TestSpecialisedExplanations::test_not_in_text_single_long_term
|
|
|
|
FAILED failure_demo.py::TestSpecialisedExplanations::test_eq_dataclass - ...
|
|
|
|
FAILED failure_demo.py::TestSpecialisedExplanations::test_eq_attrs - Asse...
|
|
|
|
FAILED failure_demo.py::test_attribute - assert 1 == 2
|
|
|
|
FAILED failure_demo.py::test_attribute_instance - AssertionError: assert ...
|
|
|
|
FAILED failure_demo.py::test_attribute_failure - Exception: Failed to get...
|
|
|
|
FAILED failure_demo.py::test_attribute_multiple - AssertionError: assert ...
|
|
|
|
FAILED failure_demo.py::TestRaises::test_raises - ValueError: invalid lit...
|
|
|
|
FAILED failure_demo.py::TestRaises::test_raises_doesnt - Failed: DID NOT ...
|
|
|
|
FAILED failure_demo.py::TestRaises::test_raise - ValueError: demo error
|
|
|
|
FAILED failure_demo.py::TestRaises::test_tupleerror - ValueError: not eno...
|
|
|
|
FAILED failure_demo.py::TestRaises::test_reinterpret_fails_with_print_for_the_fun_of_it
|
|
|
|
FAILED failure_demo.py::TestRaises::test_some_error - NameError: name 'na...
|
|
|
|
FAILED failure_demo.py::test_dynamic_compile_shows_nicely - AssertionError
|
|
|
|
FAILED failure_demo.py::TestMoreErrors::test_complex_error - assert 44 == 43
|
|
|
|
FAILED failure_demo.py::TestMoreErrors::test_z1_unpack_error - ValueError...
|
|
|
|
FAILED failure_demo.py::TestMoreErrors::test_z2_type_error - TypeError: c...
|
|
|
|
FAILED failure_demo.py::TestMoreErrors::test_startswith - AssertionError:...
|
|
|
|
FAILED failure_demo.py::TestMoreErrors::test_startswith_nested - Assertio...
|
|
|
|
FAILED failure_demo.py::TestMoreErrors::test_global_func - assert False
|
|
|
|
FAILED failure_demo.py::TestMoreErrors::test_instance - assert 42 != 42
|
|
|
|
FAILED failure_demo.py::TestMoreErrors::test_compare - assert 11 < 5
|
|
|
|
FAILED failure_demo.py::TestMoreErrors::test_try_finally - assert 1 == 0
|
|
|
|
FAILED failure_demo.py::TestCustomAssertMsg::test_single_line - Assertion...
|
|
|
|
FAILED failure_demo.py::TestCustomAssertMsg::test_multiline - AssertionEr...
|
|
|
|
FAILED failure_demo.py::TestCustomAssertMsg::test_custom_repr - Assertion...
|
2019-08-30 23:43:47 +08:00
|
|
|
============================ 44 failed in 0.12s ============================
|