So, I'm trying to run pytest to run selenium tests in different environments based on some command line argument. But he continues to throw this error:
TypeError: setup_class() takes exactly 2 arguments (1 given)
It seems that it understands that setup_class takes 2 arguments, but host not passed. Here is the code for setup_class :
def setup_class(cls, host): cls.host = host
And here is the conftest.py file:
def pytest_addoption(parser): parser.addoption("--host", action="store", default='local', help="specify the host to run tests with. local|stage") @pytest.fixture(scope='class') def host(request): return request.config.option.host
It's strange that host functions are visible by functions (therefore, if I do test_function and pass the host as a parameter, it gets it just fine), these are just setup tags that don't work,
I looked around and found this, pytest - to use funcargs inside setup_module , but it doesn't seem to work (and it is deprecated since version 2.3.
Does anyone know what I'm doing wrong? Using py.test 2.3.2.
thanks
Nacht
source share