import pytest
# pytest会收集当前目录下的所有test_*.py *_test.py的所有用例
# pytest设置编译方式 python解释器编译 pytest编译器编译
def func(x):
    return x + 3
def test_answer():
    assert func(3) == 6
@pytest.mark.parametrize('a,b',[
    (1,2),
    (2,3),
    (3,4)
])
def test_answer1(a,b):
    assert func(a) == b
@pytest.fixture()
def login():
    username = 'tom'
    return username
class TestDemo:
    def test_a(self,login):
        print("a")
        print(f"a username = {login}")
    def test_b(self):
        print("b")
    def c(self):
        print("c")
if __name__ == '__main__':
    pytest.main(['test_1.py','-v'])
    pytest.main(['test_1.py::TestDemo','-v'])
# 参数 -k 模式匹配  pytest -k “类名”—>表示任意位置模糊匹配类名的所有类
#          pytest -k “方法名”—>表示任意位置模糊匹配方法名的所有方法
#          pytest -k “类名 and not 方法名”—>表示任意位置模糊匹配类名的所有类,不会执行任意位置模糊匹配的方法
#   -v 表示详细的执行过程