Mercurial > treepkg
view test/runtests.py @ 296:ce7be2fb93ee
Make it easy to install extra binaries into subdirectories of extra-pkg.
This makes it easier to manage the extra-pkg directory when it contains
manually added packages and automatically added packages from one of the
package tracks by putting the automatically added packages into
extra-pkg/auto and manually added packages into extra-pkg/manual.
To this end, add parameter subdir to PBuilder.add_binaries_to_extra_pkg
method with default value "auto". Adapt the test case accordingly.
Also add the command line argument --subdir to bin/treepkgbuilder.py
add-binaries command, this time with default value "manual".
author | Bernhard Herzog <bh@intevation.de> |
---|---|
date | Wed, 18 Nov 2009 18:11:22 +0000 |
parents | f9f15ee39ed7 |
children |
line wrap: on
line source
# Copyright (C) 2007 by Intevation GmbH # Authors: # Bernhard Herzog <bh@intevation.de> # # This program is free software under the GPL (>=v2) # Read the file COPYING coming with the software for details. """ Main entry point for the test suite. Just run this file as a python script to execute all tests """ import os import sys import unittest import optparse test_dir = os.path.dirname(__file__) sys.path.append(os.path.join(test_dir, os.pardir)) def find_test_modules(dirname, package = None): """Return a list the names of the test modules in the directory dirname The return value is a list of names that can be passed to unittest.defaultTestLoader.loadTestsFromNames. Each name of the list is the name of a pure python module, one for each file in dirname whose name starts with 'test' and ends with '.py'. The optional parameter package should be the name of the python package whose directory is dirname. If package is given all names in the returned list will be prefixed with package and a dot. """ if package: prefix = package + "." else: prefix = "" suffix = ".py" return [prefix + name[:-len(suffix)] for name in os.listdir(dirname) if name.startswith("test") and name.endswith(suffix)] def main(): """Run all the tests in the test suite""" parser = optparse.OptionParser() parser.set_defaults(verbosity=1) parser.add_option("-v", "--verbose", action="store_const", const=2, dest="verbosity") opts, rest = parser.parse_args() # Build the list of test names. If names were given on the command # line, run exactly those. Othwerwise build a default list of # names. if rest: names = rest else: # All Python files starting with 'test' in the current directory # and some directories in Extensions contain test cases. # FIXME: It should be possible to run runtests.py even when not in # the test directory names = find_test_modules(test_dir) suite = unittest.defaultTestLoader.loadTestsFromNames(names) runner = unittest.TextTestRunner(verbosity=opts.verbosity) result = runner.run(suite) sys.exit(not result.wasSuccessful()) if __name__ == "__main__": main()