Optparsified, and added the -e option to exclude certain tests.

This commit is contained in:
Jeremy Fincher 2003-10-07 14:09:13 +00:00
parent 1c96752dfa
commit f93b1e305a

View File

@ -276,6 +276,8 @@ class PluginDocumentation:
if __name__ == '__main__': if __name__ == '__main__':
import optparse
if not os.path.exists(conf.dataDir): if not os.path.exists(conf.dataDir):
os.mkdir(conf.dataDir) os.mkdir(conf.dataDir)
@ -290,12 +292,20 @@ if __name__ == '__main__':
os.remove(os.path.join(conf.logDir, filename)) os.remove(os.path.join(conf.logDir, filename))
debug._open() debug._open()
parser = optparse.OptionParser(usage='Usage: %prog [options]',
version='Supybot %s' % conf.version)
parser.add_option('-e', '--exclude', action='append',
dest='exclusions', metavar='TESTFILE',
help='Exclude this test from the test run.')
(options, args) = parser.parse_args()
if not args:
args = glob.glob(os.path.join('test', 'test_*.py'))
if options.exclusions:
for name in options.exclusions:
args = [s for s in args if s != name]
world.testing = True world.testing = True
if len(sys.argv) > 1: names = [os.path.splitext(os.path.basename(name))[0] for name in args]
files = sys.argv[1:]
else:
files = glob.glob(os.path.join('test', 'test_*.py'))
names = [os.path.splitext(os.path.basename(file))[0] for file in files]
suite = unittest.defaultTestLoader.loadTestsFromNames(names) suite = unittest.defaultTestLoader.loadTestsFromNames(names)
runner = unittest.TextTestRunner(verbosity=2) runner = unittest.TextTestRunner(verbosity=2)
runner.run(suite) runner.run(suite)