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
commitcc9534ba3869c671010f91c02e884c4da328b5ea (patch)
tree19fb2870c653b90993d9be61dc88d0f64c45a2f4 /test/coveragetest.py
parent660a122bb75d77c4b1b78439230a76056d86c607 (diff)
downloadpython-coveragepy-git-cc9534ba3869c671010f91c02e884c4da328b5ea.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 8e15e49d..981beeea 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)