1#!/usr/bin/python 2 3import sys 4from optparse import OptionParser 5 6# Parse command line 7 8parser = OptionParser() 9 10parser.add_option("-b", "--binding", action="store", type="string", 11 dest="binding") 12 13parser.add_option("-d", "--domain", action="store", type="string", 14 dest="domain") 15 16parser.add_option("-u", "--username", action="store", type="string", 17 dest="username") 18 19parser.add_option("-p", "--password", action="store", type="string", 20 dest="password") 21 22(options, args) = parser.parse_args() 23 24if not options.binding: 25 parser.error('You must supply a binding string') 26 27if not options.username or not options.password or not options.domain: 28 parser.error('You must supply a domain, username and password') 29 30binding = options.binding 31domain = options.domain 32username = options.username 33password = options.password 34 35if len(args) == 0: 36 parser.error('You must supply the name of a module to test') 37 38# Import and test 39 40for test in args: 41 42 try: 43 module = __import__('torture_%s' % test) 44 except ImportError: 45 print 'No such module "%s"' % test 46 sys.exit(1) 47 48 if not hasattr(module, 'runtests'): 49 print 'Module "%s" does not have a runtests function' % test 50 51 module.runtests(binding, (domain, username, password)) 52