File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -699,6 +699,21 @@ class Example(BaseSettings):
699699 assert Example (name = 'john' , PREFIX_SURNAME = 'doe' ).model_dump () == {'name' : 'john' , 'last_name' : 'doe' }
700700
701701
702+ @pytest .mark .xfail (
703+ reason = 'This test is expected to fail in some sessions due to `InitSettingsSource`s non-deterministic behaviour.'
704+ "Simply repeating through parameterization won't help as the underlying reason is the non-deterministic "
705+ 'nature of python sets, which will remain constant within the same session.'
706+ )
707+ def test_init_kwargs_alias_resolution_deterministic ():
708+ class Example (BaseSettings ):
709+ name : str
710+ last_name : str = Field (validation_alias = AliasChoices ('surname' , 'last_name' ))
711+
712+ result = Example (name = 'john' , surname = 'doe' , last_name = 'smith' ).model_dump ()
713+
714+ assert result == {'name' : 'john' , 'last_name' : 'doe' }
715+
716+
702717def test_alias_nested_model_default_partial_update ():
703718 class SubModel (BaseModel ):
704719 v1 : str = 'default'
You can’t perform that action at this time.
0 commit comments