I am new to Python and I have a doubt in pytest
test_client.py
# Simple Example tests
import pytest
def test_one():
assert False == False
def test_two():
assert True == True
def cleanup():
# do some cleanup stuff
conftest.py
import pytest
import test_client
@pytest.fixture(scope="session", autouse=True)
def do_clean_up(request):
request.addfinalizer(test_client.cleanup)
Is it possible to move the fixture defined in conftest.py to the test_client.py thereby eliminating having conftest.py
Yes. Why didn't you simply try? ;)
Fixtures are put in conftest.py
files to be able to use them in multiple test files.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.