testutils: split out DebianGitTestRepo
authorGuido Günther <agx@sigxcpu.org>
Sun, 25 Jan 2015 14:10:12 +0000 (15:10 +0100)
committerGuido Günther <agx@sigxcpu.org>
Sun, 25 Jan 2015 14:14:59 +0000 (15:14 +0100)
Gbp-Dch: Ignore

tests/testutils/__init__.py
tests/testutils/debiangittestrepo.py [new file with mode: 0644]

index 2a13218a9dc52321da6eec8d818c6ee523fcaf49..6df30e2c916eb54aca2908060a1c178d49506428 100644 (file)
@@ -6,47 +6,16 @@ import os
 import shutil
 import subprocess
 import tempfile
-import unittest
 
 import gbp.log
-import gbp.deb.git
 import gbp.errors
 from gbp.deb.changelog import ChangeLog
 
 from gbplogtester import GbpLogTester
+from debiangittestrepo import DebianGitTestRepo
 
-class DebianGitTestRepo(unittest.TestCase):
-    """Scratch repo for a single unit test"""
-
-    def setUp(self):
-        self.tmpdir = context.new_tmpdir(__name__)
-
-        repodir = self.tmpdir.join('test_repo')
-        self.repo = gbp.deb.git.DebianGitRepository.create(repodir)
-
-    def tearDown(self):
-        context.teardown()
-
-    def add_file(self, name, content=None, msg=None):
-        """
-        Add a single file with name I{name} and content I{content}. If
-        I{content} is C{none} the content of the file is undefined.
-
-        @param name: the file's path relativ to the git repo
-        @type name: C{str}
-        @param content: the file's content
-        @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 open(path, 'w+') as f:
-            content == None or f.write(content)
-        self.repo.add_files(name, force=True)
-        self.repo.commit_files(path, msg or "added %s" % name)
+__all__ = ['GbpLogTester, DebianGitTestRepo', 'OsReleaseFile',
+           'MockedChangeLog', 'get_dch_default_urgency' ]
 
 class OsReleaseFile(object):
     """Repesents a simple file with key-value pairs"""
diff --git a/tests/testutils/debiangittestrepo.py b/tests/testutils/debiangittestrepo.py
new file mode 100644 (file)
index 0000000..61456f1
--- /dev/null
@@ -0,0 +1,41 @@
+# vim: set fileencoding=utf-8 :
+
+from .. import context
+
+import os
+import unittest
+
+import gbp.deb.git
+
+class DebianGitTestRepo(unittest.TestCase):
+    """Scratch repo for a single unit test"""
+
+    def setUp(self):
+        self.tmpdir = context.new_tmpdir(__name__)
+
+        repodir = self.tmpdir.join('test_repo')
+        self.repo = gbp.deb.git.DebianGitRepository.create(repodir)
+
+    def tearDown(self):
+        context.teardown()
+
+    def add_file(self, name, content=None, msg=None):
+        """
+        Add a single file with name I{name} and content I{content}. If
+        I{content} is C{none} the content of the file is undefined.
+
+        @param name: the file's path relativ to the git repo
+        @type name: C{str}
+        @param content: the file's content
+        @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 open(path, 'w+') as f:
+            content == None or f.write(content)
+        self.repo.add_files(name, force=True)
+        self.repo.commit_files(path, msg or "added %s" % name)