def test_programmatically_file_load(tmpdir):
    """Check file can be included programmatically"""
    settings_file = tmpdir.join("settings.toml")
    settings_file.write(
        """
       [default]
       default_var = 'default'
    """
    )

    settings = LazySettings(
        environments=True, SETTINGS_FILE_FOR_DYNACONF=str(settings_file)
    )
    assert settings.DEFAULT_VAR == "default"

    toml_plugin_file = tmpdir.join("plugin1.toml")
    toml_plugin_file.write(
        """
        [development]
        plugin_value = 'plugin'
    """
    )

    settings.load_file(path=str(toml_plugin_file))
    assert settings.PLUGIN_VALUE == "plugin"

    settings.setenv("production")
    assert settings.DEFAULT_VAR == "default"
    # programmatically loaded file is not persisted
    # once `env` is changed, or a `reload` it will be missed
    # to persist it needs to go to `INCLUDES_FOR_DYNACONF` variable
    with pytest.raises(AttributeError):
        assert settings.PLUGIN_VALUE == "plugin"
Check file can be included programmatically
tests/test_nested_loading.py