(self)
| 435 | }) |
| 436 | |
| 437 | def test_case_sensitivity(self): |
| 438 | cf = self.newconfig() |
| 439 | cf.add_section("A") |
| 440 | cf.add_section("a") |
| 441 | cf.add_section("B") |
| 442 | L = cf.sections() |
| 443 | L.sort() |
| 444 | eq = self.assertEqual |
| 445 | eq(L, ["A", "B", "a"]) |
| 446 | cf.set("a", "B", "value") |
| 447 | eq(cf.options("a"), ["b"]) |
| 448 | eq(cf.get("a", "b"), "value", |
| 449 | "could not locate option, expecting case-insensitive option names") |
| 450 | with self.assertRaises(configparser.NoSectionError): |
| 451 | # section names are case-sensitive |
| 452 | cf.set("b", "A", "value") |
| 453 | self.assertTrue(cf.has_option("a", "b")) |
| 454 | self.assertFalse(cf.has_option("b", "b")) |
| 455 | cf.set("A", "A-B", "A-B value") |
| 456 | for opt in ("a-b", "A-b", "a-B", "A-B"): |
| 457 | self.assertTrue( |
| 458 | cf.has_option("A", opt), |
| 459 | "has_option() returned false for option which should exist") |
| 460 | eq(cf.options("A"), ["a-b"]) |
| 461 | eq(cf.options("a"), ["b"]) |
| 462 | cf.remove_option("a", "B") |
| 463 | eq(cf.options("a"), []) |
| 464 | |
| 465 | # SF bug #432369: |
| 466 | cf = self.fromstring( |
| 467 | "[MySection]\nOption{} first line \n\tsecond line \n".format( |
| 468 | self.delimiters[0])) |
| 469 | eq(cf.options("MySection"), ["option"]) |
| 470 | eq(cf.get("MySection", "Option"), "first line\nsecond line") |
| 471 | |
| 472 | # SF bug #561822: |
| 473 | cf = self.fromstring("[section]\n" |
| 474 | "nekey{}nevalue\n".format(self.delimiters[0]), |
| 475 | defaults={"key":"value"}) |
| 476 | self.assertTrue(cf.has_option("section", "Key")) |
| 477 | |
| 478 | |
| 479 | def test_case_sensitivity_mapping_access(self): |
nothing calls this directly
no test coverage detected