Beispiel #1
0
    def test_multiple_entries(self):
        # load the configuration
        config = load(DEFAULT_TEST_FILE)

        self.assertIn('list', config)
        self.assertEqual(4, len(config['list']))
        self.assertTrue(isinstance(config['list'], list))
Beispiel #2
0
    def test_multiple_entries_in_setion(self):
        # load the configuration
        config = load(DEFAULT_TEST_FILE)

        self.assertIn('Some Section', config)

        self.assertEqual('pymodconf-app-section',
                         config['Some Section']['opt'])
Beispiel #3
0
    def test_section_in_config(self):

        mapping = {'Some Section': ['opt']}

        try:
            self.config = load(DEFAULT_TEST_FILE, mapping)
        except InvalidConfigurationError:  # pragma: no cover
            self.fail(
                'InvalidConfigurationError exception raised unexpectedly!')
Beispiel #4
0
    def test_hello(self):
        # load the configuration
        config = load(DEFAULT_TEST_FILE)

        self.assertIn('name', config)
        self.assertIn('string', config)
        self.assertEqual('Hello pymodconf!', config['string'])

        print(config['string'])
Beispiel #5
0
    def test_load_module_config_file(self):
        # register the test tag
        t = Tag('Module: ')
        register(t)

        # load the configuration
        config = load(DEFAULT_TEST_FILE)

        # check if tag is available
        self.assertIn(str(t), config)
        self.assertEqual(1, len(config[str(t)]))
Beispiel #6
0
    def test_option_missing_in_config(self):

        mapping = {'Some Section': ['required option']}

        with self.assertRaises(InvalidConfigurationError):
            self.config = load(DEFAULT_TEST_FILE, mapping)
Beispiel #7
0
 def test_load_default_config_file(self):
     # load the configuration
     load(DEFAULT_TEST_FILE)