2010-11-25 19:11:10 +08:00
|
|
|
|
|
|
|
.. _`tbreportdemo`:
|
|
|
|
|
|
|
|
Demo of Python failure reports with py.test
|
|
|
|
==================================================
|
|
|
|
|
|
|
|
Here is a nice run of several tens of failures
|
|
|
|
and how py.test presents things (unfortunately
|
|
|
|
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
|
|
|
|
|
|
|
assertion $ py.test failure_demo.py
|
|
|
|
=========================== test session starts ============================
|
2013-04-30 18:26:30 +08:00
|
|
|
platform linux2 -- Python 2.7.3 -- pytest-2.3.5
|
2012-10-07 19:06:17 +08:00
|
|
|
collected 39 items
|
2010-11-25 19:11:10 +08:00
|
|
|
|
2011-02-03 22:14:50 +08:00
|
|
|
failure_demo.py FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
|
2010-11-25 19:11:10 +08:00
|
|
|
|
|
|
|
================================= FAILURES =================================
|
|
|
|
____________________________ test_generative[0] ____________________________
|
|
|
|
|
|
|
|
param1 = 3, param2 = 6
|
|
|
|
|
|
|
|
def test_generative(param1, param2):
|
|
|
|
> assert param1 * 2 < param2
|
|
|
|
E assert (3 * 2) < 6
|
|
|
|
|
|
|
|
failure_demo.py:15: AssertionError
|
|
|
|
_________________________ TestFailing.test_simple __________________________
|
|
|
|
|
2013-04-30 18:26:30 +08:00
|
|
|
self = <failure_demo.TestFailing object at 0x1445e10>
|
2010-11-25 19:11:10 +08:00
|
|
|
|
|
|
|
def test_simple(self):
|
|
|
|
def f():
|
|
|
|
return 42
|
|
|
|
def g():
|
|
|
|
return 43
|
|
|
|
|
|
|
|
> assert f() == g()
|
|
|
|
E assert 42 == 43
|
2013-04-30 18:26:30 +08:00
|
|
|
E + where 42 = <function f at 0x137c6e0>()
|
|
|
|
E + and 43 = <function g at 0x137c758>()
|
2010-11-25 19:11:10 +08:00
|
|
|
|
|
|
|
failure_demo.py:28: AssertionError
|
|
|
|
____________________ TestFailing.test_simple_multiline _____________________
|
|
|
|
|
2013-04-30 18:26:30 +08:00
|
|
|
self = <failure_demo.TestFailing object at 0x135a1d0>
|
2010-11-25 19:11:10 +08:00
|
|
|
|
|
|
|
def test_simple_multiline(self):
|
|
|
|
otherfunc_multi(
|
|
|
|
42,
|
|
|
|
> 6*9)
|
|
|
|
|
2010-11-26 20:26:56 +08:00
|
|
|
failure_demo.py:33:
|
|
|
|
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
|
2010-11-25 19:11:10 +08:00
|
|
|
|
|
|
|
a = 42, b = 54
|
|
|
|
|
|
|
|
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
|
|
|
|
|
2011-08-21 00:37:00 +08:00
|
|
|
failure_demo.py:11: AssertionError
|
2010-11-25 19:11:10 +08:00
|
|
|
___________________________ TestFailing.test_not ___________________________
|
|
|
|
|
2013-04-30 18:26:30 +08:00
|
|
|
self = <failure_demo.TestFailing object at 0x1458ed0>
|
2010-11-25 19:11:10 +08:00
|
|
|
|
|
|
|
def test_not(self):
|
|
|
|
def f():
|
|
|
|
return 42
|
|
|
|
> assert not f()
|
|
|
|
E assert not 42
|
2013-04-30 18:26:30 +08:00
|
|
|
E + where 42 = <function f at 0x137caa0>()
|
2010-11-25 19:11:10 +08:00
|
|
|
|
|
|
|
failure_demo.py:38: AssertionError
|
|
|
|
_________________ TestSpecialisedExplanations.test_eq_text _________________
|
|
|
|
|
2013-04-30 18:26:30 +08:00
|
|
|
self = <failure_demo.TestSpecialisedExplanations object at 0x14451d0>
|
2010-11-25 19:11:10 +08:00
|
|
|
|
|
|
|
def test_eq_text(self):
|
|
|
|
> assert 'spam' == 'eggs'
|
|
|
|
E assert 'spam' == 'eggs'
|
|
|
|
E - spam
|
|
|
|
E + eggs
|
|
|
|
|
|
|
|
failure_demo.py:42: AssertionError
|
|
|
|
_____________ TestSpecialisedExplanations.test_eq_similar_text _____________
|
|
|
|
|
2013-04-30 18:26:30 +08:00
|
|
|
self = <failure_demo.TestSpecialisedExplanations object at 0x1458c90>
|
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 ? ^
|
|
|
|
|
|
|
|
failure_demo.py:45: AssertionError
|
|
|
|
____________ TestSpecialisedExplanations.test_eq_multiline_text ____________
|
|
|
|
|
2013-04-30 18:26:30 +08:00
|
|
|
self = <failure_demo.TestSpecialisedExplanations object at 0x1434390>
|
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
|
|
|
|
|
|
|
|
failure_demo.py:48: AssertionError
|
|
|
|
______________ TestSpecialisedExplanations.test_eq_long_text _______________
|
|
|
|
|
2013-04-30 18:26:30 +08:00
|
|
|
self = <failure_demo.TestSpecialisedExplanations object at 0x1459f50>
|
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 ? ^
|
|
|
|
|
|
|
|
failure_demo.py:53: AssertionError
|
|
|
|
_________ TestSpecialisedExplanations.test_eq_long_text_multiline __________
|
|
|
|
|
2013-04-30 18:26:30 +08:00
|
|
|
self = <failure_demo.TestSpecialisedExplanations object at 0x135a790>
|
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
|
|
|
|
|
|
|
|
failure_demo.py:58: AssertionError
|
|
|
|
_________________ TestSpecialisedExplanations.test_eq_list _________________
|
|
|
|
|
2013-04-30 18:26:30 +08:00
|
|
|
self = <failure_demo.TestSpecialisedExplanations object at 0x138dfd0>
|
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
|
|
|
|
|
|
|
|
failure_demo.py:61: AssertionError
|
|
|
|
______________ TestSpecialisedExplanations.test_eq_list_long _______________
|
|
|
|
|
2013-04-30 18:26:30 +08:00
|
|
|
self = <failure_demo.TestSpecialisedExplanations object at 0x135a990>
|
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
|
|
|
|
|
|
|
|
failure_demo.py:66: AssertionError
|
|
|
|
_________________ TestSpecialisedExplanations.test_eq_dict _________________
|
|
|
|
|
2013-04-30 18:26:30 +08:00
|
|
|
self = <failure_demo.TestSpecialisedExplanations object at 0x1459310>
|
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}
|
|
|
|
E Hiding 1 identical items, use -v to show
|
|
|
|
E Differing items:
|
|
|
|
E {'b': 1} != {'b': 2}
|
|
|
|
E Left contains more items:
|
|
|
|
E {'c': 0}
|
|
|
|
E Right contains more items:
|
|
|
|
E {'d': 0}
|
2010-11-25 19:11:10 +08:00
|
|
|
|
|
|
|
failure_demo.py:69: AssertionError
|
|
|
|
_________________ TestSpecialisedExplanations.test_eq_set __________________
|
|
|
|
|
2013-04-30 18:26:30 +08:00
|
|
|
self = <failure_demo.TestSpecialisedExplanations object at 0x1434310>
|
2010-11-25 19:11:10 +08:00
|
|
|
|
|
|
|
def test_eq_set(self):
|
|
|
|
> assert set([0, 10, 11, 12]) == set([0, 20, 21])
|
|
|
|
E assert set([0, 10, 11, 12]) == set([0, 20, 21])
|
|
|
|
E Extra items in the left set:
|
|
|
|
E 10
|
|
|
|
E 11
|
|
|
|
E 12
|
|
|
|
E Extra items in the right set:
|
|
|
|
E 20
|
|
|
|
E 21
|
|
|
|
|
|
|
|
failure_demo.py:72: AssertionError
|
|
|
|
_____________ TestSpecialisedExplanations.test_eq_longer_list ______________
|
|
|
|
|
2013-04-30 18:26:30 +08:00
|
|
|
self = <failure_demo.TestSpecialisedExplanations object at 0x138ded0>
|
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
|
|
|
|
|
|
|
|
failure_demo.py:75: AssertionError
|
|
|
|
_________________ TestSpecialisedExplanations.test_in_list _________________
|
|
|
|
|
2013-04-30 18:26:30 +08:00
|
|
|
self = <failure_demo.TestSpecialisedExplanations object at 0x1459e10>
|
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]
|
|
|
|
|
|
|
|
failure_demo.py:78: AssertionError
|
2011-02-03 22:14:50 +08:00
|
|
|
__________ TestSpecialisedExplanations.test_not_in_text_multiline __________
|
|
|
|
|
2013-04-30 18:26:30 +08:00
|
|
|
self = <failure_demo.TestSpecialisedExplanations object at 0x1434950>
|
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
|
|
|
|
|
|
|
|
failure_demo.py:82: AssertionError
|
|
|
|
___________ TestSpecialisedExplanations.test_not_in_text_single ____________
|
|
|
|
|
2013-04-30 18:26:30 +08:00
|
|
|
self = <failure_demo.TestSpecialisedExplanations object at 0x138dbd0>
|
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 ? +++
|
|
|
|
|
|
|
|
failure_demo.py:86: AssertionError
|
|
|
|
_________ TestSpecialisedExplanations.test_not_in_text_single_long _________
|
|
|
|
|
2013-04-30 18:26:30 +08:00
|
|
|
self = <failure_demo.TestSpecialisedExplanations object at 0x14593d0>
|
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:
|
|
|
|
E head head foo tail tail tail tail tail tail tail tail tail tail tail tail tail tail tail tail tail tail tail tail
|
|
|
|
E ? +++
|
|
|
|
|
|
|
|
failure_demo.py:90: AssertionError
|
|
|
|
______ TestSpecialisedExplanations.test_not_in_text_single_long_term _______
|
|
|
|
|
2013-04-30 18:26:30 +08:00
|
|
|
self = <failure_demo.TestSpecialisedExplanations object at 0x1459650>
|
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:
|
|
|
|
E head head fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffftail tail tail tail tail tail tail tail tail tail tail tail tail tail tail tail tail tail tail tail
|
|
|
|
E ? ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
|
|
|
|
|
|
failure_demo.py:94: AssertionError
|
2010-11-25 19:11:10 +08:00
|
|
|
______________________________ test_attribute ______________________________
|
|
|
|
|
|
|
|
def test_attribute():
|
|
|
|
class Foo(object):
|
|
|
|
b = 1
|
|
|
|
i = Foo()
|
|
|
|
> assert i.b == 2
|
|
|
|
E assert 1 == 2
|
2013-04-30 18:26:30 +08:00
|
|
|
E + where 1 = <failure_demo.Foo object at 0x1434850>.b
|
2010-11-25 19:11:10 +08:00
|
|
|
|
2011-02-03 22:14:50 +08:00
|
|
|
failure_demo.py:101: AssertionError
|
2010-11-25 19:11:10 +08:00
|
|
|
_________________________ test_attribute_instance __________________________
|
|
|
|
|
|
|
|
def test_attribute_instance():
|
|
|
|
class Foo(object):
|
|
|
|
b = 1
|
|
|
|
> assert Foo().b == 2
|
|
|
|
E assert 1 == 2
|
2013-04-30 18:26:30 +08:00
|
|
|
E + where 1 = <failure_demo.Foo object at 0x1459dd0>.b
|
|
|
|
E + where <failure_demo.Foo object at 0x1459dd0> = <class 'failure_demo.Foo'>()
|
2010-11-25 19:11:10 +08:00
|
|
|
|
2011-02-03 22:14:50 +08:00
|
|
|
failure_demo.py:107: AssertionError
|
2010-11-25 19:11:10 +08:00
|
|
|
__________________________ test_attribute_failure __________________________
|
|
|
|
|
|
|
|
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
|
|
|
|
|
2011-02-03 22:14:50 +08:00
|
|
|
failure_demo.py:116:
|
2010-11-26 20:26:56 +08:00
|
|
|
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
|
2010-11-25 19:11:10 +08:00
|
|
|
|
2013-04-30 18:26:30 +08:00
|
|
|
self = <failure_demo.Foo object at 0x1434150>
|
2010-11-25 19:11:10 +08:00
|
|
|
|
|
|
|
def _get_b(self):
|
|
|
|
> raise Exception('Failed to get attrib')
|
|
|
|
E Exception: Failed to get attrib
|
|
|
|
|
2011-02-03 22:14:50 +08:00
|
|
|
failure_demo.py:113: Exception
|
2010-11-25 19:11:10 +08:00
|
|
|
_________________________ test_attribute_multiple __________________________
|
|
|
|
|
|
|
|
def test_attribute_multiple():
|
|
|
|
class Foo(object):
|
|
|
|
b = 1
|
|
|
|
class Bar(object):
|
|
|
|
b = 2
|
|
|
|
> assert Foo().b == Bar().b
|
|
|
|
E assert 1 == 2
|
2013-04-30 18:26:30 +08:00
|
|
|
E + where 1 = <failure_demo.Foo object at 0x14590d0>.b
|
|
|
|
E + where <failure_demo.Foo object at 0x14590d0> = <class 'failure_demo.Foo'>()
|
|
|
|
E + and 2 = <failure_demo.Bar object at 0x1459b10>.b
|
|
|
|
E + where <failure_demo.Bar object at 0x1459b10> = <class 'failure_demo.Bar'>()
|
2010-11-25 19:11:10 +08:00
|
|
|
|
2011-02-03 22:14:50 +08:00
|
|
|
failure_demo.py:124: AssertionError
|
2010-11-25 19:11:10 +08:00
|
|
|
__________________________ TestRaises.test_raises __________________________
|
|
|
|
|
2013-04-30 18:26:30 +08:00
|
|
|
self = <failure_demo.TestRaises instance at 0x13a0d88>
|
2010-11-25 19:11:10 +08:00
|
|
|
|
|
|
|
def test_raises(self):
|
|
|
|
s = 'qwe'
|
|
|
|
> raises(TypeError, "int(s)")
|
|
|
|
|
2011-02-03 22:14:50 +08:00
|
|
|
failure_demo.py:133:
|
2010-11-26 20:26:56 +08:00
|
|
|
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
|
2010-11-25 19:11:10 +08:00
|
|
|
|
|
|
|
> int(s)
|
|
|
|
E ValueError: invalid literal for int() with base 10: 'qwe'
|
|
|
|
|
2013-04-30 18:26:30 +08:00
|
|
|
<0-codegen /home/hpk/p/pytest/.tox/regen/local/lib/python2.7/site-packages/_pytest/python.py:858>:1: ValueError
|
2010-11-25 19:11:10 +08:00
|
|
|
______________________ TestRaises.test_raises_doesnt _______________________
|
|
|
|
|
2013-04-30 18:26:30 +08:00
|
|
|
self = <failure_demo.TestRaises instance at 0x145fcf8>
|
2010-11-25 19:11:10 +08:00
|
|
|
|
|
|
|
def test_raises_doesnt(self):
|
|
|
|
> raises(IOError, "int('3')")
|
|
|
|
E Failed: DID NOT RAISE
|
|
|
|
|
2011-02-03 22:14:50 +08:00
|
|
|
failure_demo.py:136: Failed
|
2010-11-25 19:11:10 +08:00
|
|
|
__________________________ TestRaises.test_raise ___________________________
|
|
|
|
|
2013-04-30 18:26:30 +08:00
|
|
|
self = <failure_demo.TestRaises instance at 0x13a9ea8>
|
2010-11-25 19:11:10 +08:00
|
|
|
|
|
|
|
def test_raise(self):
|
|
|
|
> raise ValueError("demo error")
|
|
|
|
E ValueError: demo error
|
|
|
|
|
2011-02-03 22:14:50 +08:00
|
|
|
failure_demo.py:139: ValueError
|
2010-11-25 19:11:10 +08:00
|
|
|
________________________ TestRaises.test_tupleerror ________________________
|
|
|
|
|
2013-04-30 18:26:30 +08:00
|
|
|
self = <failure_demo.TestRaises instance at 0x13843f8>
|
2010-11-25 19:11:10 +08:00
|
|
|
|
|
|
|
def test_tupleerror(self):
|
|
|
|
> a,b = [1]
|
|
|
|
E ValueError: need more than 1 value to unpack
|
|
|
|
|
2011-02-03 22:14:50 +08:00
|
|
|
failure_demo.py:142: ValueError
|
2010-11-25 19:11:10 +08:00
|
|
|
______ TestRaises.test_reinterpret_fails_with_print_for_the_fun_of_it ______
|
|
|
|
|
2013-04-30 18:26:30 +08:00
|
|
|
self = <failure_demo.TestRaises instance at 0x14532d8>
|
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
|
|
|
|
|
2011-02-03 22:14:50 +08:00
|
|
|
failure_demo.py:147: TypeError
|
2010-11-25 19:11:10 +08:00
|
|
|
----------------------------- Captured stdout ------------------------------
|
|
|
|
l is [1, 2, 3]
|
|
|
|
________________________ TestRaises.test_some_error ________________________
|
|
|
|
|
2013-04-30 18:26:30 +08:00
|
|
|
self = <failure_demo.TestRaises instance at 0x139d290>
|
2010-11-25 19:11:10 +08:00
|
|
|
|
|
|
|
def test_some_error(self):
|
|
|
|
> if namenotexi:
|
2012-10-19 17:12:13 +08:00
|
|
|
E NameError: global name 'namenotexi' is not defined
|
2010-11-25 19:11:10 +08:00
|
|
|
|
2011-02-03 22:14:50 +08:00
|
|
|
failure_demo.py:150: NameError
|
2010-11-25 19:11:10 +08:00
|
|
|
____________________ test_dynamic_compile_shows_nicely _____________________
|
|
|
|
|
|
|
|
def test_dynamic_compile_shows_nicely():
|
|
|
|
src = 'def foo():\n assert 1 == 0\n'
|
|
|
|
name = 'abc-123'
|
|
|
|
module = py.std.imp.new_module(name)
|
|
|
|
code = py.code.compile(src, name, 'exec')
|
|
|
|
py.builtin.exec_(code, module.__dict__)
|
|
|
|
py.std.sys.modules[name] = module
|
|
|
|
> module.foo()
|
|
|
|
|
2011-02-03 22:14:50 +08:00
|
|
|
failure_demo.py:165:
|
2010-11-26 20:26:56 +08:00
|
|
|
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
|
2010-11-25 19:11:10 +08:00
|
|
|
|
|
|
|
def foo():
|
|
|
|
> assert 1 == 0
|
|
|
|
E assert 1 == 0
|
|
|
|
|
2012-10-07 19:06:17 +08:00
|
|
|
<2-codegen 'abc-123' /home/hpk/p/pytest/doc/en/example/assertion/failure_demo.py:162>:2: AssertionError
|
2010-11-25 19:11:10 +08:00
|
|
|
____________________ TestMoreErrors.test_complex_error _____________________
|
|
|
|
|
2013-04-30 18:26:30 +08:00
|
|
|
self = <failure_demo.TestMoreErrors instance at 0x137d758>
|
2010-11-25 19:11:10 +08:00
|
|
|
|
|
|
|
def test_complex_error(self):
|
|
|
|
def f():
|
|
|
|
return 44
|
|
|
|
def g():
|
|
|
|
return 43
|
|
|
|
> somefunc(f(), g())
|
|
|
|
|
2011-02-03 22:14:50 +08:00
|
|
|
failure_demo.py:175:
|
2010-11-26 20:26:56 +08:00
|
|
|
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
|
2010-11-25 19:11:10 +08:00
|
|
|
|
|
|
|
x = 44, y = 43
|
|
|
|
|
|
|
|
def somefunc(x,y):
|
|
|
|
> otherfunc(x,y)
|
|
|
|
|
2010-11-26 20:26:56 +08:00
|
|
|
failure_demo.py:8:
|
|
|
|
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
|
2010-11-25 19:11:10 +08:00
|
|
|
|
|
|
|
a = 44, b = 43
|
|
|
|
|
|
|
|
def otherfunc(a,b):
|
|
|
|
> assert a==b
|
|
|
|
E assert 44 == 43
|
|
|
|
|
|
|
|
failure_demo.py:5: AssertionError
|
|
|
|
___________________ TestMoreErrors.test_z1_unpack_error ____________________
|
|
|
|
|
2013-04-30 18:26:30 +08:00
|
|
|
self = <failure_demo.TestMoreErrors instance at 0x13a5200>
|
2010-11-25 19:11:10 +08:00
|
|
|
|
|
|
|
def test_z1_unpack_error(self):
|
|
|
|
l = []
|
|
|
|
> a,b = l
|
|
|
|
E ValueError: need more than 0 values to unpack
|
|
|
|
|
2011-02-03 22:14:50 +08:00
|
|
|
failure_demo.py:179: ValueError
|
2010-11-25 19:11:10 +08:00
|
|
|
____________________ TestMoreErrors.test_z2_type_error _____________________
|
|
|
|
|
2013-04-30 18:26:30 +08:00
|
|
|
self = <failure_demo.TestMoreErrors instance at 0x1395290>
|
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
|
|
|
|
|
2011-02-03 22:14:50 +08:00
|
|
|
failure_demo.py:183: TypeError
|
2010-11-25 19:11:10 +08:00
|
|
|
______________________ TestMoreErrors.test_startswith ______________________
|
|
|
|
|
2013-04-30 18:26:30 +08:00
|
|
|
self = <failure_demo.TestMoreErrors instance at 0x137f200>
|
2010-11-25 19:11:10 +08:00
|
|
|
|
|
|
|
def test_startswith(self):
|
|
|
|
s = "123"
|
|
|
|
g = "456"
|
|
|
|
> assert s.startswith(g)
|
2013-04-30 18:26:30 +08:00
|
|
|
E assert <built-in method startswith of str object at 0x143f288>('456')
|
|
|
|
E + where <built-in method startswith of str object at 0x143f288> = '123'.startswith
|
2010-11-25 19:11:10 +08:00
|
|
|
|
2011-02-03 22:14:50 +08:00
|
|
|
failure_demo.py:188: AssertionError
|
2010-11-25 19:11:10 +08:00
|
|
|
__________________ TestMoreErrors.test_startswith_nested ___________________
|
|
|
|
|
2013-04-30 18:26:30 +08:00
|
|
|
self = <failure_demo.TestMoreErrors instance at 0x145fb00>
|
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())
|
2013-04-30 18:26:30 +08:00
|
|
|
E assert <built-in method startswith of str object at 0x143f288>('456')
|
|
|
|
E + where <built-in method startswith of str object at 0x143f288> = '123'.startswith
|
|
|
|
E + where '123' = <function f at 0x13abaa0>()
|
|
|
|
E + and '456' = <function g at 0x13ab578>()
|
2010-11-25 19:11:10 +08:00
|
|
|
|
2011-02-03 22:14:50 +08:00
|
|
|
failure_demo.py:195: AssertionError
|
2010-11-25 19:11:10 +08:00
|
|
|
_____________________ TestMoreErrors.test_global_func ______________________
|
|
|
|
|
2013-04-30 18:26:30 +08:00
|
|
|
self = <failure_demo.TestMoreErrors instance at 0x139cd40>
|
2010-11-25 19:11:10 +08:00
|
|
|
|
|
|
|
def test_global_func(self):
|
|
|
|
> assert isinstance(globf(42), float)
|
2011-08-21 00:37:00 +08:00
|
|
|
E assert isinstance(43, float)
|
|
|
|
E + where 43 = globf(42)
|
2010-11-25 19:11:10 +08:00
|
|
|
|
2011-02-03 22:14:50 +08:00
|
|
|
failure_demo.py:198: AssertionError
|
2010-11-25 19:11:10 +08:00
|
|
|
_______________________ TestMoreErrors.test_instance _______________________
|
|
|
|
|
2013-04-30 18:26:30 +08:00
|
|
|
self = <failure_demo.TestMoreErrors instance at 0x13593b0>
|
2010-11-25 19:11:10 +08:00
|
|
|
|
|
|
|
def test_instance(self):
|
|
|
|
self.x = 6*7
|
|
|
|
> assert self.x != 42
|
|
|
|
E assert 42 != 42
|
2013-04-30 18:26:30 +08:00
|
|
|
E + where 42 = <failure_demo.TestMoreErrors instance at 0x13593b0>.x
|
2010-11-25 19:11:10 +08:00
|
|
|
|
2011-02-03 22:14:50 +08:00
|
|
|
failure_demo.py:202: AssertionError
|
2010-11-25 19:11:10 +08:00
|
|
|
_______________________ TestMoreErrors.test_compare ________________________
|
|
|
|
|
2013-04-30 18:26:30 +08:00
|
|
|
self = <failure_demo.TestMoreErrors instance at 0x1465d40>
|
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)
|
|
|
|
|
2011-02-03 22:14:50 +08:00
|
|
|
failure_demo.py:205: AssertionError
|
2010-11-25 19:11:10 +08:00
|
|
|
_____________________ TestMoreErrors.test_try_finally ______________________
|
|
|
|
|
2013-04-30 18:26:30 +08:00
|
|
|
self = <failure_demo.TestMoreErrors instance at 0x1456ea8>
|
2010-11-25 19:11:10 +08:00
|
|
|
|
|
|
|
def test_try_finally(self):
|
|
|
|
x = 1
|
|
|
|
try:
|
|
|
|
> assert x == 0
|
|
|
|
E assert 1 == 0
|
|
|
|
|
2011-02-03 22:14:50 +08:00
|
|
|
failure_demo.py:210: AssertionError
|
2013-04-30 18:26:30 +08:00
|
|
|
======================== 39 failed in 0.21 seconds =========================
|