Пример #1
0
 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
     }
Пример #2
0
 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
     }
Пример #3
0
    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
Пример #4
0
    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
Пример #5
0
    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)
Пример #6
0
 def test_toml_advanced(self):
     config = Config('')
     config.from_toml(self.example_prefix('advanced.toml'))
     self.advanced_test(config)
Пример #7
0
 def test_toml_basic(self):
     config = Config('')
     config.from_toml(self.example_prefix('basic.toml'))
     self.basic_test(config)
Пример #8
0
 def test_toml_format_error(self):
     with pytest.raises(toml.TomlError):
         example = self.example_prefix('format_err.toml')
         config = Config('')
         config.from_toml(example)
Пример #9
0
 def test_toml_advanced(self):
     config = Config('')
     config.from_toml(self.example_prefix('advanced.toml'))
     self.advanced_test(config)
Пример #10
0
 def test_toml_basic(self):
     config = Config('')
     config.from_toml(self.example_prefix('basic.toml'))
     self.basic_test(config)
Пример #11
0
 def test_toml_format_error(self):
     with pytest.raises(toml.TomlError):
         example = self.example_prefix('format_err.toml')
         config = Config('')
         config.from_toml(example)