我有以下脚本:从conftest返回变量测试类
conftest.py:
import pytest
@pytest.fixture(scope="session")
def setup_env(request):
# run some setup
return("result")
test.py:
import pytest
@pytest.mark.usefixtures("setup_env")
class TestDirectoryInit(object):
def setup(cls):
print("this is setup")
ret=setup_env()
print(ret)
def test1():
print("test1")
def teardown(cls):
print("this teardown")
我得到的错误:
def setup(cls):
print("this is setup")
> ret=setup_env()
E NameError: name 'setup_env' is not defined
在setup()
中,我想从setup_env()
得到conftest.py
的返回值“result”。
任何专家可以指导我如何做到这一点?