diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2011-01-30 08:31:41 -0500 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2011-01-30 08:31:41 -0500 |
commit | 453c1487076ca12bca8d08d6fc6e8d996eb7745b (patch) | |
tree | d96e2dc8a103ac8365b117681343edf7371538ff /test/coveragetest.py | |
parent | 8603a594d0f08dc469abb0ae8090b4b7b5ed39e7 (diff) | |
download | python-coveragepy-git-453c1487076ca12bca8d08d6fc6e8d996eb7745b.tar.gz |
A test for parsing files with different line endings.
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) |