Can't Get Pytest To Understand Command-line Arguments On Setups
So I have been trying to get pytest to run selenium tests on different environments based on some command-line argument. But it keeps throwing this error: TypeError: setup_class()
Solution 1:
To access the command line options from inside the setup functions, you can use the pytest.config object. Here is an example... adapt as needed.
import pytest
defsetup_module(mod):
print"Host is %s" % pytest.config.getoption('host')
Solution 2:
setup_module/class/method and friends cannot work with pytest fixtures directly. The pytest-2.3 way of doing the equivalent is to use autouse fixtures. If you can it's better to pass fixtures explicitely to test functions or to put a usefixtures marker on a class or module.
Post a Comment for "Can't Get Pytest To Understand Command-line Arguments On Setups"