PyUT: Add initial unittest framework, limit possible python versions to >= 2.7.
authorDidier Raboud <odyx@debian.org>
Fri, 4 May 2012 11:41:25 +0000 (13:41 +0200)
committerDidier Raboud <odyx@debian.org>
Mon, 7 May 2012 17:28:54 +0000 (19:28 +0200)
Limiting the supported python versions to >= 2.6 permits to avoid unneccessary
code to permit the use of unittest in all python 2 and 3 versions such as:

import sys

if sys.version_info[0] >= 3:
import unittest
else:
import unittest2 as unittest

python2.7 is the default version in Debian unstable since Sep 2011.

debian/control
debian/rules
test/test_lsb_release.py [new file with mode: 0644]

index fde40a4ecd8601e1156f3e761b6d365d7db66d6c..7bcca796eb7c08cafe0eefd8d2af09b5e9e180f0 100644 (file)
@@ -6,7 +6,8 @@ Uploaders: Didier Raboud <odyx@debian.org>, Jeff Licquia <licquia@debian.org>
 Build-Depends: debhelper (>> 7.0.50~),
  po-debconf (>= 0.5.0),
  dpkg-dev (>= 1.10),
- python-all-dev (>= 2.6.6-6~)
+ python-all-dev (>= 2.6.6-6~),
+X-Python-Version: >= 2.7
 Standards-Version: 3.9.3
 Homepage: http://www.linuxfoundation.org/collaborate/workgroups/lsb
 Vcs-Git: git://anonscm.debian.org/collab-maint/lsb.git
index a465fc4160a9e5e30a64afb70f23431c21f12eb1..07c6067cd0e666b01db1fd96bae5464c1680eb88 100755 (executable)
@@ -2,6 +2,8 @@
 
 derives_from_ubuntu := $(shell (dpkg-vendor --derives-from Ubuntu && echo "yes") || echo "no")
 
+PY2VERSIONS=$(shell pyversions -vr)
+
 %:
        dh --with python2 $@
 
@@ -44,6 +46,11 @@ override_dh_clean:
        dh_clean
        rm -f *.py[co]
 
+override_dh_auto_test: $(PY2VERSIONS:%=test-python%)
+
+test-python%:
+       PYTHONPATH=. python$* test/test_lsb_release.py -vv
+
 override_dh_python2:
        dh_python2
        dh_python2 /usr/lib/lsb
diff --git a/test/test_lsb_release.py b/test/test_lsb_release.py
new file mode 100644 (file)
index 0000000..bc927f8
--- /dev/null
@@ -0,0 +1,15 @@
+#!/usr/bin/python
+import unittest
+
+import lsb_release as lr
+
+import random
+import string
+
+class TestLSBRelease(unittest.TestCase):
+
+       def test_void(self):
+               self.assertTrue('Void test')
+
+if __name__ == '__main__':
+       unittest.main()