[Python] pytest is not accepting a custom argument value

Discussão em 'Python' iniciado por Stack, Julho 18, 2025.

  1. Stack

    Stack Membro Participativo

    I'm trying to run pytest with a custom input argument "--trustkey_jks".

    Running like this:

    sh-4.2$ pytest -m test_e2e.py --trustkey_jks somekey
    ERROR: usage: py.test [options] [file_or_dir] [file_or_dir] [...]
    py.test: error: argument --trustkey_jks: expected one argument


    Also tried like this:

    sh-4.2$ py.test --trustkey_jks somekey test_e2e.py
    ERROR: usage: py.test [options] [file_or_dir] [file_or_dir] [...]
    py.test: error: argument --trustkey_jks: expected one argument


    Can omit a file name to let pytest to collect any tests:

    sh-4.2$ py.test --trustkey_jks somekey
    ERROR: usage: py.test [options] [file_or_dir] [file_or_dir] [...]
    py.test: error: argument --trustkey_jks: expected one argument


    My conftest.py (same level as tests_e2e.py):

    # conftest.py
    def pytest_addoption(parser):
    parser.addoption("--trustkey_jks", action="store")

    @pytest.fixture()
    def trustkey_jks(request):
    return request.config.getoption("--trustkey_jks")


    As far as i understand, pytest fails at parsing input arguments. Appreciate any help.

    NOTE: the above is happening inside an Openshift POD, not sure if it matters.

    Continue reading...

Compartilhe esta Página