From 88f696023c9faa5105e30dc76596a2c141127a94 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Sat, 20 Mar 2010 23:22:15 -0400 Subject: make_files is more useful if it can do subdirectories too. --- test/coveragetest.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'test/coveragetest.py') 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) -- cgit v1.2.1