0

我是 Python 新手,我对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)

是否可以将 conftest.py 中定义的夹具移动test_client.py从而消除conftest.py

4

1 回答 1

1

是的。你为什么不简单地尝试一下?;)

夹具被放入conftest.py文件中,以便能够在多个测试文件中使用它们。

于 2016-08-16T09:39:42.270 回答