summaryrefslogtreecommitdiff
path: root/test/coveragetest.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2010-03-20 23:22:15 -0400
committerNed Batchelder <ned@nedbatchelder.com>2010-03-20 23:22:15 -0400
commit88f696023c9faa5105e30dc76596a2c141127a94 (patch)
tree6109a16c0205b50bf13306ea50e77a15d88645e4 /test/coveragetest.py
parent1a67a1f8e08acaf6b28903ae812a7af8b40d846e (diff)
downloadpython-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.py8
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)