tests: make tests a Python module
authorMarkus Lehtonen <markus.lehtonen@linux.intel.com>
Tue, 6 Nov 2012 17:01:01 +0000 (19:01 +0200)
committerGuido Günther <agx@sigxcpu.org>
Fri, 23 Nov 2012 16:30:31 +0000 (17:30 +0100)
Makes it possible to reuse code between various tests.

Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
setup.py
tests/08_test_patch.py
tests/09_test_write_tree.py
tests/10_test_get_upstream_tree.py
tests/11_test_dch_main.py
tests/__init__.py [new file with mode: 0644]

index b9342c2..4042eb4 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -55,7 +55,7 @@ setup(name = "gbp",
                   'bin/gbp-clone',
                   'bin/gbp-create-remote-repo',
                   'bin/git-pbuilder'],
-      packages = find_packages(),
+      packages = find_packages(exclude=['tests', 'tests.*']),
       data_files = [("/etc/git-buildpackage/", ["gbp.conf"]),],
       setup_requires=['nose>=0.11.1', 'coverage>=2.85'],
 )
index 7aa6048..9816074 100644 (file)
@@ -9,7 +9,7 @@ from gbp.patch_series import Patch
 
 
 class TestPatch(unittest.TestCase):
-    data_dir = "tests/%s_data" % __module__
+    data_dir = os.path.splitext(__file__)[0] + '_data'
 
     def test_filename(self):
         """Get patch information from the filename"""
index dd81f70..4275cac 100644 (file)
@@ -4,7 +4,7 @@
 
 import os
 
-import testutils
+import tests.testutils as testutils
 
 import gbp.log
 import gbp.git
index 8c60178..83611dd 100644 (file)
@@ -2,7 +2,7 @@
 
 """Test  L{buildpackage}'s get_upstream_tree method"""
 
-import testutils
+import tests.testutils as testutils
 
 import gbp.errors
 import gbp.scripts.buildpackage as buildpackage
index 7c8fee2..f45857e 100644 (file)
@@ -4,7 +4,7 @@
 
 import unittest
 
-from testutils import DebianGitTestRepo
+from tests.testutils import DebianGitTestRepo
 
 from gbp.scripts import dch
 
diff --git a/tests/__init__.py b/tests/__init__.py
new file mode 100644 (file)
index 0000000..22e1fc5
--- /dev/null
@@ -0,0 +1,20 @@
+# vim: set fileencoding=utf-8 :
+#
+# (C) 2009, 2010,2011, 2012 Guido Guenther <agx@sigxcpu.org>
+# (C) 2012 Intel Corporation <markus.lehtonen@linux.intel.com>
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License
+#    along with this program; if not, write to the Free Software
+#    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+"""Unit tests for git-buildpackage"""
+
+# vim:et:ts=4:sw=4:et:sts=4:ai:set list listchars=tab\:»·,trail\:·: