Lines Matching refs:cf
64 cf = self.newconfig(defaults)
65 cf.read_string(string)
66 return cf
71 def basic_test(self, cf):
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):
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):
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
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'])
853 cf[self.default_section] = {}
854 self.assertEqual(set(cf[self.default_section].keys()), set())
855 self.assertEqual(set(cf['section1'].keys()), {'name1'})
856 self.assertEqual(set(cf['section2'].keys()), {'name22'})
857 self.assertEqual(set(cf['section3'].keys()), set())
858 self.assertEqual(cf.sections(), ['section1', 'section2', 'section3'])
869 cf = self.newconfig()
871 cf.read_string(invalid)
872 self.assertEqual(cf.get('DEFAULT', 'test'), 'test')
873 self.assertEqual(cf['DEFAULT']['test'], 'test')
885 cf = self.get_interpolation_config()
887 eq(cf.get("Foo", "bar"), "something with interpolation (1 step)")
888 eq(cf.get("Foo", "bar9"),
890 eq(cf.get("Foo", "bar10"),
892 e = self.get_error(cf, configparser.InterpolationDepthError, "Foo", "bar11")
901 cf = self.get_interpolation_config()
902 e = self.get_error(cf, configparser.InterpolationMissingOptionError,
923 cf = self.fromstring("[section]\n"
929 self.assertEqual(cf.get("section", "ok"), "xxx/%s")
931 self.assertEqual(cf.get("section", "not_ok"), "xxx/xxx/%s")
934 cf.get("section", "not_ok")
937 cf = self.fromstring("[sect]\n"
940 self.assertEqual(cf.get('sect', "option1"), "foo")
942 self.assertRaises(ValueError, cf.set, "sect", "option1", "%foo")
943 self.assertRaises(ValueError, cf.set, "sect", "option1", "foo%")
944 self.assertRaises(ValueError, cf.set, "sect", "option1", "f%oo")
946 self.assertEqual(cf.get('sect', "option1"), "foo")
949 cf.set("sect", "option2", "foo%%bar")
950 self.assertEqual(cf.get("sect", "option2"), "foo%bar")
953 cf = self.fromstring("[sect]\n"
957 self.assertRaises(TypeError, cf.set, "sect", "option1", 1)
958 self.assertRaises(TypeError, cf.set, "sect", "option1", 1.0)
959 self.assertRaises(TypeError, cf.set, "sect", "option1", object())
960 self.assertRaises(TypeError, cf.set, "sect", "option2", 1)
961 self.assertRaises(TypeError, cf.set, "sect", "option2", 1.0)
962 self.assertRaises(TypeError, cf.set, "sect", "option2", object())
963 self.assertRaises(TypeError, cf.set, "sect", 123, "invalid opt name!")
964 self.assertRaises(TypeError, cf.add_section, 123)
967 cf = self.newconfig()
968 self.assertRaises(ValueError, cf.add_section, self.default_section)
972 cf = self.newconfig(defaults={1: 2.4})
973 self.assertEqual(cf[self.default_section]['1'], '2.4')
974 self.assertAlmostEqual(cf[self.default_section].getfloat('1'), 2.4)
975 cf = self.newconfig(defaults={"A": 5.2})
976 self.assertEqual(cf[self.default_section]['a'], '5.2')
977 self.assertAlmostEqual(cf[self.default_section].getfloat('a'), 5.2)
993 def assertMatchesIni(self, cf):
994 self.assertEqual(cf['numbers']['one'], '1')
995 self.assertEqual(cf['numbers']['two'], '%(one)s * 2')
996 self.assertEqual(cf['numbers']['three'], '${common:one} * 3')
997 self.assertEqual(cf['hexen']['sixteen'], '${numbers:two} * 8')
1000 cf = self.fromstring(self.ini)
1001 self.assertMatchesIni(cf)
1004 cf = self.newconfig()
1005 self.assertIsNone(cf.read_string(""))
1011 cf = CustomConfigParser()
1012 cf.read_string(self.ini)
1013 self.assertMatchesIni(cf)
1021 cf = self.fromstring("[sect]\n"
1024 self.assertEqual(cf.get('sect', "option1"), "foo")
1026 cf.set("sect", "option1", "%foo")
1027 self.assertEqual(cf.get('sect', "option1"), "%foo")
1028 cf.set("sect", "option1", "foo%")
1029 self.assertEqual(cf.get('sect', "option1"), "foo%")
1030 cf.set("sect", "option1", "f%oo")
1031 self.assertEqual(cf.get('sect', "option1"), "f%oo")
1034 cf.set("sect", "option2", "foo%%bar")
1035 self.assertEqual(cf.get("sect", "option2"), "foo%%bar")
1055 cf = self.newconfig()
1058 cf.add_section(s)
1060 cf.set(s, 'lovely_spam{}'.format(j), self.wonderful_spam)
1062 cf.write(f)
1081 cf = self.get_interpolation_config()
1083 eq(cf.get("Foo", "bar"),
1085 eq(cf.get("Foo", "bar9"),
1087 eq(cf.get("Foo", "bar10"),
1089 eq(cf.get("Foo", "bar11"),
1100 cf = self.newconfig()
1101 cf.add_section('non-string')
1102 cf.set('non-string', 'int', 1)
1103 cf.set('non-string', 'list', [0, 1, 1, 2, 3, 5, 8, 13])
1104 cf.set('non-string', 'dict', {'pi': 3.14159})
1105 self.assertEqual(cf.get('non-string', 'int'), 1)
1106 self.assertEqual(cf.get('non-string', 'list'),
1108 self.assertEqual(cf.get('non-string', 'dict'), {'pi': 3.14159})
1109 cf.add_section(123)
1110 cf.set(123, 'this is sick', True)
1111 self.assertEqual(cf.get(123, 'this is sick'), True)
1112 if cf._dict is configparser._default_dict:
1115 cf.optionxform = lambda x: x
1116 cf.set('non-string', 1, 1)
1117 self.assertEqual(cf.get('non-string', 1), 1)
1125 cf = self.newconfig(defaults={"A": 5.2})
1126 self.assertAlmostEqual(cf[self.default_section]['a'], 5.2)
1144 cf = self.newconfig()
1145 parsed_files = cf.read([smbconf, "nonexistent-file"], encoding='utf-8')
1149 self.assertEqual(cf.sections(), sections)
1150 self.assertEqual(cf.get("global", "workgroup"), "MDKGROUP")
1151 self.assertEqual(cf.getint("global", "max log size"), 50)
1152 self.assertEqual(cf.get("global", "hosts allow"), "127.")
1153 self.assertEqual(cf.get("tmp", "echo command"), "cat %s; rm %s")
1162 cf = self.newconfig(defaults)
1164 cf.optionxform = optionxform
1165 cf.read_string(string)
1166 return cf
1169 cf = self.fromstring(textwrap.dedent("""
1194 eq(cf['common']['favourite Beatle'], 'Paul')
1195 eq(cf['common']['favourite color'], 'green')
1196 eq(cf['tom']['favourite Beatle'], 'Paul')
1197 eq(cf['tom']['favourite color'], 'green')
1198 eq(cf['tom']['favourite band'], 'green day')
1199 eq(cf['tom']['favourite pope'], 'John Paul II')
1200 eq(cf['tom']['sequel'], 'John Paul III')
1201 eq(cf['ambv']['favourite Beatle'], 'George')
1202 eq(cf['ambv']['favourite color'], 'green')
1203 eq(cf['ambv']['son of Edward VII'], 'George V')
1204 eq(cf['ambv']['son of George V'], 'George VI')
1205 cf['stanley']['favourite Beatle'], 'George')
1206 eq(cf['stanley']['favourite color'], 'black')
1207 eq(cf['stanley']['favourite state of mind'], 'paranoid')
1208 eq(cf['stanley']['favourite movie'], 'soylent green')
1209 eq(cf['stanley']['favourite pope'], 'John Paul II')
1210 eq(cf['stanley']['favourite song'],
1214 cf = self.fromstring(textwrap.dedent("""
1226 cf['one for you']['ping']
1228 cf['selfish']['me']
1231 cf = self.fromstring("""
1242 self.assertEqual(cf['dollars']['$var'], '$value')
1243 self.assertEqual(cf['interpolated']['$other'], '$value')
1244 self.assertEqual(cf['dollars']['${sick}'], 'cannot interpolate me')
1247 cf['interpolated']['$trying']
1266 cf = self.fromstring(ini)
1268 eq(cf['common']['optionlower'], 'value')
1269 eq(cf['common']['OptionUpper'], 'Value')
1270 eq(cf['Common']['optionlower'], 'a better value')
1271 eq(cf['Common']['OptionUpper'], 'A Better Value')
1272 eq(cf['random']['foolower'], 'value redefined')
1273 eq(cf['random']['FooUpper'], 'A Better Value Redefined')
1290 cf = self.fromstring(ini)
1293 cf = self.fromstring(ini, optionxform=lambda opt: opt)
1295 eq(cf['common']['option'], 'value')
1296 eq(cf['common']['Option'], 'Value')
1297 eq(cf['Common']['option'], 'a better value')
1298 eq(cf['Common']['Option'], 'A Better Value')
1299 eq(cf['random']['foo'], 'value redefined')
1300 eq(cf['random']['Foo'], 'A Better Value Redefined')
1303 cf = self.fromstring("""
1313 cf['interpolation fail']['case1']
1315 cf['interpolation fail']['case2']
1317 cf['interpolation fail']['case3']
1319 cf['interpolation fail']['case4']
1321 cf['interpolation fail']['case5']
1323 cf['interpolation fail']['case6'] = "BLACK $ABBATH"
1338 cf = self.newconfig()
1339 self.assertEqual(len(cf.read(tricky, encoding='utf-8')), 1)
1340 self.assertEqual(cf.sections(), ['strange',
1348 self.assertEqual(cf.getint(self.default_section, 'go',
1352 cf.getint(self.default_section, 'go', raw=True,
1354 self.assertEqual(len(cf.get('strange', 'other').split('\n')), 4)
1355 self.assertEqual(len(cf.get('corruption', 'value').split('\n')), 10)
1357 self.assertFalse(cf.getboolean(longname, 'are they subsections'))
1358 self.assertEqual(cf.get(longname, 'lets use some Unicode'), '???')
1359 self.assertEqual(len(cf.items('another one!')), 5) # 4 in section and
1362 cf.items('no values here')
1363 self.assertEqual(cf.get('tricky interpolation', 'lets'), 'do this')
1364 self.assertEqual(cf.get('tricky interpolation', 'lets'),
1365 cf.get('tricky interpolation', 'go'))
1366 self.assertEqual(cf.get('more interpolation', 'lets'), 'go shopping')
1370 cf = self.newconfig()
1372 cf.read(tricky, encoding='ascii')
1408 cf = self.fromstring("[b]\n"
1416 cf.write(output)
1442 cf = self.fromstring(config_string)
1443 self.assertEqual(cf.get('Commented Bar', 'foo'),
1445 self.assertEqual(cf.get('Commented Bar', 'baz'), 'qwe')
1446 self.assertEqual(cf.get('Commented Bar', 'quirk'),
1453 cf = self.newconfig(defaults)
1454 cf.read_string(string)
1456 cf_copy.read_dict(cf)
1462 for default, value in cf[self.default_section].items():