Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The "create report" option, --html's parameter should be optional as it's possible to specify the name procedurally #477

Open
bedge opened this issue Dec 30, 2021 · 2 comments
Labels
next-gen Candidate for the next-gen project

Comments

@bedge
Copy link

bedge commented Dec 30, 2021

When one sets the report name procedurally, eg:

@pytest.hookimpl(tryfirst=True)
def pytest_configure(config):
    """
    Runs early, report name must be set here
    https://stackoverflow.com/questions/60571675/setting-dynamic-folder-and-report-name-in-pytest
    :param config:
    :return:
    """
    env = os.environ['ENVIRONMENT']
    assert env is not None
    now = datetime.now()
    # create report target dir
    reports_dir = Path('reports')
    reports_dir.mkdir(parents=True, exist_ok=True)
    # custom report file
    report = reports_dir / f"{env}_{now.strftime('%Y-%m-%d_%H-%M')}.html"
    config.option.htmlpath = report.absolute()

The is no need to have a parameter to the --html arg as it's being specified in the code above.

However, one currently still needs to provide this to satisfy the argparser:

[I] ➜ py.test  .... --html
ERROR: usage: py.test [options] [file_or_dir] [file_or_dir] [...]
py.test: error: argument --html: expected one argument

It forces one to specify a parameter, eg: --html=xx solely for the parser validation.

In short, please make the --html arg's parameter optional.

thanks

@BeyondEvil BeyondEvil added the next-gen Candidate for the next-gen project label Jan 14, 2022
@BeyondEvil
Copy link
Contributor

BeyondEvil commented Jan 14, 2022

Good point!

Will make sure this is how the next major release works. 👍

@bedge
Copy link
Author

bedge commented Jan 14, 2022

WooHoo! thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
next-gen Candidate for the next-gen project
Projects
None yet
Development

No branches or pull requests

2 participants