diff testcases.py @ 71:1bee3a0beeb5

Added a 'Sample total' line when using test groups
author Oleg Oshmyan <chortos@inbox.lv>
date Mon, 03 Jan 2011 01:48:02 +0200
parents c0f1b87013ad
children 7520b6bb6636
line wrap: on
line diff
--- a/testcases.py	Mon Jan 03 01:27:56 2011 +0200
+++ b/testcases.py	Mon Jan 03 01:48:02 2011 +0200
@@ -663,6 +663,13 @@
 	# like the exit code of an output validator is used.
 
 
+class DummyTestContext(problem.TestGroup):
+	__slots__ = ()
+	def end(self):
+		say('Sample total: %d/%d tests' % (self.ncorrect, self.ntotal))
+		return self.log
+
+
 def load_problem(prob, _types={'batch'   : BatchTestCase,
                                'outonly' : OutputOnlyTestCase,
                                'bestout' : BestOutputTestCase,
@@ -707,9 +714,11 @@
 			for i in group:
 				s = str(i).zfill(prob.config.padtests)
 				prob.cache.padoutput = max(prob.cache.padoutput, len(s))
+		yield DummyTestContext()
 		for i in prob.config.dummies:
 			s = str(i).zfill(prob.config.paddummies)
 			yield _types[prob.config.kind](prob, s, True, 0)
+		yield problem.test_context_end
 		for group in prob.config.tests:
 			yield problem.TestGroup()
 			for i in group: