测试用例test_Pytest.py文件
import pytest
class TestPytest:
@pytest.fixture(autouse=True)
def setup_method(self,get_token):
token = get_token
print(token)
self.phone = 'a'
print("setup方法执行")
def test_process(self):
print("test_one方法执行")
assert 1 == 1
def teardown_method(self):
print("teardown方法执行")
if __name__ == "__main__":
pytest.main(['-s', 'test_Pytest.py'])
conftest.py文件
import pytest
# conftest.py
@pytest.fixture(scope='session')
def get_token():
token = 'qeehfjejwjwjej11sss@22'
yield token