Skip to content

Commit

Permalink
Fix test_protected_namespace_defaults with -Wdefault
Browse files Browse the repository at this point in the history
This test failed with "pytest -Wdefault", which distros usually enable
for downstream testing to avoid surprise failures.

Use proper `pytest.warns()` method instead of incorrect
`pytest.raises()`.

See: https://mgorny.pl/articles/downstream-testing-python-packages.html#assuming-werror-catching-warnings-as-exceptions
  • Loading branch information
CyberTailor committed Nov 3, 2024
1 parent 2441670 commit 4bb6087
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion tests/test_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -2175,7 +2175,7 @@ class Model(BaseSettings):
model_prefixed_field: str

# pydantic-settings default
with pytest.raises(
with pytest.warns(
UserWarning, match='Field "settings_prefixed_field" in Model1 has conflict with protected namespace "settings_"'
):

Expand Down

0 comments on commit 4bb6087

Please sign in to comment.