def test_get_environment_returns_part_of_dict(self): config = Config('') test = { 'KEY': False, 'environments': { 'debug': { 'DEBUG': True }, 'testing': { 'TESTING': True } } } assert config._get_environment('debug', test) == { 'DEBUG': True, 'KEY': False }
def environment_test(self, filename): config = Config('') config.from_toml(filename, environment='dev') assert config['TEST_KEY'] == 'foo' assert config['SECRET_KEY'] == 'devkey' assert config['DEBUG'] == True assert 'TESTING' not in config assert 'ignored' not in config config = Config('') config.from_toml(filename, environment='testing') assert config['TEST_KEY'] == 'foo' assert config['SECRET_KEY'] == 'devkey' assert config['TESTING'] == True assert 'DEBUG' not in config assert 'ignored' not in config
def make_config(self, instance_relative=False): root_path = self.root_path if instance_relative: root_path = self.instance_path return Config(root_path, self.default_config)
def test_toml_advanced(self): config = Config('') config.from_toml(self.example_prefix('advanced.toml')) self.advanced_test(config)
def test_toml_basic(self): config = Config('') config.from_toml(self.example_prefix('basic.toml')) self.basic_test(config)
def test_toml_format_error(self): with pytest.raises(toml.TomlError): example = self.example_prefix('format_err.toml') config = Config('') config.from_toml(example)