[Calypso-commits] [calypso] 01/04: tests: move git repo setup to a separate class

Guido Guenther agx at moszumanska.debian.org
Sat Oct 22 21:11:14 UTC 2016


This is an automated email from the git hooks/post-receive script.

agx pushed a commit to branch master
in repository calypso.

commit 0bc082a6bdb5b660959d23b7f33f6a66eef8e4c1
Author: Guido Günther <agx at sigxcpu.org>
Date:   Sat Oct 22 15:05:59 2016 +0200

    tests: move git repo setup to a separate class
    
    and set up author and email to reduce clutter
---
 tests/test_collection.py         | 15 +++------------
 tests/test_matchfilterelement.py | 14 +++-----------
 tests/testutils.py               | 20 ++++++++++++++++++++
 3 files changed, 26 insertions(+), 23 deletions(-)

diff --git a/tests/test_collection.py b/tests/test_collection.py
index baa49d9..f3e3ad1 100644
--- a/tests/test_collection.py
+++ b/tests/test_collection.py
@@ -1,29 +1,20 @@
 # vim: set fileencoding=utf-8 :
-"""Test L{gbp.command_wrappers.Command}'s tarball unpack"""
 
 import subprocess
 import tempfile
 import shutil
 import unittest
 
-import calypso.config
 from calypso.webdav import Collection
 from calypso import paths
 
+from .testutils import CalypsoTestCase
 
-class TestCollection(unittest.TestCase):
+
+class TestCollection(CalypsoTestCase):
     test_vcard = "tests/data/import.vcard"
     test_resource_with_slash = "tests/data/from-tripsync.ics"
 
-    def setUp(self):
-        self.tmpdir = tempfile.mkdtemp()
-        calypso.config.set('storage', 'folder', self.tmpdir)
-        subprocess.call(["git", "init", self.tmpdir]),
-
-    def tearDown(self):
-        if self.tmpdir:
-            shutil.rmtree(self.tmpdir)
-
     def test_import_file(self):
         collection = Collection("")
         self.assertTrue(collection.import_file(self.test_vcard))
diff --git a/tests/test_matchfilterelement.py b/tests/test_matchfilterelement.py
index ca28285..ea070f7 100644
--- a/tests/test_matchfilterelement.py
+++ b/tests/test_matchfilterelement.py
@@ -7,22 +7,14 @@ import shutil
 import unittest
 import xml.etree.ElementTree as ET
 
-import calypso.config
 from calypso.webdav import Collection
 from calypso import xmlutils
 
+from .testutils import CalypsoTestCase
 
-class TestMatchFilterElement(unittest.TestCase):
-    test_vcal = "tests/data/import.vcalendar"
-
-    def setUp(self):
-        self.tmpdir = tempfile.mkdtemp()
-        calypso.config.set('storage', 'folder', self.tmpdir)
-        subprocess.call(["git", "init", self.tmpdir]),
 
-    def tearDown(self):
-        if self.tmpdir:
-            shutil.rmtree(self.tmpdir)
+class TestMatchFilterElement(CalypsoTestCase):
+    test_vcal = "tests/data/import.vcalendar"
 
     def test_start_end(self):
         """
diff --git a/tests/testutils.py b/tests/testutils.py
new file mode 100644
index 0000000..fd9c94d
--- /dev/null
+++ b/tests/testutils.py
@@ -0,0 +1,20 @@
+import shutil
+import subprocess
+import tempfile
+import unittest
+
+import calypso.config
+
+
+class CalypsoTestCase(unittest.TestCase):
+
+    def setUp(self):
+        self.tmpdir = tempfile.mkdtemp()
+        calypso.config.set('storage', 'folder', self.tmpdir)
+        subprocess.call(["git", "init", self.tmpdir])
+        subprocess.call(["git", "config", "user.email", "calypso at example.com"], cwd=self.tmpdir)
+        subprocess.call(["git", "config", "user.name", "cal Ypso"], cwd=self.tmpdir)
+
+    def tearDown(self):
+        if self.tmpdir:
+            shutil.rmtree(self.tmpdir)

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/calypso/calypso.git



More information about the Calypso-commits mailing list