mardi 19 février 2019

in pytest how can I use command line arguments to modify test parameters?

I want to add a command line parameter to my tests which have effect on (but not only on) test parameters. So I've added an option to my conftest.py:

def pytest_addoption(parser):
    parser.addoption("--target-name", action="store")

I know how to make fixtures depend on command line values but not how to do this for test parameters

@pytest.mark.parametrize(
    "target_specific_data", json.parse(open("target-%s.json" % target_name)))
def test_foo(golden_values):
      ...
      ...

How can I do this with pytest?

Aucun commentaire:

Enregistrer un commentaire