2010-11-25 19:11:10 +08:00
|
|
|
|
|
|
|
.. _`tbreportdemo`:
|
2014-01-18 19:31:33 +08:00
|
|
|
|
|
|
|
Demo of Python failure reports with pytest
|
2010-11-25 19:11:10 +08:00
|
|
|
==================================================
|
|
|
|
|
|
|
|
Here is a nice run of several tens of failures
|
2014-01-18 19:31:33 +08:00
|
|
|
and how ``pytest`` presents things (unfortunately
|
2010-11-25 19:11:10 +08:00
|
|
|
not showing the nice colors here in the HTML that you
|
2010-11-26 03:06:42 +08:00
|
|
|
get on the terminal - we are working on that):
|
|
|
|
|
|
|
|
.. code-block:: python
|
2010-11-25 19:11:10 +08:00
|
|
|
|
2016-06-21 22:16:57 +08:00
|
|
|
assertion $ pytest failure_demo.py
|
2015-06-07 05:30:49 +08:00
|
|
|
======= test session starts ========
|
2016-08-24 05:59:59 +08:00
|
|
|
platform linux -- Python 3.5.2, pytest-3.0.1, py-1.4.31, pluggy-0.3.1
|
2015-09-22 20:02:11 +08:00
|
|
|
rootdir: $REGENDOC_TMPDIR/assertion, inifile:
|
2014-09-24 20:46:56 +08:00
|
|
|
collected 42 items
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2014-09-24 20:46:56 +08:00
|
|
|
failure_demo.py FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2015-06-07 05:30:49 +08:00
|
|
|
======= FAILURES ========
|
|
|
|
_______ test_generative[0] ________
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2010-11-25 19:11:10 +08:00
|
|
|
param1 = 3, param2 = 6
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2010-11-25 19:11:10 +08:00
|
|
|
def test_generative(param1, param2):
|
|
|
|
> assert param1 * 2 < param2
|
|
|
|
E assert (3 * 2) < 6
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2016-03-01 04:52:56 +08:00
|
|
|
failure_demo.py:16: AssertionError
|
2015-06-07 05:30:49 +08:00
|
|
|
_______ TestFailing.test_simple ________
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2015-06-07 05:30:49 +08:00
|
|
|
self = <failure_demo.TestFailing object at 0xdeadbeef>
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2010-11-25 19:11:10 +08:00
|
|
|
def test_simple(self):
|
|
|
|
def f():
|
|
|
|
return 42
|
|
|
|
def g():
|
|
|
|
return 43
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2010-11-25 19:11:10 +08:00
|
|
|
> assert f() == g()
|
|
|
|
E assert 42 == 43
|
2015-09-22 22:52:35 +08:00
|
|
|
E + where 42 = <function TestFailing.test_simple.<locals>.f at 0xdeadbeef>()
|
|
|
|
E + and 43 = <function TestFailing.test_simple.<locals>.g at 0xdeadbeef>()
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2016-03-01 04:52:56 +08:00
|
|
|
failure_demo.py:29: AssertionError
|
2015-06-07 05:30:49 +08:00
|
|
|
_______ TestFailing.test_simple_multiline ________
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2015-06-07 05:30:49 +08:00
|
|
|
self = <failure_demo.TestFailing object at 0xdeadbeef>
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2010-11-25 19:11:10 +08:00
|
|
|
def test_simple_multiline(self):
|
|
|
|
otherfunc_multi(
|
|
|
|
42,
|
|
|
|
> 6*9)
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2016-03-01 04:52:56 +08:00
|
|
|
failure_demo.py:34:
|
2015-09-22 20:02:11 +08:00
|
|
|
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2010-11-25 19:11:10 +08:00
|
|
|
a = 42, b = 54
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2010-11-25 19:11:10 +08:00
|
|
|
def otherfunc_multi(a,b):
|
2011-08-21 00:37:00 +08:00
|
|
|
> assert (a ==
|
|
|
|
b)
|
2010-11-25 19:11:10 +08:00
|
|
|
E assert 42 == 54
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2016-03-01 04:52:56 +08:00
|
|
|
failure_demo.py:12: AssertionError
|
2015-06-07 05:30:49 +08:00
|
|
|
_______ TestFailing.test_not ________
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2015-06-07 05:30:49 +08:00
|
|
|
self = <failure_demo.TestFailing object at 0xdeadbeef>
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2010-11-25 19:11:10 +08:00
|
|
|
def test_not(self):
|
|
|
|
def f():
|
|
|
|
return 42
|
|
|
|
> assert not f()
|
|
|
|
E assert not 42
|
2015-09-22 22:52:35 +08:00
|
|
|
E + where 42 = <function TestFailing.test_not.<locals>.f at 0xdeadbeef>()
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2016-03-01 04:52:56 +08:00
|
|
|
failure_demo.py:39: AssertionError
|
2015-06-07 05:30:49 +08:00
|
|
|
_______ TestSpecialisedExplanations.test_eq_text ________
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2015-06-07 05:30:49 +08:00
|
|
|
self = <failure_demo.TestSpecialisedExplanations object at 0xdeadbeef>
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2010-11-25 19:11:10 +08:00
|
|
|
def test_eq_text(self):
|
|
|
|
> assert 'spam' == 'eggs'
|
|
|
|
E assert 'spam' == 'eggs'
|
|
|
|
E - spam
|
|
|
|
E + eggs
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2016-03-01 04:52:56 +08:00
|
|
|
failure_demo.py:43: AssertionError
|
2015-06-07 05:30:49 +08:00
|
|
|
_______ TestSpecialisedExplanations.test_eq_similar_text ________
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2015-06-07 05:30:49 +08:00
|
|
|
self = <failure_demo.TestSpecialisedExplanations object at 0xdeadbeef>
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2010-11-25 19:11:10 +08:00
|
|
|
def test_eq_similar_text(self):
|
|
|
|
> assert 'foo 1 bar' == 'foo 2 bar'
|
|
|
|
E assert 'foo 1 bar' == 'foo 2 bar'
|
|
|
|
E - foo 1 bar
|
|
|
|
E ? ^
|
|
|
|
E + foo 2 bar
|
|
|
|
E ? ^
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2016-03-01 04:52:56 +08:00
|
|
|
failure_demo.py:46: AssertionError
|
2015-06-07 05:30:49 +08:00
|
|
|
_______ TestSpecialisedExplanations.test_eq_multiline_text ________
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2015-06-07 05:30:49 +08:00
|
|
|
self = <failure_demo.TestSpecialisedExplanations object at 0xdeadbeef>
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2010-11-25 19:11:10 +08:00
|
|
|
def test_eq_multiline_text(self):
|
|
|
|
> assert 'foo\nspam\nbar' == 'foo\neggs\nbar'
|
|
|
|
E assert 'foo\nspam\nbar' == 'foo\neggs\nbar'
|
|
|
|
E foo
|
|
|
|
E - spam
|
|
|
|
E + eggs
|
|
|
|
E bar
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2016-03-01 04:52:56 +08:00
|
|
|
failure_demo.py:49: AssertionError
|
2015-06-07 05:30:49 +08:00
|
|
|
_______ TestSpecialisedExplanations.test_eq_long_text ________
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2015-06-07 05:30:49 +08:00
|
|
|
self = <failure_demo.TestSpecialisedExplanations object at 0xdeadbeef>
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2010-11-25 19:11:10 +08:00
|
|
|
def test_eq_long_text(self):
|
|
|
|
a = '1'*100 + 'a' + '2'*100
|
|
|
|
b = '1'*100 + 'b' + '2'*100
|
|
|
|
> assert a == b
|
2011-02-03 22:14:50 +08:00
|
|
|
E assert '111111111111...2222222222222' == '1111111111111...2222222222222'
|
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
|
2010-11-25 19:11:10 +08:00
|
|
|
E - 1111111111a222222222
|
|
|
|
E ? ^
|
|
|
|
E + 1111111111b222222222
|
|
|
|
E ? ^
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2016-03-01 04:52:56 +08:00
|
|
|
failure_demo.py:54: AssertionError
|
2015-06-07 05:30:49 +08:00
|
|
|
_______ TestSpecialisedExplanations.test_eq_long_text_multiline ________
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2015-06-07 05:30:49 +08:00
|
|
|
self = <failure_demo.TestSpecialisedExplanations object at 0xdeadbeef>
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2010-11-25 19:11:10 +08:00
|
|
|
def test_eq_long_text_multiline(self):
|
|
|
|
a = '1\n'*100 + 'a' + '2\n'*100
|
|
|
|
b = '1\n'*100 + 'b' + '2\n'*100
|
|
|
|
> assert a == b
|
2011-02-03 22:14:50 +08:00
|
|
|
E assert '1\n1\n1\n1\n...n2\n2\n2\n2\n' == '1\n1\n1\n1\n1...n2\n2\n2\n2\n'
|
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
|
|
|
|
E 1
|
|
|
|
E 1
|
|
|
|
E - a2
|
|
|
|
E + b2
|
|
|
|
E 2
|
|
|
|
E 2
|
|
|
|
E 2
|
|
|
|
E 2
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2016-03-01 04:52:56 +08:00
|
|
|
failure_demo.py:59: AssertionError
|
2015-06-07 05:30:49 +08:00
|
|
|
_______ TestSpecialisedExplanations.test_eq_list ________
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2015-06-07 05:30:49 +08:00
|
|
|
self = <failure_demo.TestSpecialisedExplanations object at 0xdeadbeef>
|
2014-01-29 20:47:11 +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]
|
|
|
|
E At index 2 diff: 2 != 3
|
2014-10-24 21:08:43 +08:00
|
|
|
E Use -v to get the full diff
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2016-03-01 04:52:56 +08:00
|
|
|
failure_demo.py:62: AssertionError
|
2015-06-07 05:30:49 +08:00
|
|
|
_______ TestSpecialisedExplanations.test_eq_list_long ________
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2015-06-07 05:30:49 +08:00
|
|
|
self = <failure_demo.TestSpecialisedExplanations object at 0xdeadbeef>
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2010-11-25 19:11:10 +08:00
|
|
|
def test_eq_list_long(self):
|
|
|
|
a = [0]*100 + [1] + [3]*100
|
|
|
|
b = [0]*100 + [2] + [3]*100
|
|
|
|
> assert a == b
|
|
|
|
E assert [0, 0, 0, 0, 0, 0, ...] == [0, 0, 0, 0, 0, 0, ...]
|
|
|
|
E At index 100 diff: 1 != 2
|
2014-10-24 21:08:43 +08:00
|
|
|
E Use -v to get the full diff
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2016-03-01 04:52:56 +08:00
|
|
|
failure_demo.py:67: AssertionError
|
2015-06-07 05:30:49 +08:00
|
|
|
_______ TestSpecialisedExplanations.test_eq_dict ________
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2015-06-07 05:30:49 +08:00
|
|
|
self = <failure_demo.TestSpecialisedExplanations object at 0xdeadbeef>
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2010-11-25 19:11:10 +08:00
|
|
|
def test_eq_dict(self):
|
2013-04-30 18:26:30 +08:00
|
|
|
> assert {'a': 0, 'b': 1, 'c': 0} == {'a': 0, 'b': 2, 'd': 0}
|
|
|
|
E assert {'a': 0, 'b': 1, 'c': 0} == {'a': 0, 'b': 2, 'd': 0}
|
2013-10-04 01:09:18 +08:00
|
|
|
E Omitting 1 identical items, use -v to show
|
2013-04-30 18:26:30 +08:00
|
|
|
E Differing items:
|
|
|
|
E {'b': 1} != {'b': 2}
|
|
|
|
E Left contains more items:
|
|
|
|
E {'c': 0}
|
|
|
|
E Right contains more items:
|
|
|
|
E {'d': 0}
|
2014-10-24 21:08:43 +08:00
|
|
|
E Use -v to get the full diff
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2016-03-01 04:52:56 +08:00
|
|
|
failure_demo.py:70: AssertionError
|
2015-06-07 05:30:49 +08:00
|
|
|
_______ TestSpecialisedExplanations.test_eq_set ________
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2015-06-07 05:30:49 +08:00
|
|
|
self = <failure_demo.TestSpecialisedExplanations object at 0xdeadbeef>
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2010-11-25 19:11:10 +08:00
|
|
|
def test_eq_set(self):
|
|
|
|
> assert set([0, 10, 11, 12]) == set([0, 20, 21])
|
2016-05-31 17:15:57 +08:00
|
|
|
E assert {0, 10, 11, 12} == {0, 20, 21}
|
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
|
|
|
|
E 21
|
2014-10-24 21:08:43 +08:00
|
|
|
E Use -v to get the full diff
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2016-03-01 04:52:56 +08:00
|
|
|
failure_demo.py:73: AssertionError
|
2015-06-07 05:30:49 +08:00
|
|
|
_______ TestSpecialisedExplanations.test_eq_longer_list ________
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2015-06-07 05:30:49 +08:00
|
|
|
self = <failure_demo.TestSpecialisedExplanations object at 0xdeadbeef>
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2010-11-25 19:11:10 +08:00
|
|
|
def test_eq_longer_list(self):
|
|
|
|
> assert [1,2] == [1,2,3]
|
|
|
|
E assert [1, 2] == [1, 2, 3]
|
|
|
|
E Right contains more items, first extra item: 3
|
2014-10-24 21:08:43 +08:00
|
|
|
E Use -v to get the full diff
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2016-03-01 04:52:56 +08:00
|
|
|
failure_demo.py:76: AssertionError
|
2015-06-07 05:30:49 +08:00
|
|
|
_______ TestSpecialisedExplanations.test_in_list ________
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2015-06-07 05:30:49 +08:00
|
|
|
self = <failure_demo.TestSpecialisedExplanations object at 0xdeadbeef>
|
2014-01-29 20:47:11 +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]
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2016-03-01 04:52:56 +08:00
|
|
|
failure_demo.py:79: AssertionError
|
2015-06-07 05:30:49 +08:00
|
|
|
_______ TestSpecialisedExplanations.test_not_in_text_multiline ________
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2015-06-07 05:30:49 +08:00
|
|
|
self = <failure_demo.TestSpecialisedExplanations object at 0xdeadbeef>
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2011-02-03 22:14:50 +08:00
|
|
|
def test_not_in_text_multiline(self):
|
|
|
|
text = 'some multiline\ntext\nwhich\nincludes foo\nand a\ntail'
|
|
|
|
> assert 'foo' not in text
|
|
|
|
E assert 'foo' not in 'some multiline\ntext\nw...ncludes foo\nand a\ntail'
|
|
|
|
E 'foo' is contained here:
|
|
|
|
E some multiline
|
|
|
|
E text
|
|
|
|
E which
|
|
|
|
E includes foo
|
|
|
|
E ? +++
|
|
|
|
E and a
|
|
|
|
E tail
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2016-03-01 04:52:56 +08:00
|
|
|
failure_demo.py:83: AssertionError
|
2015-06-07 05:30:49 +08:00
|
|
|
_______ TestSpecialisedExplanations.test_not_in_text_single ________
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2015-06-07 05:30:49 +08:00
|
|
|
self = <failure_demo.TestSpecialisedExplanations object at 0xdeadbeef>
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2011-02-03 22:14:50 +08:00
|
|
|
def test_not_in_text_single(self):
|
|
|
|
text = 'single foo line'
|
|
|
|
> assert 'foo' not in text
|
|
|
|
E assert 'foo' not in 'single foo line'
|
|
|
|
E 'foo' is contained here:
|
|
|
|
E single foo line
|
|
|
|
E ? +++
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2016-03-01 04:52:56 +08:00
|
|
|
failure_demo.py:87: AssertionError
|
2015-06-07 05:30:49 +08:00
|
|
|
_______ TestSpecialisedExplanations.test_not_in_text_single_long ________
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2015-06-07 05:30:49 +08:00
|
|
|
self = <failure_demo.TestSpecialisedExplanations object at 0xdeadbeef>
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2011-02-03 22:14:50 +08:00
|
|
|
def test_not_in_text_single_long(self):
|
|
|
|
text = 'head ' * 50 + 'foo ' + 'tail ' * 20
|
|
|
|
> assert 'foo' not in text
|
|
|
|
E assert 'foo' not in 'head head head head hea...ail tail tail tail tail '
|
|
|
|
E 'foo' is contained here:
|
2014-01-29 20:47:11 +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 ? +++
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2016-03-01 04:52:56 +08:00
|
|
|
failure_demo.py:91: AssertionError
|
2015-09-22 20:02:11 +08:00
|
|
|
______ TestSpecialisedExplanations.test_not_in_text_single_long_term _______
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2015-06-07 05:30:49 +08:00
|
|
|
self = <failure_demo.TestSpecialisedExplanations object at 0xdeadbeef>
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2011-02-03 22:14:50 +08:00
|
|
|
def test_not_in_text_single_long_term(self):
|
|
|
|
text = 'head ' * 50 + 'f'*70 + 'tail ' * 20
|
|
|
|
> assert 'f'*70 not in text
|
|
|
|
E assert 'fffffffffff...ffffffffffff' not in 'head head he...l tail tail '
|
|
|
|
E 'ffffffffffffffffff...fffffffffffffffffff' is contained here:
|
2014-01-29 20:47:11 +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 ? ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2016-03-01 04:52:56 +08:00
|
|
|
failure_demo.py:95: AssertionError
|
2015-06-07 05:30:49 +08:00
|
|
|
_______ test_attribute ________
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2010-11-25 19:11:10 +08:00
|
|
|
def test_attribute():
|
|
|
|
class Foo(object):
|
|
|
|
b = 1
|
|
|
|
i = Foo()
|
|
|
|
> assert i.b == 2
|
|
|
|
E assert 1 == 2
|
2015-09-22 22:52:35 +08:00
|
|
|
E + where 1 = <failure_demo.test_attribute.<locals>.Foo object at 0xdeadbeef>.b
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2016-03-01 04:52:56 +08:00
|
|
|
failure_demo.py:102: AssertionError
|
2015-06-07 05:30:49 +08:00
|
|
|
_______ test_attribute_instance ________
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2010-11-25 19:11:10 +08:00
|
|
|
def test_attribute_instance():
|
|
|
|
class Foo(object):
|
|
|
|
b = 1
|
|
|
|
> assert Foo().b == 2
|
|
|
|
E assert 1 == 2
|
2015-09-22 22:52:35 +08:00
|
|
|
E + where 1 = <failure_demo.test_attribute_instance.<locals>.Foo object at 0xdeadbeef>.b
|
|
|
|
E + where <failure_demo.test_attribute_instance.<locals>.Foo object at 0xdeadbeef> = <class 'failure_demo.test_attribute_instance.<locals>.Foo'>()
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2016-03-01 04:52:56 +08:00
|
|
|
failure_demo.py:108: AssertionError
|
2015-06-07 05:30:49 +08:00
|
|
|
_______ test_attribute_failure ________
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2010-11-25 19:11:10 +08:00
|
|
|
def test_attribute_failure():
|
|
|
|
class Foo(object):
|
|
|
|
def _get_b(self):
|
|
|
|
raise Exception('Failed to get attrib')
|
|
|
|
b = property(_get_b)
|
|
|
|
i = Foo()
|
|
|
|
> assert i.b == 2
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2016-03-01 04:52:56 +08:00
|
|
|
failure_demo.py:117:
|
2015-09-22 20:02:11 +08:00
|
|
|
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2015-09-22 22:52:35 +08:00
|
|
|
self = <failure_demo.test_attribute_failure.<locals>.Foo object at 0xdeadbeef>
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2010-11-25 19:11:10 +08:00
|
|
|
def _get_b(self):
|
|
|
|
> raise Exception('Failed to get attrib')
|
|
|
|
E Exception: Failed to get attrib
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2016-03-01 04:52:56 +08:00
|
|
|
failure_demo.py:114: Exception
|
2015-06-07 05:30:49 +08:00
|
|
|
_______ test_attribute_multiple ________
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2010-11-25 19:11:10 +08:00
|
|
|
def test_attribute_multiple():
|
|
|
|
class Foo(object):
|
|
|
|
b = 1
|
|
|
|
class Bar(object):
|
|
|
|
b = 2
|
|
|
|
> assert Foo().b == Bar().b
|
|
|
|
E assert 1 == 2
|
2015-09-22 22:52:35 +08:00
|
|
|
E + where 1 = <failure_demo.test_attribute_multiple.<locals>.Foo object at 0xdeadbeef>.b
|
|
|
|
E + where <failure_demo.test_attribute_multiple.<locals>.Foo object at 0xdeadbeef> = <class 'failure_demo.test_attribute_multiple.<locals>.Foo'>()
|
|
|
|
E + and 2 = <failure_demo.test_attribute_multiple.<locals>.Bar object at 0xdeadbeef>.b
|
|
|
|
E + where <failure_demo.test_attribute_multiple.<locals>.Bar object at 0xdeadbeef> = <class 'failure_demo.test_attribute_multiple.<locals>.Bar'>()
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2016-03-01 04:52:56 +08:00
|
|
|
failure_demo.py:125: AssertionError
|
2015-06-07 05:30:49 +08:00
|
|
|
_______ TestRaises.test_raises ________
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2015-09-22 22:52:35 +08:00
|
|
|
self = <failure_demo.TestRaises object at 0xdeadbeef>
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2010-11-25 19:11:10 +08:00
|
|
|
def test_raises(self):
|
|
|
|
s = 'qwe'
|
|
|
|
> raises(TypeError, "int(s)")
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2016-03-01 04:52:56 +08:00
|
|
|
failure_demo.py:134:
|
2015-09-22 20:02:11 +08:00
|
|
|
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2010-11-25 19:11:10 +08:00
|
|
|
> int(s)
|
|
|
|
E ValueError: invalid literal for int() with base 10: 'qwe'
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2016-08-24 05:59:59 +08:00
|
|
|
<0-codegen $PYTHON_PREFIX/lib/python3.5/site-packages/_pytest/python.py:1189>:1: ValueError
|
2015-06-07 05:30:49 +08:00
|
|
|
_______ TestRaises.test_raises_doesnt ________
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2015-09-22 22:52:35 +08:00
|
|
|
self = <failure_demo.TestRaises object at 0xdeadbeef>
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2010-11-25 19:11:10 +08:00
|
|
|
def test_raises_doesnt(self):
|
|
|
|
> raises(IOError, "int('3')")
|
2016-03-01 04:52:56 +08:00
|
|
|
E Failed: DID NOT RAISE <class 'OSError'>
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2016-03-01 04:52:56 +08:00
|
|
|
failure_demo.py:137: Failed
|
2015-06-07 05:30:49 +08:00
|
|
|
_______ TestRaises.test_raise ________
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2015-09-22 22:52:35 +08:00
|
|
|
self = <failure_demo.TestRaises object at 0xdeadbeef>
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2010-11-25 19:11:10 +08:00
|
|
|
def test_raise(self):
|
|
|
|
> raise ValueError("demo error")
|
|
|
|
E ValueError: demo error
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2016-03-01 04:52:56 +08:00
|
|
|
failure_demo.py:140: ValueError
|
2015-06-07 05:30:49 +08:00
|
|
|
_______ TestRaises.test_tupleerror ________
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2015-09-22 22:52:35 +08:00
|
|
|
self = <failure_demo.TestRaises object at 0xdeadbeef>
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2010-11-25 19:11:10 +08:00
|
|
|
def test_tupleerror(self):
|
|
|
|
> a,b = [1]
|
2016-05-31 17:15:57 +08:00
|
|
|
E ValueError: not enough values to unpack (expected 2, got 1)
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2016-03-01 04:52:56 +08:00
|
|
|
failure_demo.py:143: ValueError
|
2015-09-22 20:02:11 +08:00
|
|
|
______ TestRaises.test_reinterpret_fails_with_print_for_the_fun_of_it ______
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2015-09-22 22:52:35 +08:00
|
|
|
self = <failure_demo.TestRaises object at 0xdeadbeef>
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2010-11-25 19:11:10 +08:00
|
|
|
def test_reinterpret_fails_with_print_for_the_fun_of_it(self):
|
|
|
|
l = [1,2,3]
|
|
|
|
print ("l is %r" % l)
|
|
|
|
> a,b = l.pop()
|
|
|
|
E TypeError: 'int' object is not iterable
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2016-03-01 04:52:56 +08:00
|
|
|
failure_demo.py:148: TypeError
|
2015-09-22 20:02:11 +08:00
|
|
|
--------------------------- Captured stdout call ---------------------------
|
2010-11-25 19:11:10 +08:00
|
|
|
l is [1, 2, 3]
|
2015-06-07 05:30:49 +08:00
|
|
|
_______ TestRaises.test_some_error ________
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2015-09-22 22:52:35 +08:00
|
|
|
self = <failure_demo.TestRaises object at 0xdeadbeef>
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2010-11-25 19:11:10 +08:00
|
|
|
def test_some_error(self):
|
|
|
|
> if namenotexi:
|
2015-09-22 22:52:35 +08:00
|
|
|
E NameError: name 'namenotexi' is not defined
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2016-03-01 04:52:56 +08:00
|
|
|
failure_demo.py:151: NameError
|
2015-06-07 05:30:49 +08:00
|
|
|
_______ test_dynamic_compile_shows_nicely ________
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2010-11-25 19:11:10 +08:00
|
|
|
def test_dynamic_compile_shows_nicely():
|
|
|
|
src = 'def foo():\n assert 1 == 0\n'
|
|
|
|
name = 'abc-123'
|
|
|
|
module = py.std.imp.new_module(name)
|
2016-03-01 04:52:56 +08:00
|
|
|
code = _pytest._code.compile(src, name, 'exec')
|
2010-11-25 19:11:10 +08:00
|
|
|
py.builtin.exec_(code, module.__dict__)
|
|
|
|
py.std.sys.modules[name] = module
|
|
|
|
> module.foo()
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2016-03-01 04:52:56 +08:00
|
|
|
failure_demo.py:166:
|
2015-09-22 20:02:11 +08:00
|
|
|
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2010-11-25 19:11:10 +08:00
|
|
|
def foo():
|
|
|
|
> assert 1 == 0
|
2016-08-02 02:46:34 +08:00
|
|
|
E AssertionError
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2016-03-01 04:52:56 +08:00
|
|
|
<2-codegen 'abc-123' $REGENDOC_TMPDIR/assertion/failure_demo.py:163>:2: AssertionError
|
2015-06-07 05:30:49 +08:00
|
|
|
_______ TestMoreErrors.test_complex_error ________
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2015-09-22 22:52:35 +08:00
|
|
|
self = <failure_demo.TestMoreErrors object at 0xdeadbeef>
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2010-11-25 19:11:10 +08:00
|
|
|
def test_complex_error(self):
|
|
|
|
def f():
|
|
|
|
return 44
|
|
|
|
def g():
|
|
|
|
return 43
|
|
|
|
> somefunc(f(), g())
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2016-03-01 04:52:56 +08:00
|
|
|
failure_demo.py:176:
|
2015-09-22 20:02:11 +08:00
|
|
|
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
|
2016-03-01 04:52:56 +08:00
|
|
|
failure_demo.py:9: in somefunc
|
2014-07-17 22:55:24 +08:00
|
|
|
otherfunc(x,y)
|
2015-09-22 20:02:11 +08:00
|
|
|
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2010-11-25 19:11:10 +08:00
|
|
|
a = 44, b = 43
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2010-11-25 19:11:10 +08:00
|
|
|
def otherfunc(a,b):
|
|
|
|
> assert a==b
|
|
|
|
E assert 44 == 43
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2016-03-01 04:52:56 +08:00
|
|
|
failure_demo.py:6: AssertionError
|
2015-06-07 05:30:49 +08:00
|
|
|
_______ TestMoreErrors.test_z1_unpack_error ________
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2015-09-22 22:52:35 +08:00
|
|
|
self = <failure_demo.TestMoreErrors object at 0xdeadbeef>
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2010-11-25 19:11:10 +08:00
|
|
|
def test_z1_unpack_error(self):
|
|
|
|
l = []
|
|
|
|
> a,b = l
|
2016-05-31 17:15:57 +08:00
|
|
|
E ValueError: not enough values to unpack (expected 2, got 0)
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2016-03-01 04:52:56 +08:00
|
|
|
failure_demo.py:180: ValueError
|
2015-06-07 05:30:49 +08:00
|
|
|
_______ TestMoreErrors.test_z2_type_error ________
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2015-09-22 22:52:35 +08:00
|
|
|
self = <failure_demo.TestMoreErrors object at 0xdeadbeef>
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2010-11-25 19:11:10 +08:00
|
|
|
def test_z2_type_error(self):
|
|
|
|
l = 3
|
|
|
|
> a,b = l
|
|
|
|
E TypeError: 'int' object is not iterable
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2016-03-01 04:52:56 +08:00
|
|
|
failure_demo.py:184: TypeError
|
2015-06-07 05:30:49 +08:00
|
|
|
_______ TestMoreErrors.test_startswith ________
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2015-09-22 22:52:35 +08:00
|
|
|
self = <failure_demo.TestMoreErrors object at 0xdeadbeef>
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2010-11-25 19:11:10 +08:00
|
|
|
def test_startswith(self):
|
|
|
|
s = "123"
|
|
|
|
g = "456"
|
|
|
|
> assert s.startswith(g)
|
2016-08-02 02:46:34 +08:00
|
|
|
E assert False
|
|
|
|
E + where False = <built-in method startswith of str object at 0xdeadbeef>('456')
|
|
|
|
E + where <built-in method startswith of str object at 0xdeadbeef> = '123'.startswith
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2016-03-01 04:52:56 +08:00
|
|
|
failure_demo.py:189: AssertionError
|
2015-06-07 05:30:49 +08:00
|
|
|
_______ TestMoreErrors.test_startswith_nested ________
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2015-09-22 22:52:35 +08:00
|
|
|
self = <failure_demo.TestMoreErrors object at 0xdeadbeef>
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2010-11-25 19:11:10 +08:00
|
|
|
def test_startswith_nested(self):
|
|
|
|
def f():
|
|
|
|
return "123"
|
|
|
|
def g():
|
|
|
|
return "456"
|
|
|
|
> assert f().startswith(g())
|
2016-08-02 02:46:34 +08:00
|
|
|
E assert False
|
|
|
|
E + where False = <built-in method startswith of str object at 0xdeadbeef>('456')
|
|
|
|
E + where <built-in method startswith of str object at 0xdeadbeef> = '123'.startswith
|
|
|
|
E + where '123' = <function TestMoreErrors.test_startswith_nested.<locals>.f at 0xdeadbeef>()
|
|
|
|
E + and '456' = <function TestMoreErrors.test_startswith_nested.<locals>.g at 0xdeadbeef>()
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2016-03-01 04:52:56 +08:00
|
|
|
failure_demo.py:196: AssertionError
|
2015-06-07 05:30:49 +08:00
|
|
|
_______ TestMoreErrors.test_global_func ________
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2015-09-22 22:52:35 +08:00
|
|
|
self = <failure_demo.TestMoreErrors object at 0xdeadbeef>
|
2014-01-29 20:47:11 +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)
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2016-03-01 04:52:56 +08:00
|
|
|
failure_demo.py:199: AssertionError
|
2015-06-07 05:30:49 +08:00
|
|
|
_______ TestMoreErrors.test_instance ________
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2015-09-22 22:52:35 +08:00
|
|
|
self = <failure_demo.TestMoreErrors object at 0xdeadbeef>
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2010-11-25 19:11:10 +08:00
|
|
|
def test_instance(self):
|
|
|
|
self.x = 6*7
|
|
|
|
> assert self.x != 42
|
|
|
|
E assert 42 != 42
|
2015-09-22 22:52:35 +08:00
|
|
|
E + where 42 = <failure_demo.TestMoreErrors object at 0xdeadbeef>.x
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2016-03-01 04:52:56 +08:00
|
|
|
failure_demo.py:203: AssertionError
|
2015-06-07 05:30:49 +08:00
|
|
|
_______ TestMoreErrors.test_compare ________
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2015-09-22 22:52:35 +08:00
|
|
|
self = <failure_demo.TestMoreErrors object at 0xdeadbeef>
|
2014-01-29 20:47:11 +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)
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2016-03-01 04:52:56 +08:00
|
|
|
failure_demo.py:206: AssertionError
|
2015-06-07 05:30:49 +08:00
|
|
|
_______ TestMoreErrors.test_try_finally ________
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2015-09-22 22:52:35 +08:00
|
|
|
self = <failure_demo.TestMoreErrors object at 0xdeadbeef>
|
2014-01-29 20:47:11 +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
|
2014-01-29 20:47:11 +08:00
|
|
|
|
2016-03-01 04:52:56 +08:00
|
|
|
failure_demo.py:211: AssertionError
|
2015-06-07 05:30:49 +08:00
|
|
|
_______ TestCustomAssertMsg.test_single_line ________
|
2014-09-24 20:46:56 +08:00
|
|
|
|
2015-09-22 22:52:35 +08:00
|
|
|
self = <failure_demo.TestCustomAssertMsg object at 0xdeadbeef>
|
2014-09-24 20:46:56 +08:00
|
|
|
|
|
|
|
def test_single_line(self):
|
|
|
|
class A:
|
|
|
|
a = 1
|
|
|
|
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
|
2014-09-24 20:46:56 +08:00
|
|
|
|
2016-03-01 04:52:56 +08:00
|
|
|
failure_demo.py:222: AssertionError
|
2015-06-07 05:30:49 +08:00
|
|
|
_______ TestCustomAssertMsg.test_multiline ________
|
2014-09-24 20:46:56 +08:00
|
|
|
|
2015-09-22 22:52:35 +08:00
|
|
|
self = <failure_demo.TestCustomAssertMsg object at 0xdeadbeef>
|
2014-09-24 20:46:56 +08:00
|
|
|
|
|
|
|
def test_multiline(self):
|
|
|
|
class A:
|
|
|
|
a = 1
|
|
|
|
b = 2
|
|
|
|
> assert A.a == b, "A.a appears not to be b\n" \
|
|
|
|
"or does not appear to be b\none of those"
|
|
|
|
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
|
2014-09-24 20:46:56 +08:00
|
|
|
|
2016-03-01 04:52:56 +08:00
|
|
|
failure_demo.py:228: AssertionError
|
2015-06-07 05:30:49 +08:00
|
|
|
_______ TestCustomAssertMsg.test_custom_repr ________
|
2014-09-24 20:46:56 +08:00
|
|
|
|
2015-09-22 22:52:35 +08:00
|
|
|
self = <failure_demo.TestCustomAssertMsg object at 0xdeadbeef>
|
2014-09-24 20:46:56 +08:00
|
|
|
|
|
|
|
def test_custom_repr(self):
|
|
|
|
class JSON:
|
|
|
|
a = 1
|
|
|
|
def __repr__(self):
|
|
|
|
return "This is JSON\n{\n 'foo': 'bar'\n}"
|
|
|
|
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
|
|
|
|
|
2016-03-01 04:52:56 +08:00
|
|
|
failure_demo.py:238: AssertionError
|
2015-06-07 05:30:49 +08:00
|
|
|
======= 42 failed in 0.12 seconds ========
|