| 1530 | |
| 1531 | class ReadFileTestCase(unittest.TestCase): |
| 1532 | def test_file(self): |
| 1533 | file_paths = [support.findfile("cfgparser.1", subdir="configdata")] |
| 1534 | try: |
| 1535 | file_paths.append(file_paths[0].encode('utf8')) |
| 1536 | except UnicodeEncodeError: |
| 1537 | pass # unfortunately we can't test bytes on this path |
| 1538 | for file_path in file_paths: |
| 1539 | parser = configparser.ConfigParser() |
| 1540 | with open(file_path, encoding="utf-8") as f: |
| 1541 | parser.read_file(f) |
| 1542 | self.assertIn("Foo Bar", parser) |
| 1543 | self.assertIn("foo", parser["Foo Bar"]) |
| 1544 | self.assertEqual(parser["Foo Bar"]["foo"], "newbar") |
| 1545 | |
| 1546 | def test_iterable(self): |
| 1547 | lines = textwrap.dedent(""" |