来自pytest.org的示例代码,是否可以从 json 文件加载参数?
# content of conftest.py
import pytest
import smtplib
@pytest.fixture(scope="module",
params=["smtp.gmail.com", "mail.python.org"])
def smtp(request):
smtp = smtplib.SMTP(request.param)
def fin():
print ("finalizing %s" % smtp)
smtp.close()
request.addfinalizer(fin)
return smtp
我想做类似的事情
# conftest.py
@pytest.fixture(scope="module", params=a_list_var)
def fixture_a(request):
# some.py or anywhere?
a_list_var = load_json(parameter_file_path)
# test_foo.py
...
def test_foo(fixture_a)
...