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 support for .pytest.ini as an alternative to pytest.ini #9988

Merged
merged 5 commits into from Jun 14, 2022

Conversation

grintor
Copy link
Contributor

@grintor grintor commented May 23, 2022

Adds support for .pytest.ini as an alternative to pytest.ini. Closes #9987

Added config search option of ".pytest.ini" in addition to "pytest.ini"
Hidden version of pytest.ini documented.
Added hidden configuration file info to changelog.
Added myself to AUTHORS file.
Copy link
Member

@The-Compiler The-Compiler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like a good idea!

@grintor grintor requested a review from The-Compiler May 24, 2022 11:23
Copy link
Member

@nicoddemus nicoddemus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but we need an explicit test that loads from a .pytest.ini file to avoid regressions.

For an example see test_pyproject_toml in test_config.py, I think we can create a new test which follows the same approach taken there.

@nicoddemus nicoddemus added this to the 7.2 milestone Jun 14, 2022
@nicoddemus
Copy link
Member

Took the liberty of adding the test myself (we just needed to add a new parameter to a parametrized test actually).

Thanks @grintor!

)
def test_ini_names(self, pytester: Pytester, name, section) -> None:
pytester.path.joinpath(name).write_text(
textwrap.dedent(
"""
[{section}]
minversion = 1.0
minversion = 3.36
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Used a more unusual version number than 1.0 just to be more clear that we are getting the actual value (1.0 seems a bit like it could be a default value).

@nicoddemus nicoddemus changed the title Allow configuration file to be hidden Add support for .pytest.ini as an alternative to pytest.ini Jun 14, 2022
@nicoddemus nicoddemus merged commit fab696d into pytest-dev:main Jun 14, 2022
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.

Offer alternative config filename ".pytest.ini"
3 participants