comparison 2.00/testcases.py @ 24:c23d81f4a1a3

Score returned by TestCase.__call__() is now normalized to 0..1 TestCase.__call__() now returns the fraction (a number from 0 to 1) of case.points that is to be awarded. Bug fix: %-patterns in configuration variables common to all problems are now substituted.
author Oleg Oshmyan <chortos@inbox.lv>
date Thu, 23 Sep 2010 00:11:24 +0000
parents c1f52b5d80d6
children b500e117080e
comparison
equal deleted inserted replaced
23:c1f52b5d80d6 24:c23d81f4a1a3
319 refoutput.next() 319 refoutput.next()
320 except StopIteration: 320 except StopIteration:
321 pass 321 pass
322 else: 322 else:
323 raise WrongAnswer 323 raise WrongAnswer
324 return case.points 324 return 1
325 elif callable(case.validator): 325 elif callable(case.validator):
326 return case.validator(output) 326 return case.validator(output)
327 else: 327 else:
328 # Call the validator program 328 # Call the validator program
329 output.close() 329 output.close()
338 comment = comment[match.end():] 338 comment = comment[match.end():]
339 if not case.problem.config.maxexitcode: 339 if not case.problem.config.maxexitcode:
340 if case.process.returncode: 340 if case.process.returncode:
341 raise WrongAnswer(comment) 341 raise WrongAnswer(comment)
342 else: 342 else:
343 return case.points, comment 343 return 1, comment
344 else: 344 else:
345 return case.points * case.process.returncode / case.problem.config.maxexitcode, comment 345 return case.process.returncode / case.problem.config.maxexitcode, comment
346 346
347 347
348 class BatchTestCase(ValidatedTestCase): 348 class BatchTestCase(ValidatedTestCase):
349 __slots__ = () 349 __slots__ = ()
350 350