diff options
| author | Ned Batchelder <ned@nedbatchelder.com> | 2010-03-20 23:22:15 -0400 |
|---|---|---|
| committer | Ned Batchelder <ned@nedbatchelder.com> | 2010-03-20 23:22:15 -0400 |
| commit | 88f696023c9faa5105e30dc76596a2c141127a94 (patch) | |
| tree | 6109a16c0205b50bf13306ea50e77a15d88645e4 /test/coveragetest.py | |
| parent | 1a67a1f8e08acaf6b28903ae812a7af8b40d846e (diff) | |
| download | python-coveragepy-88f696023c9faa5105e30dc76596a2c141127a94.tar.gz | |
make_files is more useful if it can do subdirectories too.
Diffstat (limited to 'test/coveragetest.py')
| -rw-r--r-- | test/coveragetest.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/test/coveragetest.py b/test/coveragetest.py index 8e15e49..981beee 100644 --- a/test/coveragetest.py +++ b/test/coveragetest.py @@ -116,13 +116,19 @@ class CoverageTest(TestCase): def make_file(self, filename, text): """Create a temp file. - `filename` is the file name, and `text` is the content. + `filename` is the path to the file, including directories if desired, + and `text` is the content. """ # Tests that call `make_file` should be run in a temp environment. assert self.run_in_temp_dir text = textwrap.dedent(text) + # Make sure the directories are available. + dirs, _ = os.path.split(filename) + if dirs and not os.path.exists(dirs): + os.makedirs(dirs) + # Create the file. f = open(filename, 'w') f.write(text) |
