You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In a py.test code I can specify some file that can be used for some tests. So in the conftest.py I define
def pytest_addoption(parser):
"""Defines the extra options for the MOOC tests."""
parser.addoption(
"--tests",
help="Defines the json files containing the test parameters.",
)
@pytest.fixture
def testfile(request):
"""Returns True if driver should run headless."""
return request.config.getoption("--tests")
so I have a fixture which represents a filename.
Now in the test itself I want to use this filename to parametrize a test as follows:
from parameterized import parameterized
@parameterized(
param.explicit(*json.loads(line))
for line in open(testfile)
)
def test_1(testparam):
...
but that does not work as the fixture testfile does not seem to be defined/accessible in "front of" a test method. Is there any way to define testfile in a dynamic way?
The text was updated successfully, but these errors were encountered:
In a py.test code I can specify some file that can be used for some tests. So in the conftest.py I define
def pytest_addoption(parser):
"""Defines the extra options for the MOOC tests."""
parser.addoption(
"--tests",
help="Defines the json files containing the test parameters.",
)
@pytest.fixture
def testfile(request):
"""Returns True if driver should run headless."""
return request.config.getoption("--tests")
so I have a fixture which represents a filename.
Now in the test itself I want to use this filename to parametrize a test as follows:
from parameterized import parameterized
@parameterized(
param.explicit(*json.loads(line))
for line in open(testfile)
)
def test_1(testparam):
...
but that does not work as the fixture testfile does not seem to be defined/accessible in "front of" a test method. Is there any way to define testfile in a dynamic way?
In a py.test code I can specify some file that can be used for some tests. So in the conftest.py I define
so I have a fixture which represents a filename.
Now in the test itself I want to use this filename to parametrize a test as follows:
but that does not work as the fixture testfile does not seem to be defined/accessible in "front of" a test method. Is there any way to define
testfile
in a dynamic way?The text was updated successfully, but these errors were encountered: