From: "Benjamin A. Beasley" <code@musicinmybrain.net>
Date: Sun, 22 Jun 2025 09:49:34 -0400
Subject: Adapt test_protected_namespace_defaults for dev. Pydantic

Based on testing with a current development snapshot of Pydantic and
Python 3.14.

Origin: other, https://github.com/pydantic/pydantic-settings/pull/637
Last-Update: 2025-08-25
---
 tests/test_settings.py | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/tests/test_settings.py b/tests/test_settings.py
index a7bd86c..06fd414 100644
--- a/tests/test_settings.py
+++ b/tests/test_settings.py
@@ -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):
@@ -2283,18 +2286,21 @@ def test_protected_namespace_defaults():
     # 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\.'
         ),
     ):
 
