From 9478bad09b8e3cf8f58a5324ee1f3e116f6d5214 Mon Sep 17 00:00:00 2001 From: Guido Günther Date: Fri, 23 Nov 2012 18:24:32 +0100 Subject: testutils: create missing directories when adding a file --- tests/testutils.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/testutils.py b/tests/testutils.py index 74b1067..af243d5 100644 --- a/tests/testutils.py +++ b/tests/testutils.py @@ -7,7 +7,6 @@ import unittest import gbp.log import gbp.deb.git import gbp.errors -import gbp.scripts.buildpackage as buildpackage class DebianGitTestRepo(unittest.TestCase): """Scratch repo for a single test""" @@ -35,6 +34,11 @@ class DebianGitTestRepo(unittest.TestCase): @type content: C{str} """ path = os.path.join(self.repo.path, name) + + d = os.path.dirname(path) + if not os.path.exists(d): + os.makedirs(d) + with file(path, 'w+') as f: content == None or f.write(content) self.repo.add_files(name, force=True) -- cgit v1.2.3