Home | History | Annotate | Download | only in test

Lines Matching refs:cf

37             self.cf = self.config_class(allow_no_value=self.allow_no_value)
39 self.cf = self.config_class(defaults,
41 return self.cf
44 cf = self.newconfig(defaults)
46 cf.readfp(sio)
47 return cf
76 cf = self.fromstring(config_string)
77 L = cf.sections()
96 eq(cf.get('Foo Bar', 'foo'), 'bar')
97 eq(cf.get('Spacey Bar', 'foo'), 'bar')
98 eq(cf.get('Commented Bar', 'foo'), 'bar')
99 eq(cf.get('Spaces', 'key with spaces'), 'value')
100 eq(cf.get('Spaces', 'another with spaces'), 'splat!')
102 eq(cf.get('NoValue', 'option-without-value'), None)
104 self.assertNotIn('__name__', cf.options("Foo Bar"),
109 self.assertTrue(cf.remove_option('Foo Bar', 'foo'),
111 self.assertFalse(cf.has_option('Foo Bar', 'foo'),
113 self.assertFalse(cf.remove_option('Foo Bar', 'foo'),
118 cf.remove_option, 'No Such Section', 'foo')
120 eq(cf.get('Long Line', 'foo'),
124 cf = self.newconfig()
125 cf.add_section("A")
126 cf.add_section("a")
127 L = cf.sections()
131 cf.set("a", "B", "value")
132 eq(cf.options("a"), ["b"])
133 eq(cf.get("a", "b"), "value",
135 self.assertTrue(cf.has_option("a", "b"))
136 cf.set("A", "A-B", "A-B value")
139 cf.has_option("A", opt),
141 eq(cf.options("A"), ["a-b"])
142 eq(cf.options("a"), ["b"])
143 cf.remove_option("a", "B")
144 eq(cf.options("a"), [])
147 cf = self.fromstring(
149 eq(cf.options("MySection"), ["option"])
150 eq(cf.get("MySection", "Option"), "first line\nsecond line")
153 cf = self.fromstring("[section]\nnekey=nevalue\n",
155 self.assertTrue(cf.has_option("section", "Key"))
159 cf = self.newconfig({"foo": "Bar"})
161 cf.get("DEFAULT", "Foo"), "Bar",
163 cf = self.newconfig({"Foo": "Bar"})
165 cf.get("DEFAULT", "Foo"), "Bar",
183 self.assertRaises(exc, self.cf.readfp, sio)
186 cf = self.newconfig()
187 self.assertEqual(cf.sections(), [],
189 self.assertFalse(cf.has_section("Foo"),
193 cf.options, "Foo")
195 cf.set, "foo", "bar", "value")
197 cf.add_section("foo")
202 self.cf.get(section, option)
210 cf = self.fromstring(
229 self.assertTrue(cf.getboolean('BOOLTEST', 't%d' % x))
230 self.assertFalse(cf.getboolean('BOOLTEST', 'f%d' % x))
232 cf.getboolean, 'BOOLTEST', 'e%d' % x)
235 cf = self.newconfig()
236 cf.add_section("Foo")
238 cf.add_section, "Foo")
255 cf = self.fromstring(config_string)
257 cf.write(output)
277 cf = self.fromstring("[sect]\n"
283 cf.set("sect", "option1", "splat")
284 cf.set("sect", "option1", mystr("splat"))
285 cf.set("sect", "option2", "splat")
286 cf.set("sect", "option2", mystr("splat"))
294 cf = self.fromstring("[sect]\n"
296 cf.set("sect", "option1", unicode("splat"))
297 cf.set("sect", "option2", unicode("splat"))
302 cf = self.newconfig()
303 parsed_files = cf.read([file1, "nonexistent-file"])
305 self.assertEqual(cf.get("Foo Bar", "foo"), "newbar")
307 cf = self.newconfig()
308 parsed_files = cf.read(file1)
310 self.assertEqual(cf.get("Foo Bar", "foo"), "newbar")
312 cf = self.newconfig()
313 parsed_files = cf.read(["nonexistent-file"])
316 cf = self.newconfig()
317 parsed_files = cf.read([])
350 cf = self.fromstring(
357 L = list(cf.items("section"))
372 cf = self.get_interpolation_config()
374 eq(cf.get("Foo", "getname"), "Foo")
375 eq(cf.get("Foo", "bar"), "something with interpolation (1 step)")
376 eq(cf.get("Foo", "bar9"),
378 eq(cf.get("Foo", "bar10"),
398 cf = self.newconfig()
399 cf.add_section('non-string')
400 cf.set('non-string', 'int', 1)
401 cf.set('non-string', 'list', [0, 1, 1, 2, 3, 5, 8, 13, '%('])
402 cf.set('non-string', 'dict', {'pi': 3.14159, '%(': 1,
404 cf.set('non-string', 'string_with_interpolation', '%(list)s')
405 cf.set('non-string', 'no-value')
406 self.assertEqual(cf.get('non-string', 'int', raw=True), 1)
407 self.assertRaises(TypeError, cf.get, 'non-string', 'int')
408 self.assertEqual(cf.get('non-string', 'list', raw=True),
410 self.assertRaises(TypeError, cf.get, 'non-string', 'list')
411 self.assertEqual(cf.get('non-string', 'dict', raw=True),
413 self.assertRaises(TypeError, cf.get, 'non-string', 'dict')
414 self.assertEqual(cf.get('non-string', 'string_with_interpolation',
416 self.assertRaises(ValueError, cf.get, 'non-string',
418 self.assertEqual(cf.get('non-string', 'no-value'), None)
427 cf = self.newconfig()
430 cf.add_section(s)
432 cf.set(s, 'lovely_spam{}'.format(j), self.wonderful_spam)
434 cf.write(f)
452 cf = self.get_interpolation_config()
454 eq(cf.get("Foo", "getname"), "%(__name__)s")
455 eq(cf.get("Foo", "bar"),
457 eq(cf.get("Foo", "bar9"),
459 eq(cf.get("Foo", "bar10"),
461 eq(cf.get("Foo", "bar11"),
472 cf = self.newconfig()
473 cf.add_section('non-string')
474 cf.set('non-string', 'int', 1)
475 cf.set('non-string', 'list', [0, 1, 1, 2, 3, 5, 8, 13])
476 cf.set('non-string', 'dict', {'pi': 3.14159})
477 self.assertEqual(cf.get('non-string', 'int'), 1)
478 self.assertEqual(cf.get('non-string', 'list'),
480 self.assertEqual(cf.get('non-string', 'dict'), {'pi': 3.14159})
488 cf = self.fromstring("[section]\n"
493 self.assertEqual(cf.get("section", "ok"), "xxx/%s")
494 self.assertEqual(cf.get("section", "not_ok"), "xxx/xxx/%s")
497 cf = self.fromstring("[sect]\n"
500 self.assertEqual(cf.get('sect', "option1"), "foo")
502 self.assertRaises(ValueError, cf.set, "sect", "option1", "%foo")
503 self.assertRaises(ValueError, cf.set, "sect", "option1", "foo%")
504 self.assertRaises(ValueError, cf.set, "sect", "option1", "f%oo")
506 self.assertEqual(cf.get('sect', "option1"), "foo")
509 cf.set("sect", "option2", "foo%%bar")
510 self.assertEqual(cf.get("sect", "option2"), "foo%bar")
513 cf = self.fromstring("[sect]\n"
517 self.assertRaises(TypeError, cf.set, "sect", "option1", 1)
518 self.assertRaises(TypeError, cf.set, "sect", "option1", 1.0)
519 self.assertRaises(TypeError, cf.set, "sect", "option1", object())
520 self.assertRaises(TypeError, cf.set, "sect", "option2", 1)
521 self.assertRaises(TypeError, cf.set, "sect", "option2", 1.0)
522 self.assertRaises(TypeError, cf.set, "sect", "option2", object())
525 cf = self.newconfig()
526 self.assertRaises(ValueError, cf.add_section, "default")
529 cf = self.newconfig()
530 self.assertRaises(ValueError, cf.add_section, "DEFAULT")
588 self.cf = self.config_class(defaults=defaults, dict_type=SortedDict)
589 return self.cf
600 self.cf.write(output)