Skip to content

Adapt test_protected_namespace_defaults for dev. Pydantic #637

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions tests/test_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -2274,7 +2274,10 @@ def test_protected_namespace_defaults():
# pydantic default
with pytest.warns(
UserWarning,
match='Field "model_dump_prefixed_field" in Model has conflict with protected namespace "model_dump"',
match=(
'Field "model_dump_prefixed_field" in Model has conflict with protected namespace "model_dump"|'
r"Field 'model_dump_prefixed_field' in 'Model' conflicts with protected namespace 'model_dump'\..*"
),
):

class Model(BaseSettings):
Expand All @@ -2283,18 +2286,21 @@ class Model(BaseSettings):
# pydantic-settings default
with pytest.warns(
UserWarning,
match='Field "settings_customise_sources_prefixed_field" in Model1 has conflict with protected namespace "settings_customise_sources"',
match=(
'Field "settings_customise_sources_prefixed_field" in Model1 has conflict with protected namespace "settings_customise_sources"|'
r"Field 'settings_customise_sources_prefixed_field' in 'Model1' conflicts with protected namespace 'settings_customise_sources'\..*"
),
):

class Model1(BaseSettings):
settings_customise_sources_prefixed_field: str

with pytest.raises(
NameError,
(NameError, ValueError),
match=(
'Field "settings_customise_sources" conflicts with member <bound method '
"BaseSettings.settings_customise_sources of <class 'pydantic_settings.main.BaseSettings'>> "
'of protected namespace "settings_customise_sources".'
r'Field (["\'])settings_customise_sources\1 conflicts with member <bound method '
r"BaseSettings\.settings_customise_sources of <class 'pydantic_settings\.main\.BaseSettings'>> "
r'of protected namespace \1settings_customise_sources\1\.'
),
):

Expand Down