【发布时间】:2017-05-31 21:27:35
【问题描述】:
我有以下脚本:
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()中,我想从conftest.py中的setup_env()获取返回值“结果”。
有高手可以指导我怎么做吗?
【问题讨论】: