Python 全球测试
为什么pytest中的所有装置都是全局的?Python 全球测试,python,pytest,Python,Pytest,为什么pytest中的所有装置都是全局的? 例如: tests/ conftest.py # content of tests/conftest.py import pytest @pytest.fixture def fixture_1(): pass test_something.py # content of tests/test_something.py
例如:
tests/
conftest.py
# content of tests/conftest.py
import pytest
@pytest.fixture
def fixture_1():
pass
test_something.py
# content of tests/test_something.py
def test_something(fixture_2):
assert fixture_2 != None
subfolder/
conftest.py
# content of tests/subfolder/conftest.py
import pytest
@pytest.fixture
def fixture_2(username):
pass
如您所见,我可以从第一级文件夹中的测试中的第二级获取夹具_2。是否有可能只为一个包装设置夹具