(self)
| 71 | ) |
| 72 | |
| 73 | def testDumpWholeConfig(self): |
| 74 | text = """\ |
| 75 | |
| 76 | # a |
| 77 | a = b |
| 78 | |
| 79 | <a block> |
| 80 | a = b |
| 81 | </a> |
| 82 | a b |
| 83 | <a a block> |
| 84 | c "d d" |
| 85 | b = 三 |
| 86 | </a> |
| 87 | # a |
| 88 | """ |
| 89 | |
| 90 | expect_text = """\ |
| 91 | a b |
| 92 | <a> |
| 93 | <block> |
| 94 | a b |
| 95 | </block> |
| 96 | </a> |
| 97 | a b |
| 98 | <a> |
| 99 | <a block> |
| 100 | c "d d" |
| 101 | b 三 |
| 102 | </a block> |
| 103 | </a> |
| 104 | """ |
| 105 | |
| 106 | ApacheConfigLexer = make_lexer() |
| 107 | ApacheConfigParser = make_parser() |
| 108 | |
| 109 | loader = ApacheConfigLoader( |
| 110 | ApacheConfigParser(ApacheConfigLexer())) |
| 111 | |
| 112 | config = loader.loads(text) |
| 113 | gen_text = loader.dumps(config) |
| 114 | |
| 115 | try: |
| 116 | self.assertEqual(expect_text, gen_text) |
| 117 | except AssertionError: |
| 118 | # Account for non-deterministic ordering of dict items; |
| 119 | # swap lines `b 三` and `c "d d"` |
| 120 | lines = expect_text.split('\n') |
| 121 | lines[9], lines[10] = lines[10], lines[9] |
| 122 | expect_text = "\n".join(lines) |
| 123 | self.assertEqual(expect_text, gen_text) |
| 124 | |
| 125 | # Testing dump(filepath, config) |
| 126 | tmpd = tempfile.mkdtemp() |
| 127 | filepath = os.path.join(tmpd, "config") |
| 128 | loader.dump(filepath, config) |
| 129 | with io.open(filepath, mode='r', encoding='utf-8') as f: |
| 130 | text = f.read() |
nothing calls this directly
no test coverage detected