Esempio n. 1
0
    def test_should_raise_error_when_file_is_not_path_or_string(
            self, env_file):
        with pytest.raises(TypeError) as exc_info:
            Configuration.load_from_dotenv(env_file)

        assert f'env file must be of type Path or str but you provided {type(env_file)}' == str(
            exc_info.value)
Esempio n. 2
0
    def test_should_return_correct_config_given_correct_env_file(self, tmp_path, math_module):
        env_file = tmp_path / '.env'
        lines = """
        FOO = BAR
        SCALPEL_FOLLOW_ROBOTS_TXT = yes
        SCALPEL_FETCH_TIMEOUT = 2.0
        SCALPEL_RESPONSE_MIDDLEWARES = custom_math.add:custom_math.minus
        """
        env_file.write_text(lines)

        config = Configuration.load_from_dotenv(env_file)
        assert config.follow_robots_txt is True
        assert 2.0 == config.fetch_timeout
        assert [math_module.add, math_module.minus] == config.response_middlewares