diff options
author | Guido Günther <agx@sigxcpu.org> | 2012-11-23 18:24:32 +0100 |
---|---|---|
committer | Guido Günther <agx@sigxcpu.org> | 2012-11-23 18:24:32 +0100 |
commit | 9478bad09b8e3cf8f58a5324ee1f3e116f6d5214 (patch) | |
tree | 89659049c2aa1f7467179a5d8da6a82bafb85257 | |
parent | 932b1c07a7ff38b6c774e9a5c63a8ac18960d74c (diff) |
testutils: create missing directories when adding a file
-rw-r--r-- | tests/testutils.py | 6 |
1 files changed, 5 insertions, 1 deletions
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) |