# HG changeset patch # User Atul Varma # Date 1252616833 25200 # Node ID 6c55f09ff31d8e2503e9c68308b02eee86d946db # Parent e4978bd08bfab1ea07f40e20cfabd5ec4320ee4b Minor refactorings to improve readability diff -r e4978bd08bfa -r 6c55f09ff31d test_pydertron.py --- a/test_pydertron.py Thu Sep 10 13:53:03 2009 -0700 +++ b/test_pydertron.py Thu Sep 10 14:07:13 2009 -0700 @@ -7,14 +7,11 @@ def run_test(name, libpath): sandbox = JsSandbox(SandboxedFileSystem(libpath)) - stats = [0, 0] + stats = {'pass': 0, 'fail': 0, 'info': 0} @jsexposed(name='print') def jsprint(message, label): - if label == "pass": - stats[0] += 1 - elif label == "fail": - stats[1] += 1 + stats[label] += 1 print "%s %s" % (message, label) sandbox.set_globals( @@ -27,7 +24,7 @@ print if retval != 0: - stats[1] += 1 + stats['fail'] += 1 return stats if __name__ == '__main__': @@ -46,18 +43,18 @@ for name in os.listdir(base_libpath) if name not in ['.svn', 'ORACLE']] - totals = [0, 0] + totals = {'pass': 0, 'fail': 0} for libpath, name in dirs: - passed, failed = run_test(name, libpath) - totals[0] += passed - totals[1] += failed + stats = run_test(name, libpath) + totals['pass'] += stats['pass'] + totals['fail'] += stats['fail'] - print "passed: %d failed: %d" % tuple(totals) + print "passed: %(pass)d failed: %(fail)d" % totals import gc gc.collect() if pydermonkey.get_debug_info()['runtime_count']: sys.stderr.write("WARNING: JS runtime was not destroyed.\n") - sys.exit(totals[1]) + sys.exit(totals['fail'])