• Home
  • History
  • Annotate
  • Raw
  • Download

Lines Matching refs:cf

64         cf = self.newconfig(defaults)
65 cf.read_string(string)
66 return cf
71 def basic_test(self, cf): argument
89 L = cf.sections()
93 L = cf.items('Spacey Bar From The Beginning')
98 L = [section for section in cf]
103 L = cf['Spacey Bar From The Beginning'].items()
106 L = cf.items()
111 eq(cf.defaults(), cf[self.default_section])
118 eq(cf.get('Foo Bar', 'foo'), 'bar1')
119 eq(cf.get('Spacey Bar', 'foo'), 'bar2')
120 eq(cf.get('Spacey Bar From The Beginning', 'foo'), 'bar3')
121 eq(cf.get('Spacey Bar From The Beginning', 'baz'), 'qwe')
122 eq(cf.get('Commented Bar', 'foo'), 'bar4')
123 eq(cf.get('Commented Bar', 'baz'), 'qwe')
124 eq(cf.get('Spaces', 'key with spaces'), 'value')
125 eq(cf.get('Spaces', 'another with spaces'), 'splat!')
126 eq(cf.getint('Types', 'int'), 42)
127 eq(cf.get('Types', 'int'), "42")
128 self.assertAlmostEqual(cf.getfloat('Types', 'float'), 0.44)
129 eq(cf.get('Types', 'float'), "0.44")
130 eq(cf.getboolean('Types', 'boolean'), False)
131 eq(cf.get('Types', '123'), 'strange but acceptable')
133 eq(cf.get('NoValue', 'option-without-value'), None)
136 eq(cf.get('Foo Bar', 'foo', fallback='baz'), 'bar1')
137 eq(cf.get('Foo Bar', 'foo', vars={'foo': 'baz'}), 'baz')
139 cf.get('No Such Foo Bar', 'foo')
141 cf.get('Foo Bar', 'no-such-foo')
142 eq(cf.get('No Such Foo Bar', 'foo', fallback='baz'), 'baz')
143 eq(cf.get('Foo Bar', 'no-such-foo', fallback='baz'), 'baz')
144 eq(cf.get('Spacey Bar', 'foo', fallback=None), 'bar2')
145 eq(cf.get('No Such Spacey Bar', 'foo', fallback=None), None)
146 eq(cf.getint('Types', 'int', fallback=18), 42)
147 eq(cf.getint('Types', 'no-such-int', fallback=18), 18)
148 eq(cf.getint('Types', 'no-such-int', fallback="18"), "18") # sic!
150 cf.getint('Types', 'no-such-int')
151 self.assertAlmostEqual(cf.getfloat('Types', 'float',
153 self.assertAlmostEqual(cf.getfloat('Types', 'no-such-float',
155 eq(cf.getfloat('Types', 'no-such-float', fallback="0.0"), "0.0") # sic!
157 cf.getfloat('Types', 'no-such-float')
158 eq(cf.getboolean('Types', 'boolean', fallback=True), False)
159 eq(cf.getboolean('Types', 'no-such-boolean', fallback="yes"),
161 eq(cf.getboolean('Types', 'no-such-boolean', fallback=True), True)
163 cf.getboolean('Types', 'no-such-boolean')
164 eq(cf.getboolean('No Such Types', 'boolean', fallback=True), True)
166 eq(cf.get('NoValue', 'option-without-value', fallback=False), None)
167 eq(cf.get('NoValue', 'no-such-option-without-value',
171 eq(cf['Foo Bar']['foo'], 'bar1')
172 eq(cf['Spacey Bar']['foo'], 'bar2')
173 section = cf['Spacey Bar From The Beginning']
175 self.assertIs(section.parser, cf)
182 eq(cf['Commented Bar']['foo'], 'bar4')
183 eq(cf['Commented Bar']['baz'], 'qwe')
184 eq(cf['Spaces']['key with spaces'], 'value')
185 eq(cf['Spaces']['another with spaces'], 'splat!')
186 eq(cf['Long Line']['foo'],
189 eq(cf['NoValue']['option-without-value'], None)
191 eq(cf['Foo Bar'].get('foo', 'baz'), 'bar1')
192 eq(cf['Foo Bar'].get('foo', fallback='baz'), 'bar1')
193 eq(cf['Foo Bar'].get('foo', vars={'foo': 'baz'}), 'baz')
195 cf['No Such Foo Bar']['foo']
197 cf['Foo Bar']['no-such-foo']
199 cf['No Such Foo Bar'].get('foo', fallback='baz')
200 eq(cf['Foo Bar'].get('no-such-foo', 'baz'), 'baz')
201 eq(cf['Foo Bar'].get('no-such-foo', fallback='baz'), 'baz')
202 eq(cf['Foo Bar'].get('no-such-foo'), None)
203 eq(cf['Spacey Bar'].get('foo', None), 'bar2')
204 eq(cf['Spacey Bar'].get('foo', fallback=None), 'bar2')
206 cf['No Such Spacey Bar'].get('foo', None)
207 eq(cf['Types'].getint('int', 18), 42)
208 eq(cf['Types'].getint('int', fallback=18), 42)
209 eq(cf['Types'].getint('no-such-int', 18), 18)
210 eq(cf['Types'].getint('no-such-int', fallback=18), 18)
211 eq(cf['Types'].getint('no-such-int', "18"), "18") # sic!
212 eq(cf['Types'].getint('no-such-int', fallback="18"), "18") # sic!
213 eq(cf['Types'].getint('no-such-int'), None)
214 self.assertAlmostEqual(cf['Types'].getfloat('float', 0.0), 0.44)
215 self.assertAlmostEqual(cf['Types'].getfloat('float',
217 self.assertAlmostEqual(cf['Types'].getfloat('no-such-float', 0.0), 0.0)
218 self.assertAlmostEqual(cf['Types'].getfloat('no-such-float',
220 eq(cf['Types'].getfloat('no-such-float', "0.0"), "0.0") # sic!
221 eq(cf['Types'].getfloat('no-such-float', fallback="0.0"), "0.0") # sic!
222 eq(cf['Types'].getfloat('no-such-float'), None)
223 eq(cf['Types'].getboolean('boolean', True), False)
224 eq(cf['Types'].getboolean('boolean', fallback=True), False)
225 eq(cf['Types'].getboolean('no-such-boolean', "yes"), "yes") # sic!
226 eq(cf['Types'].getboolean('no-such-boolean', fallback="yes"),
228 eq(cf['Types'].getboolean('no-such-boolean', True), True)
229 eq(cf['Types'].getboolean('no-such-boolean', fallback=True), True)
230 eq(cf['Types'].getboolean('no-such-boolean'), None)
232 eq(cf['NoValue'].get('option-without-value', False), None)
233 eq(cf['NoValue'].get('option-without-value', fallback=False), None)
234 eq(cf['NoValue'].get('no-such-option-without-value', False), False)
235 eq(cf['NoValue'].get('no-such-option-without-value',
241 cf[self.default_section]['this_value'] = '1'
242 cf[self.default_section]['that_value'] = '2'
245 self.assertTrue(cf.remove_section('Spaces'))
246 self.assertFalse(cf.has_option('Spaces', 'key with spaces'))
247 self.assertFalse(cf.remove_section('Spaces'))
248 self.assertFalse(cf.remove_section(self.default_section))
249 self.assertTrue(cf.remove_option('Foo Bar', 'foo'),
251 self.assertFalse(cf.has_option('Foo Bar', 'foo'),
253 self.assertFalse(cf.remove_option('Foo Bar', 'foo'),
256 self.assertTrue(cf.has_option('Foo Bar', 'this_value'))
257 self.assertFalse(cf.remove_option('Foo Bar', 'this_value'))
258 self.assertTrue(cf.remove_option(self.default_section, 'this_value'))
259 self.assertFalse(cf.has_option('Foo Bar', 'this_value'))
260 self.assertFalse(cf.remove_option(self.default_section, 'this_value'))
263 cf.remove_option('No Such Section', 'foo')
266 eq(cf.get('Long Line', 'foo'),
270 del cf['Types']
271 self.assertFalse('Types' in cf)
273 del cf['Types']
275 del cf[self.default_section]
276 del cf['Spacey Bar']['foo']
277 self.assertFalse('foo' in cf['Spacey Bar'])
279 del cf['Spacey Bar']['foo']
280 self.assertTrue('that_value' in cf['Spacey Bar'])
282 del cf['Spacey Bar']['that_value']
283 del cf[self.default_section]['that_value']
284 self.assertFalse('that_value' in cf['Spacey Bar'])
286 del cf[self.default_section]['that_value']
288 del cf['No Such Section']['foo']
328 cf = self.fromstring(config_string)
329 self.basic_test(cf)
332 cf.read_string(textwrap.dedent("""\
338 cf.read_string(textwrap.dedent("""\
345 cf.read_string(textwrap.dedent("""\
351 cf.read_string(textwrap.dedent("""\
403 cf = self.newconfig()
404 cf.read_dict(config)
405 self.basic_test(cf)
408 cf.read_dict({
413 cf.read_dict({
420 cf.read_dict({
424 cf.read_dict({
432 cf = self.newconfig()
433 cf.add_section("A")
434 cf.add_section("a")
435 cf.add_section("B")
436 L = cf.sections()
440 cf.set("a", "B", "value")
441 eq(cf.options("a"), ["b"])
442 eq(cf.get("a", "b"), "value",
446 cf.set("b", "A", "value")
447 self.assertTrue(cf.has_option("a", "b"))
448 self.assertFalse(cf.has_option("b", "b"))
449 cf.set("A", "A-B", "A-B value")
452 cf.has_option("A", opt),
454 eq(cf.options("A"), ["a-b"])
455 eq(cf.options("a"), ["b"])
456 cf.remove_option("a", "B")
457 eq(cf.options("a"), [])
460 cf = self.fromstring(
463 eq(cf.options("MySection"), ["option"])
464 eq(cf.get("MySection", "Option"), "first line\nsecond line")
467 cf = self.fromstring("[section]\n"
470 self.assertTrue(cf.has_option("section", "Key"))
474 cf = self.newconfig()
475 cf["A"] = {}
476 cf["a"] = {"B": "value"}
477 cf["B"] = {}
478 L = [section for section in cf]
483 eq(cf["a"].keys(), {"b"})
484 eq(cf["a"]["b"], "value",
488 cf["b"]["A"] = "value"
489 self.assertTrue("b" in cf["a"])
490 cf["A"]["A-B"] = "A-B value"
493 opt in cf["A"],
495 eq(cf["A"].keys(), {"a-b"})
496 eq(cf["a"].keys(), {"b"})
497 del cf["a"]["B"]
498 elem_eq(cf["a"].keys(), {})
501 cf = self.fromstring(
504 eq(cf["MySection"].keys(), {"option"})
505 eq(cf["MySection"]["Option"], "first line\nsecond line")
508 cf = self.fromstring("[section]\n"
511 self.assertTrue("Key" in cf["section"])
514 cf = self.newconfig({"foo": "Bar"})
516 cf.get(self.default_section, "Foo"), "Bar",
518 cf = self.newconfig({"Foo": "Bar"})
520 cf.get(self.default_section, "Foo"), "Bar",
524 cf = self.newconfig()
525 self.parse_error(cf, configparser.ParsingError,
528 self.parse_error(cf, configparser.ParsingError,
531 e = self.parse_error(cf, configparser.MissingSectionHeaderError,
535 e = self.parse_error(cf, configparser.ParsingError,
548 e = self.parse_error(cf, error, f)
551 def parse_error(self, cf, exc, src): argument
557 cf.read_file(sio)
561 cf = self.newconfig()
562 self.assertEqual(cf.sections(), [],
564 self.assertFalse(cf.has_section("Foo"),
568 cf.options("Foo")
570 cf.set("foo", "bar", "value")
571 e = self.get_error(cf, configparser.NoSectionError, "foo", "bar")
573 cf.add_section("foo")
574 e = self.get_error(cf, configparser.NoOptionError, "foo", "bar")
577 def get_error(self, cf, exc, section, option): argument
579 cf.get(section, option)
587 cf = self.fromstring(
606 self.assertTrue(cf.getboolean('BOOLTEST', 't%d' % x))
607 self.assertFalse(cf.getboolean('BOOLTEST', 'f%d' % x))
609 cf.getboolean, 'BOOLTEST', 'e%d' % x)
612 cf = self.newconfig()
613 cf.add_section("Foo")
615 cf.add_section("Foo")
622 cf.read_string(textwrap.dedent("""\
636 cf.read_dict({'Bar': {'opt': 'val', 'OPT': 'is really `opt`'}})
664 cf = self.fromstring(config_string)
667 cf.write(output, space_around_delimiters=space_around_delimiters)
697 cf = self.fromstring("[sect]\n"
703 cf.set("sect", "option1", "splat")
704 cf.set("sect", "option1", mystr("splat"))
705 cf.set("sect", "option2", "splat")
706 cf.set("sect", "option2", mystr("splat"))
707 cf.set("sect", "option1", "splat")
708 cf.set("sect", "option2", "splat")
715 cf = self.newconfig()
716 parsed_files = cf.read([file1, "nonexistent-file"])
718 self.assertEqual(cf.get("Foo Bar", "foo"), "newbar")
720 cf = self.newconfig()
721 parsed_files = cf.read(file1)
723 self.assertEqual(cf.get("Foo Bar", "foo"), "newbar")
725 cf = self.newconfig()
726 parsed_files = cf.read(pathlib.Path(file1))
728 self.assertEqual(cf.get("Foo Bar", "foo"), "newbar")
730 cf = self.newconfig()
731 parsed_files = cf.read([pathlib.Path(file1), file1])
733 self.assertEqual(cf.get("Foo Bar", "foo"), "newbar")
735 cf = self.newconfig()
736 parsed_files = cf.read(["nonexistent-file"])
739 cf = self.newconfig()
740 parsed_files = cf.read([])
748 cf = self.newconfig()
749 parsed_files = cf.read(file1_bytestring)
752 cf = self.newconfig()
753 parsed_files = cf.read(b'nonexistent-file')
756 cf = self.newconfig()
757 parsed_files = cf.read([file1_bytestring, b'nonexistent-file'])
789 cf = self.fromstring("""
795 L = list(cf.items("section", vars={'value': 'value'}))
799 cf.items("no such section")
802 cf = self.fromstring("""
810 self.assertEqual(cf.popitem()[0], 'section1')
811 self.assertEqual(cf.popitem()[0], 'section2')
812 self.assertEqual(cf.popitem()[0], 'section3')
814 cf.popitem()
817 cf = self.newconfig({"foo": "Bar"})
819 cf.get(self.default_section, "Foo"), "Bar",
821 cf['zing'] = {'option1': 'value1', 'option2': 'value2'}
822 self.assertEqual(cf.sections(), ['zing'])
823 self.assertEqual(set(cf['zing'].keys()), {'option1', 'option2', 'foo'})
824 cf.clear()
825 self.assertEqual(set(cf.sections()), set())
826 self.assertEqual(set(cf[self.default_section].keys()), {'foo'})
829 cf = self.fromstring("""
837 self.assertEqual(set(cf['section1'].keys()), {'name1', 'named'})
838 self.assertEqual(set(cf['section2'].keys()), {'name2', 'named'})
839 self.assertEqual(set(cf['section3'].keys()), {'name3', 'named'})
840 self.assertEqual(cf['section1']['name1'], 'value1')
841 self.assertEqual(cf['section2']['name2'], 'value2')
842 self.assertEqual(cf['section3']['name3'], 'value3')
843 self.assertEqual(cf.sections(), ['section1', 'section2', 'section3'])
844 cf['section2'] = {'name22': 'value22'}
845 self.assertEqual(set(cf['section2'].keys()), {'name22', 'named'})
846 self.assertEqual(cf['section2']['name22'], 'value22')
847 self.assertNotIn('name2', cf['section2'])
848 self.assertEqual(cf.sections(), ['section1', 'section2', 'section3'])
849 cf['section3'] = {}
850 self.assertEqual(set(cf['section3'].keys()), {'named'})
851 self.assertNotIn('name3', cf['section3'])
852 self.assertEqual(cf.sections(), ['section1', 'section2', 'section3'])
854 cf[self.default_section] = cf[self.default_section]
855 self.assertNotEqual(set(cf[self.default_section].keys()), set())
856 cf[self.default_section] = {}
857 self.assertEqual(set(cf[self.default_section].keys()), set())
858 self.assertEqual(set(cf['section1'].keys()), {'name1'})
859 self.assertEqual(set(cf['section2'].keys()), {'name22'})
860 self.assertEqual(set(cf['section3'].keys()), set())
861 self.assertEqual(cf.sections(), ['section1', 'section2', 'section3'])
863 cf['section2'] = cf['section2']
864 self.assertEqual(set(cf['section2'].keys()), {'name22'})
875 cf = self.newconfig()
877 cf.read_string(invalid)
878 self.assertEqual(cf.get('DEFAULT', 'test'), 'test')
879 self.assertEqual(cf['DEFAULT']['test'], 'test')
891 cf = self.get_interpolation_config()
893 eq(cf.get("Foo", "bar"), "something with interpolation (1 step)")
894 eq(cf.get("Foo", "bar9"),
896 eq(cf.get("Foo", "bar10"),
898 e = self.get_error(cf, configparser.InterpolationDepthError, "Foo", "bar11")
907 cf = self.get_interpolation_config()
908 e = self.get_error(cf, configparser.InterpolationMissingOptionError,
928 cf = self.fromstring("[section]\n"
934 self.assertEqual(cf.get("section", "ok"), "xxx/%s")
936 self.assertEqual(cf.get("section", "not_ok"), "xxx/xxx/%s")
939 cf.get("section", "not_ok")
942 cf = self.fromstring("[sect]\n"
945 self.assertEqual(cf.get('sect', "option1"), "foo")
947 self.assertRaises(ValueError, cf.set, "sect", "option1", "%foo")
948 self.assertRaises(ValueError, cf.set, "sect", "option1", "foo%")
949 self.assertRaises(ValueError, cf.set, "sect", "option1", "f%oo")
951 self.assertEqual(cf.get('sect', "option1"), "foo")
954 cf.set("sect", "option2", "foo%%bar")
955 self.assertEqual(cf.get("sect", "option2"), "foo%bar")
958 cf = self.fromstring("[sect]\n"
962 self.assertRaises(TypeError, cf.set, "sect", "option1", 1)
963 self.assertRaises(TypeError, cf.set, "sect", "option1", 1.0)
964 self.assertRaises(TypeError, cf.set, "sect", "option1", object())
965 self.assertRaises(TypeError, cf.set, "sect", "option2", 1)
966 self.assertRaises(TypeError, cf.set, "sect", "option2", 1.0)
967 self.assertRaises(TypeError, cf.set, "sect", "option2", object())
968 self.assertRaises(TypeError, cf.set, "sect", 123, "invalid opt name!")
969 self.assertRaises(TypeError, cf.add_section, 123)
972 cf = self.newconfig()
973 self.assertRaises(ValueError, cf.add_section, self.default_section)
977 cf = self.newconfig(defaults={1: 2.4})
978 self.assertEqual(cf[self.default_section]['1'], '2.4')
979 self.assertAlmostEqual(cf[self.default_section].getfloat('1'), 2.4)
980 cf = self.newconfig(defaults={"A": 5.2})
981 self.assertEqual(cf[self.default_section]['a'], '5.2')
982 self.assertAlmostEqual(cf[self.default_section].getfloat('a'), 5.2)
998 def assertMatchesIni(self, cf): argument
999 self.assertEqual(cf['numbers']['one'], '1')
1000 self.assertEqual(cf['numbers']['two'], '%(one)s * 2')
1001 self.assertEqual(cf['numbers']['three'], '${common:one} * 3')
1002 self.assertEqual(cf['hexen']['sixteen'], '${numbers:two} * 8')
1005 cf = self.fromstring(self.ini)
1006 self.assertMatchesIni(cf)
1009 cf = self.newconfig()
1010 self.assertIsNone(cf.read_string(""))
1016 cf = CustomConfigParser()
1017 cf.read_string(self.ini)
1018 self.assertMatchesIni(cf)
1026 cf = self.fromstring("[sect]\n"
1029 self.assertEqual(cf.get('sect', "option1"), "foo")
1031 cf.set("sect", "option1", "%foo")
1032 self.assertEqual(cf.get('sect', "option1"), "%foo")
1033 cf.set("sect", "option1", "foo%")
1034 self.assertEqual(cf.get('sect', "option1"), "foo%")
1035 cf.set("sect", "option1", "f%oo")
1036 self.assertEqual(cf.get('sect', "option1"), "f%oo")
1039 cf.set("sect", "option2", "foo%%bar")
1040 self.assertEqual(cf.get("sect", "option2"), "foo%%bar")
1060 cf = self.newconfig()
1063 cf.add_section(s)
1065 cf.set(s, 'lovely_spam{}'.format(j), self.wonderful_spam)
1067 cf.write(f)
1086 cf = self.get_interpolation_config()
1088 eq(cf.get("Foo", "bar"),
1090 eq(cf.get("Foo", "bar9"),
1092 eq(cf.get("Foo", "bar10"),
1094 eq(cf.get("Foo", "bar11"),
1104 cf = self.newconfig()
1105 cf.add_section('non-string')
1106 cf.set('non-string', 'int', 1)
1107 cf.set('non-string', 'list', [0, 1, 1, 2, 3, 5, 8, 13])
1108 cf.set('non-string', 'dict', {'pi': 3.14159})
1109 self.assertEqual(cf.get('non-string', 'int'), 1)
1110 self.assertEqual(cf.get('non-string', 'list'),
1112 self.assertEqual(cf.get('non-string', 'dict'), {'pi': 3.14159})
1113 cf.add_section(123)
1114 cf.set(123, 'this is sick', True)
1115 self.assertEqual(cf.get(123, 'this is sick'), True)
1116 if cf._dict is configparser._default_dict:
1119 cf.optionxform = lambda x: x
1120 cf.set('non-string', 1, 1)
1121 self.assertEqual(cf.get('non-string', 1), 1)
1129 cf = self.newconfig(defaults={"A": 5.2})
1130 self.assertAlmostEqual(cf[self.default_section]['a'], 5.2)
1148 cf = self.newconfig()
1149 parsed_files = cf.read([smbconf, "nonexistent-file"], encoding='utf-8')
1153 self.assertEqual(cf.sections(), sections)
1154 self.assertEqual(cf.get("global", "workgroup"), "MDKGROUP")
1155 self.assertEqual(cf.getint("global", "max log size"), 50)
1156 self.assertEqual(cf.get("global", "hosts allow"), "127.")
1157 self.assertEqual(cf.get("tmp", "echo command"), "cat %s; rm %s")
1166 cf = self.newconfig(defaults)
1168 cf.optionxform = optionxform
1169 cf.read_string(string)
1170 return cf
1173 cf = self.fromstring(textwrap.dedent("""
1198 eq(cf['common']['favourite Beatle'], 'Paul')
1199 eq(cf['common']['favourite color'], 'green')
1200 eq(cf['tom']['favourite Beatle'], 'Paul')
1201 eq(cf['tom']['favourite color'], 'green')
1202 eq(cf['tom']['favourite band'], 'green day')
1203 eq(cf['tom']['favourite pope'], 'John Paul II')
1204 eq(cf['tom']['sequel'], 'John Paul III')
1205 eq(cf['ambv']['favourite Beatle'], 'George')
1206 eq(cf['ambv']['favourite color'], 'green')
1207 eq(cf['ambv']['son of Edward VII'], 'George V')
1208 eq(cf['ambv']['son of George V'], 'George VI')
1209 eq(cf['stanley']['favourite Beatle'], 'George')
1210 eq(cf['stanley']['favourite color'], 'black')
1211 eq(cf['stanley']['favourite state of mind'], 'paranoid')
1212 eq(cf['stanley']['favourite movie'], 'soylent green')
1213 eq(cf['stanley']['favourite pope'], 'John Paul II')
1214 eq(cf['stanley']['favourite song'],
1218 cf = self.fromstring(textwrap.dedent("""
1230 cf['one for you']['ping']
1232 cf['selfish']['me']
1235 cf = self.fromstring("""
1246 self.assertEqual(cf['dollars']['$var'], '$value')
1247 self.assertEqual(cf['interpolated']['$other'], '$value')
1248 self.assertEqual(cf['dollars']['${sick}'], 'cannot interpolate me')
1251 cf['interpolated']['$trying']
1270 cf = self.fromstring(ini)
1272 eq(cf['common']['optionlower'], 'value')
1273 eq(cf['common']['OptionUpper'], 'Value')
1274 eq(cf['Common']['optionlower'], 'a better value')
1275 eq(cf['Common']['OptionUpper'], 'A Better Value')
1276 eq(cf['random']['foolower'], 'value redefined')
1277 eq(cf['random']['FooUpper'], 'A Better Value Redefined')
1294 cf = self.fromstring(ini)
1297 cf = self.fromstring(ini, optionxform=lambda opt: opt)
1299 eq(cf['common']['option'], 'value')
1300 eq(cf['common']['Option'], 'Value')
1301 eq(cf['Common']['option'], 'a better value')
1302 eq(cf['Common']['Option'], 'A Better Value')
1303 eq(cf['random']['foo'], 'value redefined')
1304 eq(cf['random']['Foo'], 'A Better Value Redefined')
1307 cf = self.fromstring("""
1317 cf['interpolation fail']['case1']
1319 cf['interpolation fail']['case2']
1321 cf['interpolation fail']['case3']
1323 cf['interpolation fail']['case4']
1325 cf['interpolation fail']['case5']
1327 cf['interpolation fail']['case6'] = "BLACK $ABBATH"
1342 cf = self.newconfig()
1343 self.assertEqual(len(cf.read(tricky, encoding='utf-8')), 1)
1344 self.assertEqual(cf.sections(), ['strange',
1352 self.assertEqual(cf.getint(self.default_section, 'go',
1356 cf.getint(self.default_section, 'go', raw=True,
1358 self.assertEqual(len(cf.get('strange', 'other').split('\n')), 4)
1359 self.assertEqual(len(cf.get('corruption', 'value').split('\n')), 10)
1361 self.assertFalse(cf.getboolean(longname, 'are they subsections'))
1362 self.assertEqual(cf.get(longname, 'lets use some Unicode'), '片仮名')
1363 self.assertEqual(len(cf.items('another one!')), 5) # 4 in section and
1366 cf.items('no values here')
1367 self.assertEqual(cf.get('tricky interpolation', 'lets'), 'do this')
1368 self.assertEqual(cf.get('tricky interpolation', 'lets'),
1369 cf.get('tricky interpolation', 'go'))
1370 self.assertEqual(cf.get('more interpolation', 'lets'), 'go shopping')
1374 cf = self.newconfig()
1376 cf.read(tricky, encoding='ascii')
1412 cf = self.fromstring("[b]\n"
1420 cf.write(output)
1446 cf = self.fromstring(config_string)
1447 self.assertEqual(cf.get('Commented Bar', 'foo'),
1449 self.assertEqual(cf.get('Commented Bar', 'baz'), 'qwe')
1450 self.assertEqual(cf.get('Commented Bar', 'quirk'),
1457 cf = self.newconfig(defaults)
1458 cf.read_string(string)
1460 cf_copy.read_dict(cf)
1466 for default, value in cf[self.default_section].items():