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

Add PyTest IDs for better readability and filtering #409

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

GatlenCulp
Copy link

@GatlenCulp GatlenCulp commented Dec 30, 2024

This small PR adds dynamically generated IDs for the config parameters. This makes it immediately clear which configuration failed and allows for filtering with pytest -k EXPRESSION. Ex: To only run the tests using conda and mkdocs you can do pytest -k "conda and mkdocs".

def pytest_generate_tests(metafunc):
    # setup config fixture to get all of the results from config_generator
    def make_test_id(config): # NEW
        return f"{config['environment_manager']}-{config['dependency_file']}-{config['docs']}"
    
    if "config" in metafunc.fixturenames:
        metafunc.parametrize(
            "config",
            config_generator(metafunc.config.getoption("fast")),
            ids=make_test_id # NEW
        )

Before:
GatScreen_2024-12-30_17 39 15@2x

After:
GatScreen_2024-12-30_17 44 33@2x

(Screenshots from VSCode Test Explorer)

The changes to pyproject.toml and .gitignore are small changes for my local development which you're free to add or ignore.

@GatlenCulp GatlenCulp marked this pull request as ready for review December 30, 2024 22:45
@chrisjkuch
Copy link
Contributor

Sorry for the delay on this @GatlenCulp - would you mind fixing the linting issue so I can run the tests?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants