Mercurial > ~astiob > upreckon > hgweb
comparison 2.00/problem.py @ 23:c1f52b5d80d6
Compatibility and bug fixes
-1 command line option added (currently only detects the presence of test groups).
The ansname configuration variable is now (again) optional when output validators are used.
Bug fix: path realization only looked at paths beginning with tests/.
Bug fix: non-reiterable values of the tests configuration variable are now handled correctly.
Bug fix: an exceptions was raised if a problem had no test cases.
author | Oleg Oshmyan <chortos@inbox.lv> |
---|---|
date | Wed, 22 Sep 2010 23:34:51 +0000 |
parents | f07b7a431ea6 |
children | c23d81f4a1a3 |
comparison
equal
deleted
inserted
replaced
22:f07b7a431ea6 | 23:c1f52b5d80d6 |
---|---|
56 # TODO | 56 # TODO |
57 def build(prob): | 57 def build(prob): |
58 raise NotImplementedError | 58 raise NotImplementedError |
59 | 59 |
60 def test(prob): | 60 def test(prob): |
61 case = None | |
61 try: | 62 try: |
62 real = max = ntotal = nvalued = ncorrect = ncorrectvalued = 0 | 63 real = max = ntotal = nvalued = ncorrect = ncorrectvalued = 0 |
63 for case in prob.testcases: | 64 for case in prob.testcases: |
64 ntotal += 1 | 65 ntotal += 1 |
65 max += case.points | 66 max += case.points |
151 say('Problem total: %d/%d tests (%d/%d valued); %g/%g points; weighted score: %g/%g' % (ncorrect, ntotal, ncorrectvalued, nvalued, real, max, weighted, prob.config.taskweight)) | 152 say('Problem total: %d/%d tests (%d/%d valued); %g/%g points; weighted score: %g/%g' % (ncorrect, ntotal, ncorrectvalued, nvalued, real, max, weighted, prob.config.taskweight)) |
152 else: | 153 else: |
153 say('Problem total: %d/%d tests; %g/%g points; weighted score: %g/%g' % (ncorrect, ntotal, real, max, weighted, prob.config.taskweight)) | 154 say('Problem total: %d/%d tests; %g/%g points; weighted score: %g/%g' % (ncorrect, ntotal, real, max, weighted, prob.config.taskweight)) |
154 return weighted, prob.config.taskweight | 155 return weighted, prob.config.taskweight |
155 finally: | 156 finally: |
156 if options.erase and (not prob.config.stdio or case.validator): | 157 if options.erase and (not prob.config.stdio or case and case.validator): |
157 for var in 'in', 'out': | 158 for var in 'in', 'out': |
158 name = getattr(prob.config, var + 'name') | 159 name = getattr(prob.config, var + 'name') |
159 if name: | 160 if name: |
160 try: | 161 try: |
161 os.remove(name) | 162 os.remove(name) |