import pytest
class TestCasse( ):
"""
pytest test_example.py -m case10
pytest test_example.py -m "case12 or case13"
pytest test_example.py -m "not case13"
"""
@pytest.mark.case10
def test_case10(self):
assert 4 == 3, "两个数不相等"
def test_case11(self):
assert 3 == 3, "两个数相等"
@pytest.mark.case12
def test_case12(self):
assert 4 == 3, "两个数不相等"
@pytest.mark.case13
def test_case13(self):
assert 5 == 3, "两个数不相等"
@pytest.mark.skip
def test_case14(self):
assert 11 == 3, "两个数不相等"
def f( ):
raise SystemExit(1)
def test_mytest( ):
with pytest.raises(SystemExit):
f( )
def hello( ):
return "hello world"
def test_hello( ):
assert hello( ) == "hello world"
@pytest.mark.run_these_test
def test_zero_division( ):
with pytest.raises(ZeroDivisionError) as exinfo:
print(1 / 0)
assert exinfo.type == ZeroDivisionError
assert str(exinfo.value) == "division by zero"