Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Poirier <simpoir@gmail.com>2009-07-12 16:59:11 (GMT)
committer Simon Poirier <simpoir@gmail.com>2009-07-12 16:59:11 (GMT)
commit539c3f2c7d5316ea64a00dd89fc94b97f2a69fdc (patch)
treec5ab90fa455e3356483dd9065cc712b8eeb06609
parent0c3f127c86af818d260966d2292b199757087157 (diff)
test runner in setup script
-rwxr-xr-xsetup.py41
-rw-r--r--tests/skip2
2 files changed, 36 insertions, 7 deletions
diff --git a/setup.py b/setup.py
index 6518a61..54d88a1 100755
--- a/setup.py
+++ b/setup.py
@@ -4,6 +4,7 @@ from distutils.core import setup, Command
from os.path import splitext, basename, join as pjoin, walk
import os, sys
import glob
+from unittest import TestLoader, TextTestRunner, TestSuite
class TestCommand(Command):
user_options = [('coverage',
@@ -28,16 +29,42 @@ class TestCommand(Command):
'''
Finds all the tests modules in tests/, and runs them.
'''
- testfiles = [ ]
+ prefix = os.path.join(self.prefix,'lib',
+ 'python%d.%d'%sys.version_info[:2],
+ 'site-packages')
+ sys.path.insert(1, prefix)
+ if self.coverage:
+ import coverage
+ coverage.erase()
+ coverage.start()
+
+ loader = TestLoader()
+ suite = TestSuite()
+ skipped = file('tests/skip', 'r').read().split('\n')
for t in glob.glob(pjoin(self._dir, 'tests', '*.py')):
- if not t.endswith('__init__.py'):
- testfiles.append('.'.join(
- ['tests', splitext(basename(t))[0]])
- )
+ if not t.endswith('__init__.py') and basename(t) not in skipped:
+ modname = '.'.join(['tests', splitext(basename(t))[0]])
+ mod = __import__(modname, {'sys':sys}, fromlist=[modname])
+ print "loading %s" % modname
+ suite.addTest(loader.loadTestsFromModule(mod))
+ else:
+ print "skipping %s" % t
- tests = TestLoader().loadTestsFromNames(testfiles)
t = TextTestRunner(verbosity = 1)
- t.run(tests)
+ t.run(suite)
+ if self.coverage:
+ coverage.stop()
+ sources = []
+ os.path.walk(os.path.join(prefix,'sugar','tutorius'),
+ self._listsources,
+ sources)
+ coverage.report(sources)
+ coverage.erase()
+
+ def _listsources(self, arg, dirname, fnames):
+ fnames = filter(lambda x:x.endswith('.py'), fnames)
+ for name in fnames:
+ arg.append(pjoin(dirname, name))
setup(name='Tutorius',
version='0.0',
diff --git a/tests/skip b/tests/skip
new file mode 100644
index 0000000..2061a09
--- /dev/null
+++ b/tests/skip
@@ -0,0 +1,2 @@
+run-tests.py
+overlaytests.py