def test_as_dict(self, mock_envfile): settings = Settings(env_prefix="PREFIX_") settings.load_dotenv_file(mock_envfile) as_dict = settings.as_dict() assert as_dict == settings._config assert isinstance(as_dict, dict)
def test_load_envfile_with_prefix_strips_out_prefix(self, mock_envfile): settings = Settings(env_prefix="PREFIX_") settings.load_dotenv_file(mock_envfile) with pytest.raises(AttributeError): settings.PREFIX_DEBUG assert settings.DEBUG is True
def test_load_envfile_with_prefix(self, mock_envfile): settings = Settings(env_prefix="PREFIX_") settings.load_dotenv_file(mock_envfile) assert settings.DEBUG is True assert settings.ESCAPED_HASH == {"dict": "test"} assert settings.UNESCAPED_HASH == {"dict": "test"} assert settings.MULTILINE_KEY == ( "===BEGIN PUBLIC CERTIFICATE=== \n" " it is a certificate value \n" "===END PUBLIC CERTIFICATE===" )
def test_prefix_gets_stripped_once_only(self, mock_envfile): settings = Settings(env_prefix="PREFIX_") settings.load_dotenv_file(mock_envfile) assert settings.SOME_KEY_PREFIX_REPEATED == "nested"
def test_load_envfile_does_not_load_unprefixed_vars(self, mock_envfile): settings = Settings(env_prefix="PREFIX_") settings.load_dotenv_file(mock_envfile) with pytest.raises(AttributeError): settings.USER