. , , . :
def foo(x):
return x + 1
def bar(y):
return y - 1
def test_foo():
a = foo(10)
b = bar(10)
assert (a, b) == (10, 9)
pytest, :
$ pytest scratch.py
============================= test session starts =============================
platform linux2 -- Python 2.7.12, pytest-3.0.7, py-1.4.33, pluggy-0.4.0
rootdir: /home/don/workspace/scratch, inifile:
collected 1 items
scratch.py F
================================== FAILURES ===================================
__________________________________ test_foo ___________________________________
def test_foo():
# some expensive calculation
a = foo(10)
# another expensive calculation
b = bar(10)
> assert (a, b) == (10, 9)
E assert (11, 9) == (10, 9)
E At index 0 diff: 11 != 10
E Use -v to get the full diff
scratch.py:16: AssertionError
========================== 1 failed in 0.02 seconds ===========================
and
, - short circuiting. , :
assert a == 10 and b == 9
Pytest :
> assert a == 10 and b == 9
E assert (11 == 10)
b
, --showlocals
.