@songying
2018-07-02T11:09:04.000000Z
字数 383
阅读 1269
pytest
pip install -U pytest
pytest --version
def test_answer():
assert func(3) == 5
pytest 会运行当前目录下和它子目录下所有 test_*.py
或*_test.py
。
import pytest
def f():
raise SystemExit(1)
def test_mytest():
with pytest.raises(SystemExit):
f()
pytest -q test_sysexit.py
class TestClass(object):
def test_one(self):
x = "this"
assert 'h' in x
def test_two(self):
x = "hello"
assert hasattr(x, 'check')