+ log_name = os.path.join(parsed.logs, "%s-%s-%s.log" %
+ (time.strftime("%Y%m%d-%H%M%S"), type(target).__name__, name))
+ log_fd = open(log_name, 'w')
+ print "Running", name, "...",
+ sys.stdout.flush()
+ log_fd.write("Test: %s\n" % name)
+ log_fd.write("Target: %s\n" % type(target).__name__)
+ start = time.time()
+ real_stdout = sys.stdout
+ sys.stdout = log_fd
+ try:
+ result = instance.run()
+ finally:
+ sys.stdout = real_stdout
+ print "%s in %.2fs" % (result, time.time() - start)
+ sys.stdout.flush()
+ log_fd.write("Result: %s\n" % result)
+ log_fd.write("Time elapsed: %.2fs\n" % (time.time() - start))