import pytest


def deb(x,y):
    return print("和:",x + y)

def dec(x):
    return x + 1


@pytest.mark.xfail(reason="标记失败的用例")
@pytest.mark.web
def test_01():
    assert dec(3) == 4


def test_02():
    assert dec(4) == 5


def test_03():
    assert dec(3) == 3


@pytest.mark.skip(reason="跳过测试")
@pytest.mark.web
def test_04():
    assert dec(3) == 4


@pytest.mark.app
def test_05():
    print("test_05")
    assert dec(2) == 3


def test_06():
    return True


def test_07():
    if not test_06:
        pytest.mark.skipif("test skipif")


@pytest.mark.parametrize("t1",[1,2,3])
@pytest.mark.parametrize("t2",[2,3,4])
def test_08(t1,t2):

    return deb(t1,t2)


class TestApp:
    def test_09(self):
        return dec(3) == 4


    # 1.执行当前模块所以用例
    # pytest.main(["-s","test_main.py])
    #
    # 2.
    # pytest xx.py
    # 4.
    # ptest -x    # 第一次失败就停止
    # pytest --maxfail=2      #出现2次失败就停止
    #
    # 5.关键字执行
    # pytest -k "xx"
    # pytest -k "xx and not yy"
    #
    # 6.指定模块类中的方法
    # pytest test_main.py::TestApp::test_09
    #
    # 7.指定标签执行
    # pytest -m web
    
# if __name__ == '__main__':
#     pytest.main(["test_main.py::test_02","-vs"])
#     pytest.main(["test_main.py","-vs","-m","03"])
#     执行方式: python xx.py