def test_search_path(self): cfg = Config('hello', 'world', search_path='testdata:testdata/a:testdata/b') self.assertTrue(cfg.has_section('section3')) self.assertEqual(cfg.get('section1', 'var1'), 'frob') self.assertEqual( cfg.loaded_files, ['testdata/app.ini', 'testdata/a/app.ini', 'testdata/b/app.ini'])
def test_search_path(self): cfg = Config('hello', 'world', search_path='testdata:testdata/a:testdata/b') self.assertTrue(cfg.has_section('section3')) self.assertEqual(cfg.get('section1', 'var1'), 'frob') self.assertEqual( cfg.loaded_files, ['testdata/app.ini', 'testdata/a/app.ini', 'testdata/b/app.ini'])
class SimpleInitTest(unittest.TestCase): def setUp(self): self.cfg = Config('hello', 'world', search_path='testdata') def test_simple_init(self): self.assertTrue(self.cfg.has_section('section1')) def test_get(self): self.assertEqual(self.cfg.get('section1', 'var1'), 'foo') self.assertEqual(self.cfg.get('section1', 'var2'), 'bar') self.assertEqual(self.cfg.get('section2', 'var1'), 'baz') def test_no_option_error(self): self.assertIs(self.cfg.get('section1', 'b'), None) def test_no_section_error(self): self.assertIs(self.cfg.get('a', 'b'), None)
class SimpleInitTest(unittest.TestCase): def setUp(self): self.cfg = Config("hello", "world", search_path="testdata") def test_simple_init(self): self.assertTrue(self.cfg.has_section("section1")) def test_get(self): self.assertEqual(self.cfg.get("section1", "var1"), "foo") self.assertEqual(self.cfg.get("section1", "var2"), "bar") self.assertEqual(self.cfg.get("section2", "var1"), "baz") def test_no_option_error(self): self.assertIs(self.cfg.get("section1", "b", default=None), None) def test_no_section_error(self): self.assertIs(self.cfg.get("a", "b", default=None), None)
class SimpleInitTest(unittest.TestCase): def setUp(self): self.cfg = Config('hello', 'world', search_path='testdata') def test_simple_init(self): self.assertTrue(self.cfg.has_section('section1')) def test_get(self): self.assertEqual(self.cfg.get('section1', 'var1'), 'foo') self.assertEqual(self.cfg.get('section1', 'var2'), 'bar') self.assertEqual(self.cfg.get('section2', 'var1'), 'baz') def test_no_option_error(self): self.assertIs(self.cfg.get('section1', 'b'), None) def test_no_section_error(self): self.assertIs(self.cfg.get('a', 'b'), None)
class SimpleInitFromContent(TestBase): ''' Tests loading a config string from memory ''' def setUp(self): super(SimpleInitFromContent, self).setUp() self.cfg = Config('not', 'existing', search_path='testdata') self.cfg.read_string(dedent( '''\ [section_mem] val = 1 ''' )) def test_sections_available(self): self.assertTrue(self.cfg.has_section('section_mem')) def test_getting_values(self): self.assertEqual(self.cfg.get('section_mem', 'val'), '1')
def test_search_path(self): cfg = Config("hello", "world", search_path="testdata:testdata/a:testdata/b") self.assertTrue(cfg.has_section("section3")) self.assertEqual(cfg.get("section1", "var1"), "frob") self.assertEqual(cfg.loaded_files, ["testdata/app.ini", "testdata/a/app.ini", "testdata/b/app.ini"])