Skip to content

Commit

Permalink
Fix native toml documentation does not match code (#60)
Browse files Browse the repository at this point in the history
  • Loading branch information
gaborbernat authored Oct 30, 2023
1 parent 81a2692 commit 4e233bf
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ repos:
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.1.1"
rev: "v0.1.3"
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
Expand All @@ -19,7 +19,7 @@ repos:
- id: tox-ini-fmt
args: ["-p", "fix"]
- repo: https://github.com/tox-dev/pyproject-fmt
rev: "1.2.0"
rev: "1.3.0"
hooks:
- id: pyproject-fmt
additional_dependencies: ["tox>=4.11.3"]
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ dynamic = [
"version",
]
dependencies = [
"pytest>=7.4.2",
"pytest>=7.4.3",
'tomli>=2.0.1; python_version < "3.11"',
]
optional-dependencies.test = [
Expand Down
2 changes: 1 addition & 1 deletion src/pytest_env/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def _load_values(early_config: pytest.Config) -> Iterator[Entry]:
config = tomllib.load(file_handler)
if "tool" in config and "pytest_env" in config["tool"]:
has_toml_conf = True
for key, entry in config["tool"]["pytest_env"].get("env", {}).items():
for key, entry in config["tool"]["pytest_env"].items():
if isinstance(entry, dict):
value = str(entry["value"])
transform, skip_if_set = bool(entry.get("transform")), bool(entry.get("skip_if_set"))
Expand Down
6 changes: 3 additions & 3 deletions tests/test_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,21 +137,21 @@ def test_env_via_pytest(
),
pytest.param(
{},
'[tool.pytest_env.env]\nMAGIC = 1\nMAGIC_2 = "toml2"',
'[tool.pytest_env]\nMAGIC = 1\nMAGIC_2 = "toml2"',
"",
{"MAGIC": "1", "MAGIC_2": "toml2"},
id="toml native",
),
pytest.param(
{},
'[tool.pytest_env.env]\nMAGIC = 1\nMAGIC_2 = "toml2"',
'[tool.pytest_env]\nMAGIC = 1\nMAGIC_2 = "toml2"',
"[pytest]\nenv = MAGIC=ini\n MAGIC_2=ini2",
{"MAGIC": "1", "MAGIC_2": "toml2"},
id="toml native over ini",
),
pytest.param(
{},
'[tool.pytest_env.env]\nMAGIC = {value = "toml", "transform"= true, "skip_if_set" = true}',
'[tool.pytest_env]\nMAGIC = {value = "toml", "transform"= true, "skip_if_set" = true}',
"",
{"MAGIC": "toml"},
id="toml inline table",
Expand Down

0 comments on commit 4e233bf

Please sign in to comment.