Skip to content

parser.addoption is not working if the argument value is alluredir #13219

@ChrstnAnsl

Description

@ChrstnAnsl

I'm encountering an error when attempting to add --alluredir in conftest.py. The error message points to a conflict in argparse.py:

\AppData\Local\Programs\Python\Python311\Lib\argparse.py", line 1621, in _handle_conflict_error
    raise ArgumentError(action, message % conflict_string)

It seems that --alluredir is already registered, causing a conflict. What would be the best approach to handle this and set a default directory without overriding existing configurations? Our target is to check if the allure key is set to true into our configuration before running the --alluredir

pytest and operating system

  • OS = Windows 11
  • Pytest = 7.4.0

Code example

def pytest_addoption(parser):
    if config.settings.allure:
        parser.addoption("--alluredir", default="allure-results", action="store")

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions