def test_serialization_alias_settings(
    config: Union[bool, None], runtime: Union[bool, None], expected: dict[str, int]
) -> None:
    """This test reflects the priority that applies for config vs runtime serialization alias configuration.

    Runtime value (by_alias) takes precedence over config value (serialize_by_alias).
    If neither are set, the default, False, is used.
    """

    class Model(BaseModel):
        model_config = ConfigDict(serialize_by_alias=config)

        my_field: int = Field(serialization_alias='my_alias')

    model = Model(my_field=1)
    assert model.model_dump(by_alias=runtime) == expected
This test reflects the priority that applies for config vs runtime serialization alias configuration.

    Runtime value (by_alias) takes precedence over config value (serialize_by_alias).
    If neither are set, the default, False, is used.
    
tests/test_aliases.py