@songying
2018-07-02T03:09:04.000000Z
字数 383
阅读 1461
pytest
pip install -U pytestpytest --version
def test_answer():assert func(3) == 5
pytest 会运行当前目录下和它子目录下所有 test_*.py或*_test.py。
import pytestdef 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 xdef test_two(self):x = "hello"assert hasattr(x, 'check')
