[PATCH 4/6] Teach the Setuptools script how to find and run the test suite.

Ben Finney bignose at debian.org
Fri Jan 13 23:25:37 UTC 2017


---
 debian/changelog |  8 ++++++++
 setup.py.in      | 14 ++++++++++++++
 2 files changed, 22 insertions(+)

diff --git a/debian/changelog b/debian/changelog
index 5f242153..f6a31110 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,11 @@
+python-debian (0.1.30) UNRELEASED; urgency=medium
+
+  [ Ben Finney ]
+
+  * Teach the Setuptools script how to find and run the test suite.
+
+ --
+
 python-debian (0.1.29) unstable; urgency=medium
 
   * Fix handling of gpgv output from gnupg 2 (Closes: #782904).
diff --git a/setup.py.in b/setup.py.in
index 697e2c23..18399e27 100644
--- a/setup.py.in
+++ b/setup.py.in
@@ -18,8 +18,21 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
+import os.path
+import unittest
+
 from setuptools import setup
 
+
+def test_suite():
+    """ Get the test suite for this distribution. """
+    root_dir = os.path.dirname(os.path.abspath(__file__))
+    tests_dir = os.path.join(root_dir, "tests")
+    test_loader = unittest.TestLoader()
+    test_suite = test_loader.discover(start_dir=tests_dir, pattern="test_*.py")
+    return test_suite
+
+
 setup(
     name='python-debian',
     version='__CHANGELOG_VERSION__',
@@ -30,5 +43,6 @@ setup(
     py_modules=['deb822'],
     maintainer='Debian python-debian Maintainers',
     maintainer_email='pkg-python-debian-maint at lists.alioth.debian.org',
+    test_suite='setup.test_suite',
     install_requires=['six'],
 )
-- 
2.11.0



More information about the pkg-python-debian-maint mailing list