Lines Matching refs:cf
65 cf = self.newconfig(defaults)
66 cf.read_string(string)
67 return cf
72 def basic_test(self, cf): argument
91 L = cf.sections()
95 L = cf.items('Spacey Bar From The Beginning')
100 L = [section for section in cf]
105 L = cf['Spacey Bar From The Beginning'].items()
108 L = cf.items()
113 eq(cf.defaults(), cf[self.default_section])
120 eq(cf.get('Foo Bar', 'foo'), 'bar1')
121 eq(cf.get('Spacey Bar', 'foo'), 'bar2')
122 eq(cf.get('Spacey Bar From The Beginning', 'foo'), 'bar3')
123 eq(cf.get('Spacey Bar From The Beginning', 'baz'), 'qwe')
124 eq(cf.get('Commented Bar', 'foo'), 'bar4')
125 eq(cf.get('Commented Bar', 'baz'), 'qwe')
126 eq(cf.get('Spaces', 'key with spaces'), 'value')
127 eq(cf.get('Spaces', 'another with spaces'), 'splat!')
128 eq(cf.getint('Types', 'int'), 42)
129 eq(cf.get('Types', 'int'), "42")
130 self.assertAlmostEqual(cf.getfloat('Types', 'float'), 0.44)
131 eq(cf.get('Types', 'float'), "0.44")
132 eq(cf.getboolean('Types', 'boolean'), False)
133 eq(cf.get('Types', '123'), 'strange but acceptable')
134 eq(cf.get('This One Has A ] In It', 'forks'), 'spoons')
136 eq(cf.get('NoValue', 'option-without-value'), None)
139 eq(cf.get('Foo Bar', 'foo', fallback='baz'), 'bar1')
140 eq(cf.get('Foo Bar', 'foo', vars={'foo': 'baz'}), 'baz')
142 cf.get('No Such Foo Bar', 'foo')
144 cf.get('Foo Bar', 'no-such-foo')
145 eq(cf.get('No Such Foo Bar', 'foo', fallback='baz'), 'baz')
146 eq(cf.get('Foo Bar', 'no-such-foo', fallback='baz'), 'baz')
147 eq(cf.get('Spacey Bar', 'foo', fallback=None), 'bar2')
148 eq(cf.get('No Such Spacey Bar', 'foo', fallback=None), None)
149 eq(cf.getint('Types', 'int', fallback=18), 42)
150 eq(cf.getint('Types', 'no-such-int', fallback=18), 18)
151 eq(cf.getint('Types', 'no-such-int', fallback="18"), "18") # sic!
153 cf.getint('Types', 'no-such-int')
154 self.assertAlmostEqual(cf.getfloat('Types', 'float',
156 self.assertAlmostEqual(cf.getfloat('Types', 'no-such-float',
158 eq(cf.getfloat('Types', 'no-such-float', fallback="0.0"), "0.0") # sic!
160 cf.getfloat('Types', 'no-such-float')
161 eq(cf.getboolean('Types', 'boolean', fallback=True), False)
162 eq(cf.getboolean('Types', 'no-such-boolean', fallback="yes"),
164 eq(cf.getboolean('Types', 'no-such-boolean', fallback=True), True)
166 cf.getboolean('Types', 'no-such-boolean')
167 eq(cf.getboolean('No Such Types', 'boolean', fallback=True), True)
169 eq(cf.get('NoValue', 'option-without-value', fallback=False), None)
170 eq(cf.get('NoValue', 'no-such-option-without-value',
174 eq(cf['Foo Bar']['foo'], 'bar1')
175 eq(cf['Spacey Bar']['foo'], 'bar2')
176 section = cf['Spacey Bar From The Beginning']
178 self.assertIs(section.parser, cf)
185 eq(cf['Commented Bar']['foo'], 'bar4')
186 eq(cf['Commented Bar']['baz'], 'qwe')
187 eq(cf['Spaces']['key with spaces'], 'value')
188 eq(cf['Spaces']['another with spaces'], 'splat!')
189 eq(cf['Long Line']['foo'],
192 eq(cf['NoValue']['option-without-value'], None)
194 eq(cf['Foo Bar'].get('foo', 'baz'), 'bar1')
195 eq(cf['Foo Bar'].get('foo', fallback='baz'), 'bar1')
196 eq(cf['Foo Bar'].get('foo', vars={'foo': 'baz'}), 'baz')
198 cf['No Such Foo Bar']['foo']
200 cf['Foo Bar']['no-such-foo']
202 cf['No Such Foo Bar'].get('foo', fallback='baz')
203 eq(cf['Foo Bar'].get('no-such-foo', 'baz'), 'baz')
204 eq(cf['Foo Bar'].get('no-such-foo', fallback='baz'), 'baz')
205 eq(cf['Foo Bar'].get('no-such-foo'), None)
206 eq(cf['Spacey Bar'].get('foo', None), 'bar2')
207 eq(cf['Spacey Bar'].get('foo', fallback=None), 'bar2')
209 cf['No Such Spacey Bar'].get('foo', None)
210 eq(cf['Types'].getint('int', 18), 42)
211 eq(cf['Types'].getint('int', fallback=18), 42)
212 eq(cf['Types'].getint('no-such-int', 18), 18)
213 eq(cf['Types'].getint('no-such-int', fallback=18), 18)
214 eq(cf['Types'].getint('no-such-int', "18"), "18") # sic!
215 eq(cf['Types'].getint('no-such-int', fallback="18"), "18") # sic!
216 eq(cf['Types'].getint('no-such-int'), None)
217 self.assertAlmostEqual(cf['Types'].getfloat('float', 0.0), 0.44)
218 self.assertAlmostEqual(cf['Types'].getfloat('float',
220 self.assertAlmostEqual(cf['Types'].getfloat('no-such-float', 0.0), 0.0)
221 self.assertAlmostEqual(cf['Types'].getfloat('no-such-float',
223 eq(cf['Types'].getfloat('no-such-float', "0.0"), "0.0") # sic!
224 eq(cf['Types'].getfloat('no-such-float', fallback="0.0"), "0.0") # sic!
225 eq(cf['Types'].getfloat('no-such-float'), None)
226 eq(cf['Types'].getboolean('boolean', True), False)
227 eq(cf['Types'].getboolean('boolean', fallback=True), False)
228 eq(cf['Types'].getboolean('no-such-boolean', "yes"), "yes") # sic!
229 eq(cf['Types'].getboolean('no-such-boolean', fallback="yes"),
231 eq(cf['Types'].getboolean('no-such-boolean', True), True)
232 eq(cf['Types'].getboolean('no-such-boolean', fallback=True), True)
233 eq(cf['Types'].getboolean('no-such-boolean'), None)
235 eq(cf['NoValue'].get('option-without-value', False), None)
236 eq(cf['NoValue'].get('option-without-value', fallback=False), None)
237 eq(cf['NoValue'].get('no-such-option-without-value', False), False)
238 eq(cf['NoValue'].get('no-such-option-without-value',
244 cf[self.default_section]['this_value'] = '1'
245 cf[self.default_section]['that_value'] = '2'
248 self.assertTrue(cf.remove_section('Spaces'))
249 self.assertFalse(cf.has_option('Spaces', 'key with spaces'))
250 self.assertFalse(cf.remove_section('Spaces'))
251 self.assertFalse(cf.remove_section(self.default_section))
252 self.assertTrue(cf.remove_option('Foo Bar', 'foo'),
254 self.assertFalse(cf.has_option('Foo Bar', 'foo'),
256 self.assertFalse(cf.remove_option('Foo Bar', 'foo'),
259 self.assertTrue(cf.has_option('Foo Bar', 'this_value'))
260 self.assertFalse(cf.remove_option('Foo Bar', 'this_value'))
261 self.assertTrue(cf.remove_option(self.default_section, 'this_value'))
262 self.assertFalse(cf.has_option('Foo Bar', 'this_value'))
263 self.assertFalse(cf.remove_option(self.default_section, 'this_value'))
266 cf.remove_option('No Such Section', 'foo')
269 eq(cf.get('Long Line', 'foo'),
273 del cf['Types']
274 self.assertFalse('Types' in cf)
276 del cf['Types']
278 del cf[self.default_section]
279 del cf['Spacey Bar']['foo']
280 self.assertFalse('foo' in cf['Spacey Bar'])
282 del cf['Spacey Bar']['foo']
283 self.assertTrue('that_value' in cf['Spacey Bar'])
285 del cf['Spacey Bar']['that_value']
286 del cf[self.default_section]['that_value']
287 self.assertFalse('that_value' in cf['Spacey Bar'])
289 del cf[self.default_section]['that_value']
291 del cf['No Such Section']['foo']
333 cf = self.fromstring(config_string)
334 self.basic_test(cf)
337 cf.read_string(textwrap.dedent("""\
343 cf.read_string(textwrap.dedent("""\
350 cf.read_string(textwrap.dedent("""\
356 cf.read_string(textwrap.dedent("""\
411 cf = self.newconfig()
412 cf.read_dict(config)
413 self.basic_test(cf)
416 cf.read_dict({
421 cf.read_dict({
428 cf.read_dict({
432 cf.read_dict({
440 cf = self.newconfig()
441 cf.add_section("A")
442 cf.add_section("a")
443 cf.add_section("B")
444 L = cf.sections()
448 cf.set("a", "B", "value")
449 eq(cf.options("a"), ["b"])
450 eq(cf.get("a", "b"), "value",
454 cf.set("b", "A", "value")
455 self.assertTrue(cf.has_option("a", "b"))
456 self.assertFalse(cf.has_option("b", "b"))
457 cf.set("A", "A-B", "A-B value")
460 cf.has_option("A", opt),
462 eq(cf.options("A"), ["a-b"])
463 eq(cf.options("a"), ["b"])
464 cf.remove_option("a", "B")
465 eq(cf.options("a"), [])
468 cf = self.fromstring(
471 eq(cf.options("MySection"), ["option"])
472 eq(cf.get("MySection", "Option"), "first line\nsecond line")
475 cf = self.fromstring("[section]\n"
478 self.assertTrue(cf.has_option("section", "Key"))
482 cf = self.newconfig()
483 cf["A"] = {}
484 cf["a"] = {"B": "value"}
485 cf["B"] = {}
486 L = [section for section in cf]
491 eq(cf["a"].keys(), {"b"})
492 eq(cf["a"]["b"], "value",
496 cf["b"]["A"] = "value"
497 self.assertTrue("b" in cf["a"])
498 cf["A"]["A-B"] = "A-B value"
501 opt in cf["A"],
503 eq(cf["A"].keys(), {"a-b"})
504 eq(cf["a"].keys(), {"b"})
505 del cf["a"]["B"]
506 elem_eq(cf["a"].keys(), {})
509 cf = self.fromstring(
512 eq(cf["MySection"].keys(), {"option"})
513 eq(cf["MySection"]["Option"], "first line\nsecond line")
516 cf = self.fromstring("[section]\n"
519 self.assertTrue("Key" in cf["section"])
522 cf = self.newconfig({"foo": "Bar"})
524 cf.get(self.default_section, "Foo"), "Bar",
526 cf = self.newconfig({"Foo": "Bar"})
528 cf.get(self.default_section, "Foo"), "Bar",
532 cf = self.newconfig()
533 self.parse_error(cf, configparser.ParsingError,
536 self.parse_error(cf, configparser.ParsingError,
539 e = self.parse_error(cf, configparser.MissingSectionHeaderError,
543 e = self.parse_error(cf, configparser.ParsingError,
556 e = self.parse_error(cf, error, f)
559 def parse_error(self, cf, exc, src): argument
565 cf.read_file(sio)
569 cf = self.newconfig()
570 self.assertEqual(cf.sections(), [],
572 self.assertFalse(cf.has_section("Foo"),
576 cf.options("Foo")
578 cf.set("foo", "bar", "value")
579 e = self.get_error(cf, configparser.NoSectionError, "foo", "bar")
581 cf.add_section("foo")
582 e = self.get_error(cf, configparser.NoOptionError, "foo", "bar")
585 def get_error(self, cf, exc, section, option): argument
587 cf.get(section, option)
595 cf = self.fromstring(
614 self.assertTrue(cf.getboolean('BOOLTEST', 't%d' % x))
615 self.assertFalse(cf.getboolean('BOOLTEST', 'f%d' % x))
617 cf.getboolean, 'BOOLTEST', 'e%d' % x)
620 cf = self.newconfig()
621 cf.add_section("Foo")
623 cf.add_section("Foo")
630 cf.read_string(textwrap.dedent("""\
644 cf.read_dict({'Bar': {'opt': 'val', 'OPT': 'is really `opt`'}})
672 cf = self.fromstring(config_string)
675 cf.write(output, space_around_delimiters=space_around_delimiters)
705 cf = self.fromstring("[sect]\n"
711 cf.set("sect", "option1", "splat")
712 cf.set("sect", "option1", mystr("splat"))
713 cf.set("sect", "option2", "splat")
714 cf.set("sect", "option2", mystr("splat"))
715 cf.set("sect", "option1", "splat")
716 cf.set("sect", "option2", "splat")
723 cf = self.newconfig()
724 parsed_files = cf.read([file1, "nonexistent-file"], encoding="utf-8")
726 self.assertEqual(cf.get("Foo Bar", "foo"), "newbar")
728 cf = self.newconfig()
729 parsed_files = cf.read(file1, encoding="utf-8")
731 self.assertEqual(cf.get("Foo Bar", "foo"), "newbar")
733 cf = self.newconfig()
734 parsed_files = cf.read(pathlib.Path(file1), encoding="utf-8")
736 self.assertEqual(cf.get("Foo Bar", "foo"), "newbar")
738 cf = self.newconfig()
739 parsed_files = cf.read([pathlib.Path(file1), file1], encoding="utf-8")
741 self.assertEqual(cf.get("Foo Bar", "foo"), "newbar")
743 cf = self.newconfig()
744 parsed_files = cf.read(["nonexistent-file"], encoding="utf-8")
747 cf = self.newconfig()
748 parsed_files = cf.read([], encoding="utf-8")
756 cf = self.newconfig()
757 parsed_files = cf.read(file1_bytestring, encoding="utf-8")
760 cf = self.newconfig()
761 parsed_files = cf.read(b'nonexistent-file', encoding="utf-8")
764 cf = self.newconfig()
765 parsed_files = cf.read([file1_bytestring, b'nonexistent-file'], encoding="utf-8")
797 cf = self.fromstring("""
803 L = list(cf.items("section", vars={'value': 'value'}))
807 cf.items("no such section")
810 cf = self.fromstring("""
818 self.assertEqual(cf.popitem()[0], 'section1')
819 self.assertEqual(cf.popitem()[0], 'section2')
820 self.assertEqual(cf.popitem()[0], 'section3')
822 cf.popitem()
825 cf = self.newconfig({"foo": "Bar"})
827 cf.get(self.default_section, "Foo"), "Bar",
829 cf['zing'] = {'option1': 'value1', 'option2': 'value2'}
830 self.assertEqual(cf.sections(), ['zing'])
831 self.assertEqual(set(cf['zing'].keys()), {'option1', 'option2', 'foo'})
832 cf.clear()
833 self.assertEqual(set(cf.sections()), set())
834 self.assertEqual(set(cf[self.default_section].keys()), {'foo'})
837 cf = self.fromstring("""
845 self.assertEqual(set(cf['section1'].keys()), {'name1', 'named'})
846 self.assertEqual(set(cf['section2'].keys()), {'name2', 'named'})
847 self.assertEqual(set(cf['section3'].keys()), {'name3', 'named'})
848 self.assertEqual(cf['section1']['name1'], 'value1')
849 self.assertEqual(cf['section2']['name2'], 'value2')
850 self.assertEqual(cf['section3']['name3'], 'value3')
851 self.assertEqual(cf.sections(), ['section1', 'section2', 'section3'])
852 cf['section2'] = {'name22': 'value22'}
853 self.assertEqual(set(cf['section2'].keys()), {'name22', 'named'})
854 self.assertEqual(cf['section2']['name22'], 'value22')
855 self.assertNotIn('name2', cf['section2'])
856 self.assertEqual(cf.sections(), ['section1', 'section2', 'section3'])
857 cf['section3'] = {}
858 self.assertEqual(set(cf['section3'].keys()), {'named'})
859 self.assertNotIn('name3', cf['section3'])
860 self.assertEqual(cf.sections(), ['section1', 'section2', 'section3'])
862 cf[self.default_section] = cf[self.default_section]
863 self.assertNotEqual(set(cf[self.default_section].keys()), set())
864 cf[self.default_section] = {}
865 self.assertEqual(set(cf[self.default_section].keys()), set())
866 self.assertEqual(set(cf['section1'].keys()), {'name1'})
867 self.assertEqual(set(cf['section2'].keys()), {'name22'})
868 self.assertEqual(set(cf['section3'].keys()), set())
869 self.assertEqual(cf.sections(), ['section1', 'section2', 'section3'])
871 cf['section2'] = cf['section2']
872 self.assertEqual(set(cf['section2'].keys()), {'name22'})
883 cf = self.newconfig()
885 cf.read_string(invalid)
886 self.assertEqual(cf.get('DEFAULT', 'test'), 'test')
887 self.assertEqual(cf['DEFAULT']['test'], 'test')
899 cf = self.get_interpolation_config()
901 eq(cf.get("Foo", "bar"), "something with interpolation (1 step)")
902 eq(cf.get("Foo", "bar9"),
904 eq(cf.get("Foo", "bar10"),
906 e = self.get_error(cf, configparser.InterpolationDepthError, "Foo", "bar11")
915 cf = self.get_interpolation_config()
916 e = self.get_error(cf, configparser.InterpolationMissingOptionError,
936 cf = self.fromstring("[section]\n"
942 self.assertEqual(cf.get("section", "ok"), "xxx/%s")
944 self.assertEqual(cf.get("section", "not_ok"), "xxx/xxx/%s")
947 cf.get("section", "not_ok")
950 cf = self.fromstring("[sect]\n"
953 self.assertEqual(cf.get('sect', "option1"), "foo")
955 self.assertRaises(ValueError, cf.set, "sect", "option1", "%foo")
956 self.assertRaises(ValueError, cf.set, "sect", "option1", "foo%")
957 self.assertRaises(ValueError, cf.set, "sect", "option1", "f%oo")
959 self.assertEqual(cf.get('sect', "option1"), "foo")
962 cf.set("sect", "option2", "foo%%bar")
963 self.assertEqual(cf.get("sect", "option2"), "foo%bar")
966 cf = self.fromstring("[sect]\n"
970 self.assertRaises(TypeError, cf.set, "sect", "option1", 1)
971 self.assertRaises(TypeError, cf.set, "sect", "option1", 1.0)
972 self.assertRaises(TypeError, cf.set, "sect", "option1", object())
973 self.assertRaises(TypeError, cf.set, "sect", "option2", 1)
974 self.assertRaises(TypeError, cf.set, "sect", "option2", 1.0)
975 self.assertRaises(TypeError, cf.set, "sect", "option2", object())
976 self.assertRaises(TypeError, cf.set, "sect", 123, "invalid opt name!")
977 self.assertRaises(TypeError, cf.add_section, 123)
980 cf = self.newconfig()
981 self.assertRaises(ValueError, cf.add_section, self.default_section)
985 cf = self.newconfig(defaults={1: 2.4})
986 self.assertEqual(cf[self.default_section]['1'], '2.4')
987 self.assertAlmostEqual(cf[self.default_section].getfloat('1'), 2.4)
988 cf = self.newconfig(defaults={"A": 5.2})
989 self.assertEqual(cf[self.default_section]['a'], '5.2')
990 self.assertAlmostEqual(cf[self.default_section].getfloat('a'), 5.2)
1006 def assertMatchesIni(self, cf): argument
1007 self.assertEqual(cf['numbers']['one'], '1')
1008 self.assertEqual(cf['numbers']['two'], '%(one)s * 2')
1009 self.assertEqual(cf['numbers']['three'], '${common:one} * 3')
1010 self.assertEqual(cf['hexen']['sixteen'], '${numbers:two} * 8')
1013 cf = self.fromstring(self.ini)
1014 self.assertMatchesIni(cf)
1017 cf = self.newconfig()
1018 self.assertIsNone(cf.read_string(""))
1024 cf = CustomConfigParser()
1025 cf.read_string(self.ini)
1026 self.assertMatchesIni(cf)
1034 cf = self.fromstring("[sect]\n"
1037 self.assertEqual(cf.get('sect', "option1"), "foo")
1039 cf.set("sect", "option1", "%foo")
1040 self.assertEqual(cf.get('sect', "option1"), "%foo")
1041 cf.set("sect", "option1", "foo%")
1042 self.assertEqual(cf.get('sect', "option1"), "foo%")
1043 cf.set("sect", "option1", "f%oo")
1044 self.assertEqual(cf.get('sect', "option1"), "f%oo")
1047 cf.set("sect", "option2", "foo%%bar")
1048 self.assertEqual(cf.get("sect", "option2"), "foo%%bar")
1068 cf = self.newconfig()
1071 cf.add_section(s)
1073 cf.set(s, 'lovely_spam{}'.format(j), self.wonderful_spam)
1075 cf.write(f)
1094 cf = self.get_interpolation_config()
1096 eq(cf.get("Foo", "bar"),
1098 eq(cf.get("Foo", "bar9"),
1100 eq(cf.get("Foo", "bar10"),
1102 eq(cf.get("Foo", "bar11"),
1112 cf = self.newconfig()
1113 cf.add_section('non-string')
1114 cf.set('non-string', 'int', 1)
1115 cf.set('non-string', 'list', [0, 1, 1, 2, 3, 5, 8, 13])
1116 cf.set('non-string', 'dict', {'pi': 3.14159})
1117 self.assertEqual(cf.get('non-string', 'int'), 1)
1118 self.assertEqual(cf.get('non-string', 'list'),
1120 self.assertEqual(cf.get('non-string', 'dict'), {'pi': 3.14159})
1121 cf.add_section(123)
1122 cf.set(123, 'this is sick', True)
1123 self.assertEqual(cf.get(123, 'this is sick'), True)
1124 if cf._dict is configparser._default_dict:
1127 cf.optionxform = lambda x: x
1128 cf.set('non-string', 1, 1)
1129 self.assertEqual(cf.get('non-string', 1), 1)
1137 cf = self.newconfig(defaults={"A": 5.2})
1138 self.assertAlmostEqual(cf[self.default_section]['a'], 5.2)
1156 cf = self.newconfig()
1157 parsed_files = cf.read([smbconf, "nonexistent-file"], encoding='utf-8')
1161 self.assertEqual(cf.sections(), sections)
1162 self.assertEqual(cf.get("global", "workgroup"), "MDKGROUP")
1163 self.assertEqual(cf.getint("global", "max log size"), 50)
1164 self.assertEqual(cf.get("global", "hosts allow"), "127.")
1165 self.assertEqual(cf.get("tmp", "echo command"), "cat %s; rm %s")
1174 cf = self.newconfig(defaults)
1176 cf.optionxform = optionxform
1177 cf.read_string(string)
1178 return cf
1181 cf = self.fromstring(textwrap.dedent("""
1206 eq(cf['common']['favourite Beatle'], 'Paul')
1207 eq(cf['common']['favourite color'], 'green')
1208 eq(cf['tom']['favourite Beatle'], 'Paul')
1209 eq(cf['tom']['favourite color'], 'green')
1210 eq(cf['tom']['favourite band'], 'green day')
1211 eq(cf['tom']['favourite pope'], 'John Paul II')
1212 eq(cf['tom']['sequel'], 'John Paul III')
1213 eq(cf['ambv']['favourite Beatle'], 'George')
1214 eq(cf['ambv']['favourite color'], 'green')
1215 eq(cf['ambv']['son of Edward VII'], 'George V')
1216 eq(cf['ambv']['son of George V'], 'George VI')
1217 eq(cf['stanley']['favourite Beatle'], 'George')
1218 eq(cf['stanley']['favourite color'], 'black')
1219 eq(cf['stanley']['favourite state of mind'], 'paranoid')
1220 eq(cf['stanley']['favourite movie'], 'soylent green')
1221 eq(cf['stanley']['favourite pope'], 'John Paul II')
1222 eq(cf['stanley']['favourite song'],
1226 cf = self.fromstring(textwrap.dedent("""
1238 cf['one for you']['ping']
1240 cf['selfish']['me']
1243 cf = self.fromstring("""
1254 self.assertEqual(cf['dollars']['$var'], '$value')
1255 self.assertEqual(cf['interpolated']['$other'], '$value')
1256 self.assertEqual(cf['dollars']['${sick}'], 'cannot interpolate me')
1259 cf['interpolated']['$trying']
1278 cf = self.fromstring(ini)
1280 eq(cf['common']['optionlower'], 'value')
1281 eq(cf['common']['OptionUpper'], 'Value')
1282 eq(cf['Common']['optionlower'], 'a better value')
1283 eq(cf['Common']['OptionUpper'], 'A Better Value')
1284 eq(cf['random']['foolower'], 'value redefined')
1285 eq(cf['random']['FooUpper'], 'A Better Value Redefined')
1302 cf = self.fromstring(ini)
1305 cf = self.fromstring(ini, optionxform=lambda opt: opt)
1307 eq(cf['common']['option'], 'value')
1308 eq(cf['common']['Option'], 'Value')
1309 eq(cf['Common']['option'], 'a better value')
1310 eq(cf['Common']['Option'], 'A Better Value')
1311 eq(cf['random']['foo'], 'value redefined')
1312 eq(cf['random']['Foo'], 'A Better Value Redefined')
1315 cf = self.fromstring("""
1325 cf['interpolation fail']['case1']
1327 cf['interpolation fail']['case2']
1329 cf['interpolation fail']['case3']
1331 cf['interpolation fail']['case4']
1333 cf['interpolation fail']['case5']
1335 cf['interpolation fail']['case6'] = "BLACK $ABBATH"
1350 cf = self.newconfig()
1351 self.assertEqual(len(cf.read(tricky, encoding='utf-8')), 1)
1352 self.assertEqual(cf.sections(), ['strange',
1360 self.assertEqual(cf.getint(self.default_section, 'go',
1364 cf.getint(self.default_section, 'go', raw=True,
1366 self.assertEqual(len(cf.get('strange', 'other').split('\n')), 4)
1367 self.assertEqual(len(cf.get('corruption', 'value').split('\n')), 10)
1369 self.assertFalse(cf.getboolean(longname, 'are they subsections'))
1370 self.assertEqual(cf.get(longname, 'lets use some Unicode'), '片仮名')
1371 self.assertEqual(len(cf.items('another one!')), 5) # 4 in section and
1374 cf.items('no values here')
1375 self.assertEqual(cf.get('tricky interpolation', 'lets'), 'do this')
1376 self.assertEqual(cf.get('tricky interpolation', 'lets'),
1377 cf.get('tricky interpolation', 'go'))
1378 self.assertEqual(cf.get('more interpolation', 'lets'), 'go shopping')
1382 cf = self.newconfig()
1384 cf.read(tricky, encoding='ascii')
1420 cf = self.fromstring("[b]\n"
1428 cf.write(output)
1454 cf = self.fromstring(config_string)
1455 self.assertEqual(cf.get('Commented Bar', 'foo'),
1457 self.assertEqual(cf.get('Commented Bar', 'baz'), 'qwe')
1458 self.assertEqual(cf.get('Commented Bar', 'quirk'),
1465 cf = self.newconfig(defaults)
1466 cf.read_string(string)
1468 cf_copy.read_dict(cf)
1474 for default, value in cf[self.default_section].items():