(self)
| 292 | # and sections are now removed. |
| 293 | |
| 294 | def test_basic(self): |
| 295 | config_string = """\ |
| 296 | [Foo Bar] |
| 297 | foo{0[0]}bar1 |
| 298 | [Spacey Bar] |
| 299 | foo {0[0]} bar2 |
| 300 | [Spacey Bar From The Beginning] |
| 301 | foo {0[0]} bar3 |
| 302 | baz {0[0]} qwe |
| 303 | [Commented Bar] |
| 304 | foo{0[1]} bar4 {1[1]} comment |
| 305 | baz{0[0]}qwe {1[0]}another one |
| 306 | [Long Line] |
| 307 | foo{0[1]} this line is much, much longer than my editor |
| 308 | likes it. |
| 309 | [Section\\with$weird%characters[\t] |
| 310 | [Internationalized Stuff] |
| 311 | foo[bg]{0[1]} Bulgarian |
| 312 | foo{0[0]}Default |
| 313 | foo[en]{0[0]}English |
| 314 | foo[de]{0[0]}Deutsch |
| 315 | [Spaces] |
| 316 | key with spaces {0[1]} value |
| 317 | another with spaces {0[0]} splat! |
| 318 | [Types] |
| 319 | int {0[1]} 42 |
| 320 | float {0[0]} 0.44 |
| 321 | boolean {0[0]} NO |
| 322 | 123 {0[1]} strange but acceptable |
| 323 | [This One Has A ] In It] |
| 324 | forks {0[0]} spoons |
| 325 | """.format(self.delimiters, self.comment_prefixes) |
| 326 | if self.allow_no_value: |
| 327 | config_string += ( |
| 328 | "[NoValue]\n" |
| 329 | "option-without-value\n" |
| 330 | ) |
| 331 | cf = self.fromstring(config_string) |
| 332 | self.basic_test(cf) |
| 333 | if self.strict: |
| 334 | with self.assertRaises(configparser.DuplicateOptionError): |
| 335 | cf.read_string(textwrap.dedent("""\ |
| 336 | [Duplicate Options Here] |
| 337 | option {0[0]} with a value |
| 338 | option {0[1]} with another value |
| 339 | """.format(self.delimiters))) |
| 340 | with self.assertRaises(configparser.DuplicateSectionError): |
| 341 | cf.read_string(textwrap.dedent("""\ |
| 342 | [And Now For Something] |
| 343 | completely different {0[0]} True |
| 344 | [And Now For Something] |
| 345 | the larch {0[1]} 1 |
| 346 | """.format(self.delimiters))) |
| 347 | else: |
| 348 | cf.read_string(textwrap.dedent("""\ |
| 349 | [Duplicate Options Here] |
| 350 | option {0[0]} with a value |
| 351 | option {0[1]} with another value |
nothing calls this directly
no test coverage detected