diff options
Diffstat (limited to 'test/coveragetest.py')
-rw-r--r-- | test/coveragetest.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/test/coveragetest.py b/test/coveragetest.py index 53f0ef0b..1e2c2431 100644 --- a/test/coveragetest.py +++ b/test/coveragetest.py @@ -123,11 +123,12 @@ class CoverageTest(TestCase): """Return the data written to stderr during the test.""" return self.captured_stderr.getvalue() - def make_file(self, filename, text=""): + def make_file(self, filename, text="", newline=None): """Create a temp file. `filename` is the path to the file, including directories if desired, - and `text` is the content. + and `text` is the content. If `newline` is provided, it is a string + that will be used as the line endings in the created file. Returns the path to the file. @@ -135,6 +136,8 @@ class CoverageTest(TestCase): # Tests that call `make_file` should be run in a temp environment. assert self.run_in_temp_dir text = textwrap.dedent(text) + if newline: + text = text.replace("\n", newline) # Make sure the directories are available. dirs, _ = os.path.split(filename) |