-
-
Couldn't load subscription status.
- Fork 2.9k
Add support for native TOML configuration #13846
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
Conversation
|
Gave it a first pass, this is looking great! The ability of using However, it seems the only difference between # pyproject.toml
[tool.pytest]
test_int_validation = 5
test_paths = ["src", "lib"]
#[tool.pytest.ini_options]
#test_int_validation = "5"
#test_paths = ["src", "lib"]# conftest
def pytest_addoption(parser):
parser.addini("test_int_validation", "Test int validation", type="int", default=0)
parser.addini("test_paths", "Test paths config", type="paths")# test_foo.py
def test(request):
val = request.config.getini("test_int_validation")
print(f"{val} ({type(val)})")
val2 = request.config.getini("test_paths")
print(f"{val2} ({type(val2)})")From plugin author's POV, both The type-coercion for ini options means that Unless I'm missing something, To be clear, this is all good and definitely we want to introduce this in pytest. I'm just wondering why we just not did this in the first place, rather than introducing |
|
I hope to have cot.config.ingest a reasonable wip by the end of the year |
|
@nicoddemus My impression was that we wanted to get some toml support and so went with the "quick" In any case, we can wait for @RonnyPfannschmidt solution. But I wanted to finish the PR while it's still fresh in my head, maybe Ronny could reuse some of it. The changes since the initial posting:
|
I think we should go ahead with your support, I believe @RonnyPfannschmidt's solution can be built on top of it later (please correct me if I'm wrong Ronn). It would be nice to release this new support in 9.0. 👍 |
|
My solution would completely replace ini/toml/argpatse settings Its inspired by typedsetting |
|
But i believe its fine to go Ahead |
Sounds interesting, but I wonder how it would work with backward compatibility in mind. |
|
@nicoddemus i'm exploring that part still - but the basic goal is to provide a backward compatible layer - once tests pass pytest-alikeness i can propose upstream changes |
|
Rebased, still missing some coverage. I also noticed about this code here: pytest/src/_pytest/config/findpaths.py Lines 70 to 72 in 0fb7cae
It allows an empty |
|
OK, this should be ready now. |
This prepares the code and documentation for adding another configuration file format, TOML. Add a `mode` field to `ConfigValue` to track the parsing mode. Add tabs to all configuration file snippets in the docs, so that we may show both toml and ini in a nice way once toml is added. Uses the sphinx-inline-tabs package that I saw used by tox documentation. Avoid references to "pytest.ini" and "ini file" in docs, instead refer to "configuration file" (I'm sure I missed some).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Add support for using native TOML configuration, while maintaining full backwards compatibility with the existing INI-based configuration system. In pyproject.toml, the native configuration is under ``[pytest.tool]``. Also add support for ``pytest.toml``/``.pytest.toml`` files. `--override-ini` always uses "ini" mode for compatibility.
Fixes #13743.
Add support for using native TOML configuration, while maintaining full backwards compatibility with the existing INI-based configuration system.
In pyproject.toml, the native configuration is under
[pytest.tool]. Also add support forpytest.toml/.pytest.tomlfiles, under[pytest]table (similar topytest.ini).--override-inialways uses "ini" mode for compatibility.