* Add the beginnings of a test suite. (LP: #690386)

- Switch to setuptools, to support setup.py test.
This commit is contained in:
Stefano Rivera 2010-12-20 11:19:37 +02:00
parent d67edd7c3c
commit 686b6a8649
8 changed files with 86 additions and 6 deletions

4
debian/changelog vendored
View File

@ -7,8 +7,10 @@ ubuntu-dev-tools (0.109) UNRELEASED; urgency=low
- Added ubuntu-dev-tools.5
* Support the combined "Name <email>" 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 <stefanor@ubuntu.com> Sun, 19 Dec 2010 21:15:02 +0200
-- Stefano Rivera <stefanor@ubuntu.com> Mon, 20 Dec 2010 10:58:53 +0200
ubuntu-dev-tools (0.108) experimental; urgency=low

1
debian/clean vendored Normal file
View File

@ -0,0 +1 @@
*.egg-info/*

6
debian/control vendored
View File

@ -6,8 +6,10 @@ Uploaders: Luca Falavigna <dktrkranz@debian.org>,
Benjamin Drung <bdrung@ubuntu.com>
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

2
debian/copyright vendored
View File

@ -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 <bdrung@ubuntu.com>

8
debian/rules vendored
View File

@ -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

View File

@ -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',
)

View File

@ -0,0 +1,30 @@
# Test suite for ubuntutools
#
# Copyright (C) 2010, Stefano Rivera <stefanor@ubuntu.com>
#
# 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)

View File

@ -0,0 +1,35 @@
# test_common.py - Test suite for ubuntutools.common
#
# Copyright (C) 2010, Stefano Rivera <stefanor@ubuntu.com>
#
# 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)