@@ -24,7 +24,7 @@ def test_ThingConfig():
2424 assert direct .kwargs == {}
2525 assert direct .thing_slots == {}
2626
27- with pytest .raises (ThingImportFailure , match = "No module named 'missing.* '" ):
27+ with pytest .raises (ThingImportFailure , match = "No module named 'missing'" ):
2828 ThingConfig (cls = "missing.module" )
2929
3030
@@ -114,8 +114,15 @@ def test_ThingServerConfig():
114114def test_unimportable_modules ():
115115 """Test that unimportable modules raise errors as expected."""
116116
117- with pytest .raises (ThingImportFailure , match = "No module named 'missing.*'" ):
117+ with pytest .raises (ThingImportFailure , match = "No module named 'missing'" ):
118+ # If a module is missing, the error should make that clear.
119+ # Note that the error message changed with Pydantic 2.13.
118120 ThingConfig (cls = "missing.module:object" )
121+ with pytest .raises (ThingImportFailure , match = "No module named 'missing_module'" ):
122+ # Check that, if a module has a broken import, the error refers
123+ # to that missing import and doesn't suggest the target module
124+ # is missing. This was an upstream bug, fixed in Pydantic 2.13
125+ ThingConfig (cls = "tests.unimportable.missing_import:object" )
119126
120127 with pytest .raises (
121128 ThingImportFailure ,
0 commit comments