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))
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'])
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!')
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'])
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)]))
def test_option_missing_in_config(self): mapping = {'Some Section': ['required option']} with self.assertRaises(InvalidConfigurationError): self.config = load(DEFAULT_TEST_FILE, mapping)
def test_load_default_config_file(self): # load the configuration load(DEFAULT_TEST_FILE)