Skip to content

Commit f906352

Browse files
committed
and the tests
1 parent 5497ab2 commit f906352

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

tests/test_multi_source.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,18 +58,21 @@ def settings_customise_sources(
5858

5959
assert exc_info.value.errors(include_url=False) == [
6060
{
61+
'ctx': {'source': 'JsonConfigSettingsSource'},
6162
'input': 0,
6263
'loc': ('JsonConfigSettingsSource', 'foobar',),
6364
'msg': 'Input should be a valid string',
6465
'type': 'string_type',
6566
},
6667
{
68+
'ctx': {'source': 'EnvSettingsSource'},
6769
'input': 'a',
6870
'loc': ('EnvSettingsSource', 'nested', 'nested_field'),
6971
'msg': 'Input should be a valid integer, unable to parse string as an integer',
7072
'type': 'int_parsing'
7173
},
7274
{
75+
'ctx': {'source': 'InitSettingsSource'},
7376
'input': 0,
7477
'loc': ('InitSettingsSource', 'null_field',),
7578
'msg': 'Input should be a valid string',

tests/test_settings.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ class AnnotatedComplexSettings(BaseSettings, validate_each_source=True):
485485
AnnotatedComplexSettings()
486486
assert exc_info.value.errors(include_url=False) == [
487487
{
488-
'ctx': {'actual_length': 1, 'field_type': 'List', 'min_length': 2},
488+
'ctx': {'actual_length': 1, 'field_type': 'List', 'min_length': 2, 'source': 'EnvSettingsSource'},
489489
'input': ['russet'],
490490
'loc': ('EnvSettingsSource', 'apples',),
491491
'msg': 'List should have at least 2 items after validation, not 1',
@@ -1143,7 +1143,8 @@ class Settings(BaseSettings):
11431143
'type': 'extra_forbidden',
11441144
'loc': ('DotEnvSettingsSource', 'f',),
11451145
'msg': 'Extra inputs are not permitted',
1146-
'input': 'random value'
1146+
'input': 'random value',
1147+
'ctx': {'source': 'DotEnvSettingsSource'}
11471148
}
11481149
]
11491150

0 commit comments

Comments
 (0)