Skip to content

Commit 6b232f9

Browse files
Adapt test_protected_namespace_defaults for dev. Pydantic
Based on testing with a current development snapshot of Pydantic and Python 3.14.
1 parent 910b1b1 commit 6b232f9

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

tests/test_settings.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2274,7 +2274,10 @@ def test_protected_namespace_defaults():
22742274
# pydantic default
22752275
with pytest.warns(
22762276
UserWarning,
2277-
match='Field "model_dump_prefixed_field" in Model has conflict with protected namespace "model_dump"',
2277+
match=(
2278+
'Field "model_dump_prefixed_field" in Model has conflict with protected namespace "model_dump"|'
2279+
r"Field 'model_dump_prefixed_field' in 'Model' conflicts with protected namespace 'model_dump'\..*"
2280+
),
22782281
):
22792282

22802283
class Model(BaseSettings):
@@ -2283,18 +2286,21 @@ class Model(BaseSettings):
22832286
# pydantic-settings default
22842287
with pytest.warns(
22852288
UserWarning,
2286-
match='Field "settings_customise_sources_prefixed_field" in Model1 has conflict with protected namespace "settings_customise_sources"',
2289+
match=(
2290+
'Field "settings_customise_sources_prefixed_field" in Model1 has conflict with protected namespace "settings_customise_sources"|'
2291+
r"Field 'settings_customise_sources_prefixed_field' in 'Model1' conflicts with protected namespace 'settings_customise_sources'\..*"
2292+
),
22872293
):
22882294

22892295
class Model1(BaseSettings):
22902296
settings_customise_sources_prefixed_field: str
22912297

22922298
with pytest.raises(
2293-
NameError,
2299+
(NameError, ValueError),
22942300
match=(
2295-
'Field "settings_customise_sources" conflicts with member <bound method '
2296-
"BaseSettings.settings_customise_sources of <class 'pydantic_settings.main.BaseSettings'>> "
2297-
'of protected namespace "settings_customise_sources".'
2301+
r'Field (["\'])settings_customise_sources\1 conflicts with member <bound method '
2302+
r"BaseSettings\.settings_customise_sources of <class 'pydantic_settings\.main\.BaseSettings'>> "
2303+
r'of protected namespace \1settings_customise_sources\1\.'
22982304
),
22992305
):
23002306

0 commit comments

Comments
 (0)