comparison tests/run.py @ 357:d19843ac13c9

Allow passing in module arguments to the test runs.
author Dirkjan Ochtman <dirkjan@ochtman.nl>
date Thu, 28 May 2009 08:48:57 +0200
parents 537de0300510
children e857e5cfc10f
comparison
equal deleted inserted replaced
356:62f90781eb10 357:d19843ac13c9
23 import test_svnwrap 23 import test_svnwrap
24 import test_tags 24 import test_tags
25 import test_utility_commands 25 import test_utility_commands
26 import test_urls 26 import test_urls
27 27
28 def suite(): 28 if __name__ == '__main__':
29 return unittest.TestSuite([test_binaryfiles.suite(),
30 test_diff.suite(),
31 test_externals.suite(),
32 test_fetch_branches.suite(),
33 test_fetch_command.suite(),
34 test_fetch_command_regexes.suite(),
35 test_fetch_exec.suite(),
36 test_fetch_mappings.suite(),
37 test_fetch_renames.suite(),
38 test_fetch_symlinks.suite(),
39 test_fetch_truncated.suite(),
40 test_pull.suite(),
41 test_push_command.suite(),
42 test_push_renames.suite(),
43 test_push_dirs.suite(),
44 test_push_eol.suite(),
45 test_rebuildmeta.suite(),
46 test_svnwrap.suite(),
47 test_tags.suite(),
48 test_utility_commands.suite(),
49 test_urls.suite(),
50 ])
51 29
52 if __name__ == '__main__': 30 kwargs = {'descriptions': 2}
53 kwargs = { 'descriptions': 2 }
54 if '-v' in sys.argv: 31 if '-v' in sys.argv:
55 kwargs['descriptions'] = 3 32 kwargs['descriptions'] = 3
56 kwargs['verbosity'] = 2 33 kwargs['verbosity'] = 2
57 34
58 # silence output when running outside nose 35 # silence output when running outside nose
59 sys.stdout = os.tmpfile() 36 sys.stdout = os.tmpfile()
60 37
38 all = globals()
39 all = dict((k, v) for (k, v) in all.iteritems() if k.startswith('test_'))
40 del all['test_util']
41
42 args = [i for i in sys.argv[1:] if i.startswith('test')]
43 args = [i.split('.py')[0].replace('-', '_') for i in args]
44
45 if not args:
46 suite = [i[1].suite() for i in sorted(all.iteritems())]
47 else:
48 suite = []
49 for arg in args:
50 if arg not in all:
51 print 'test module %s not available' % arg
52 else:
53 suite.append(all[arg].suite())
54
61 runner = unittest.TextTestRunner(**kwargs) 55 runner = unittest.TextTestRunner(**kwargs)
62 runner.run(suite()) 56 runner.run(unittest.TestSuite(suite))