aboutsummaryrefslogtreecommitdiffstats
path: root/setuptools/command/test.py
diff options
context:
space:
mode:
authorPJ Eby <distutils-sig@python.org>2004-03-19 20:53:14 +0000
committerPJ Eby <distutils-sig@python.org>2004-03-19 20:53:14 +0000
commit8423e1ed14ac1691c2863c6e8cac9230cf558d7b (patch)
tree79f2d2cef146e08a9480357637cca4662307bd08 /setuptools/command/test.py
downloadexternal_python_setuptools-8423e1ed14ac1691c2863c6e8cac9230cf558d7b.tar.gz
external_python_setuptools-8423e1ed14ac1691c2863c6e8cac9230cf558d7b.tar.bz2
external_python_setuptools-8423e1ed14ac1691c2863c6e8cac9230cf558d7b.zip
Initial checkin of setuptools 0.0.1.
--HG-- branch : setuptools extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/trunk/setuptools%4040869
Diffstat (limited to 'setuptools/command/test.py')
-rw-r--r--setuptools/command/test.py82
1 files changed, 82 insertions, 0 deletions
diff --git a/setuptools/command/test.py b/setuptools/command/test.py
new file mode 100644
index 00000000..6b37a9fd
--- /dev/null
+++ b/setuptools/command/test.py
@@ -0,0 +1,82 @@
+from distutils.cmd import Command
+from distutils.errors import DistutilsOptionError
+import sys
+
+class test(Command):
+
+ """Command to run unit tests after installation"""
+
+ description = "run unit tests after installation"
+
+ user_options = [
+ ('test-module=','m', "Run 'test_suite' in specified module"),
+ ('test-suite=','s',
+ "Test suite to run (e.g. 'some_module.test_suite')"),
+ ]
+
+ test_suite = None
+ test_module = None
+
+ def initialize_options(self):
+ pass
+
+
+ def finalize_options(self):
+
+ if self.test_suite is None:
+ if self.test_module is None:
+ self.test_suite = self.distribution.test_suite
+ else:
+ self.test_suite = self.test_module+".test_suite"
+ elif self.test_module:
+ raise DistutilsOptionError(
+ "You may specify a module or a suite, but not both"
+ )
+
+ self.test_args = [self.test_suite]
+
+ if self.verbose:
+ self.test_args.insert(0,'--verbose')
+
+
+ def run(self):
+
+ # Install before testing
+ self.run_command('install')
+
+ if self.test_suite:
+ cmd = ' '.join(self.test_args)
+
+ if self.dry_run:
+ self.announce('skipping "unittest %s" (dry run)' % cmd)
+ else:
+ self.announce('running "unittest %s"' % cmd)
+ import unittest
+ unittest.main(None, None, [unittest.__file__]+self.test_args)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+