Mercurial > ~astiob > upreckon > hgweb
comparison 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 | 
   comparison
  equal
  deleted
  inserted
  replaced
| 70:b9d5857f7b9a | 71:1bee3a0beeb5 | 
|---|---|
| 661 # and to pipe their standard I/O from and to each other, | 661 # and to pipe their standard I/O from and to each other, | 
| 662 # and then to capture the grader's exit code and use it | 662 # and then to capture the grader's exit code and use it | 
| 663 # like the exit code of an output validator is used. | 663 # like the exit code of an output validator is used. | 
| 664 | 664 | 
| 665 | 665 | 
| 666 class DummyTestContext(problem.TestGroup): | |
| 667 __slots__ = () | |
| 668 def end(self): | |
| 669 say('Sample total: %d/%d tests' % (self.ncorrect, self.ntotal)) | |
| 670 return self.log | |
| 671 | |
| 672 | |
| 666 def load_problem(prob, _types={'batch' : BatchTestCase, | 673 def load_problem(prob, _types={'batch' : BatchTestCase, | 
| 667 'outonly' : OutputOnlyTestCase, | 674 'outonly' : OutputOnlyTestCase, | 
| 668 'bestout' : BestOutputTestCase, | 675 'bestout' : BestOutputTestCase, | 
| 669 'reactive': ReactiveTestCase}): | 676 'reactive': ReactiveTestCase}): | 
| 670 # We will need to iterate over these configuration variables twice | 677 # We will need to iterate over these configuration variables twice | 
| 705 if prob.config.usegroups: | 712 if prob.config.usegroups: | 
| 706 for group in prob.config.tests: | 713 for group in prob.config.tests: | 
| 707 for i in group: | 714 for i in group: | 
| 708 s = str(i).zfill(prob.config.padtests) | 715 s = str(i).zfill(prob.config.padtests) | 
| 709 prob.cache.padoutput = max(prob.cache.padoutput, len(s)) | 716 prob.cache.padoutput = max(prob.cache.padoutput, len(s)) | 
| 717 yield DummyTestContext() | |
| 710 for i in prob.config.dummies: | 718 for i in prob.config.dummies: | 
| 711 s = str(i).zfill(prob.config.paddummies) | 719 s = str(i).zfill(prob.config.paddummies) | 
| 712 yield _types[prob.config.kind](prob, s, True, 0) | 720 yield _types[prob.config.kind](prob, s, True, 0) | 
| 721 yield problem.test_context_end | |
| 713 for group in prob.config.tests: | 722 for group in prob.config.tests: | 
| 714 yield problem.TestGroup() | 723 yield problem.TestGroup() | 
| 715 for i in group: | 724 for i in group: | 
| 716 s = str(i).zfill(prob.config.padtests) | 725 s = str(i).zfill(prob.config.padtests) | 
| 717 yield _types[prob.config.kind](prob, s, False, prob.config.pointmap.get(i, prob.config.pointmap.get(None, prob.config.maxexitcode if prob.config.maxexitcode else 1))) | 726 yield _types[prob.config.kind](prob, s, False, prob.config.pointmap.get(i, prob.config.pointmap.get(None, prob.config.maxexitcode if prob.config.maxexitcode else 1))) | 
