L{replaceInFile} replaces data in a file based on a dict. A key from the dict that is found in the file is replaced with the corresponding value.
(self)
| 285 | self.assertEqual(cwd, os.getcwd()) |
| 286 | |
| 287 | def test_replaceInFile(self): |
| 288 | """ |
| 289 | L{replaceInFile} replaces data in a file based on a dict. A key from |
| 290 | the dict that is found in the file is replaced with the corresponding |
| 291 | value. |
| 292 | """ |
| 293 | content = "foo\nhey hey $VER\nbar\n" |
| 294 | with open("release.replace", "w") as outf: |
| 295 | outf.write(content) |
| 296 | |
| 297 | expected = content.replace("$VER", "2.0.0") |
| 298 | replaceInFile("release.replace", {"$VER": "2.0.0"}) |
| 299 | with open("release.replace") as f: |
| 300 | self.assertEqual(f.read(), expected) |
| 301 | |
| 302 | expected = expected.replace("2.0.0", "3.0.0") |
| 303 | replaceInFile("release.replace", {"2.0.0": "3.0.0"}) |
| 304 | with open("release.replace") as f: |
| 305 | self.assertEqual(f.read(), expected) |
| 306 | |
| 307 | |
| 308 | class FilePathDeltaTests(TestCase): |
nothing calls this directly
no test coverage detected