-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Closed
Description
Hi, how to access command line arguments within from a test_script.py?
suppose I do pytest --resolution 1280x1024
and my conftest.py
is:
import pytest
def pytest_addoption(parser):
parser.addoption('--resolution', metavar='resolution', default='1280x1024', help='specify resolution in format like that: "1280x720"')
def resolution(request): # not sure this is needed for the example, but I need to access resolution in conftest.py's fixtures, so I have it.
return request.config.getoption('--resolution')
and test_example.py
is:
import pytest # to try 'pytestconfig.resolution'.
def test_example():
print(resolution) # fails with NameError: name 'resolution' is not defined
print(pytestconfig.resolution) # fails the same way. I don't know what pytestconfig really is, but docs say it is pytest config object with access to command line opts.
Metadata
Metadata
Assignees
Labels
No labels