diff --git a/debian/changelog b/debian/changelog index 951bf5d..d1bff39 100644 --- a/debian/changelog +++ b/debian/changelog @@ -7,8 +7,10 @@ ubuntu-dev-tools (0.109) UNRELEASED; urgency=low - Added ubuntu-dev-tools.5 * Support the combined "Name " format in UBUMAIL, DEBFULLNAME, and DEBEMAIL. (LP: #665202) + * Add the beginnings of a test suite. (LP: #690386) + - Switch to setuptools, to support setup.py test. - -- Stefano Rivera Sun, 19 Dec 2010 21:15:02 +0200 + -- Stefano Rivera Mon, 20 Dec 2010 10:58:53 +0200 ubuntu-dev-tools (0.108) experimental; urgency=low diff --git a/debian/clean b/debian/clean new file mode 100644 index 0000000..45149aa --- /dev/null +++ b/debian/clean @@ -0,0 +1 @@ +*.egg-info/* diff --git a/debian/control b/debian/control index 5f0959f..aa8b6a8 100644 --- a/debian/control +++ b/debian/control @@ -6,8 +6,10 @@ Uploaders: Luca Falavigna , Benjamin Drung Vcs-Bzr: lp:ubuntu-dev-tools Vcs-Browser: https://code.launchpad.net/~ubuntu-dev/ubuntu-dev-tools/trunk -Build-Depends: debhelper (>= 7), python (>= 2.5) -Build-Depends-Indep: python-support (>= 0.5.3) +Build-Depends: debhelper (>= 7.0.50~), python-all (>= 2.5) +Build-Depends-Indep: python-setuptools, + python-support (>= 0.5.3), + python-unittest2 DM-Upload-Allowed: yes XS-Python-Version: >= 2.5 Homepage: https://launchpad.net/ubuntu-dev-tools diff --git a/debian/copyright b/debian/copyright index ea32b6a..1c29932 100644 --- a/debian/copyright +++ b/debian/copyright @@ -150,7 +150,6 @@ Files: pull-lp-source, pull-revu-source, ubuntu-build, - ubuntutools/common.py, ubuntutools/lp/libsupport.py, ubuntutools/lp/lpapicache.py, ubuntutools/misc.py, @@ -197,6 +196,7 @@ Files: ubuntutools/sponsor_patch/bugtask.py, ubuntutools/sponsor_patch/main.py, ubuntutools/sponsor_patch/patch.py, + ubuntutools/test/*, wrap-and-sort Copyright: 2010, Benjamin Drung diff --git a/debian/rules b/debian/rules index 2d33f6a..883be80 100755 --- a/debian/rules +++ b/debian/rules @@ -2,3 +2,11 @@ %: dh $@ + +override_dh_auto_test: +ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS))) + set -e; \ + for python in $(shell pyversions -r); do \ + $$python setup.py test; \ + done +endif diff --git a/setup.py b/setup.py index 6bc464b..91920e7 100755 --- a/setup.py +++ b/setup.py @@ -1,6 +1,6 @@ #!/usr/bin/python -from distutils.core import setup +from setuptools import setup import glob import os import re @@ -60,6 +60,8 @@ setup(name='ubuntu-dev-tools', 'ubuntutools/lp', 'ubuntutools/requestsync', 'ubuntutools/sponsor_patch', + 'ubuntutools/test', ], - data_files=[('share/man/man1', glob.glob("doc/*.1"))] + data_files=[('share/man/man1', glob.glob("doc/*.1"))], + test_suite='ubuntutools.test.discover', ) diff --git a/ubuntutools/test/__init__.py b/ubuntutools/test/__init__.py new file mode 100644 index 0000000..f47644d --- /dev/null +++ b/ubuntutools/test/__init__.py @@ -0,0 +1,30 @@ +# Test suite for ubuntutools +# +# Copyright (C) 2010, Stefano Rivera +# +# Permission to use, copy, modify, and/or distribute this software for any +# purpose with or without fee is hereby granted, provided that the above +# copyright notice and this permission notice appear in all copies. +# +# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +# AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR +# OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +# PERFORMANCE OF THIS SOFTWARE. + +from sys import version_info as _version_info + +if _version_info < (2, 7): + import unittest2 as unittest +else: + import unittest + +def discover(): + import os + import sys + # import __main__ triggers code re-execution + __main__ = sys.modules['__main__'] + setupDir = os.path.abspath(os.path.dirname(__main__.__file__)) + return unittest.defaultTestLoader.discover(setupDir) diff --git a/ubuntutools/test/test_common.py b/ubuntutools/test/test_common.py new file mode 100644 index 0000000..7e9a2fd --- /dev/null +++ b/ubuntutools/test/test_common.py @@ -0,0 +1,35 @@ +# test_common.py - Test suite for ubuntutools.common +# +# Copyright (C) 2010, Stefano Rivera +# +# Permission to use, copy, modify, and/or distribute this software for any +# purpose with or without fee is hereby granted, provided that the above +# copyright notice and this permission notice appear in all copies. +# +# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +# AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR +# OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +# PERFORMANCE OF THIS SOFTWARE. + +from ubuntutools.test import unittest +from ubuntutools.common import memoize_noargs + +class MemoizeTestCase(unittest.TestCase): + def test_memoize_noargs(self): + global run_count + run_count = 0 + + @memoize_noargs + def test_func(): + global run_count + run_count += 1 + return 42 + + self.assertEqual(run_count, 0) + self.assertEqual(test_func(), 42) + self.assertEqual(run_count, 1) + self.assertEqual(test_func(), 42) + self.assertEqual(run_count, 1)