Mercurial > ~astiob > upreckon > hgweb
comparison testcases.py @ 105:9f922b11c98a
Absent output files no longer crash Upreckon
author | Oleg Oshmyan <chortos@inbox.lv> |
---|---|
date | Fri, 08 Apr 2011 17:45:53 +0300 |
parents | 8f46e84922f9 |
children | aa0378ea1f93 |
comparison
equal
deleted
inserted
replaced
104:8f46e84922f9 | 105:9f922b11c98a |
---|---|
329 call(case.problem.config.path, case=case, stdin=devnull, stdout=devnull, stderr=STDOUT) | 329 call(case.problem.config.path, case=case, stdin=devnull, stdout=devnull, stderr=STDOUT) |
330 if config.globalconf.force_zero_exitcode and case.process.returncode or case.process.returncode < 0: | 330 if config.globalconf.force_zero_exitcode and case.process.returncode or case.process.returncode < 0: |
331 raise NonZeroExitCode(case.process.returncode) | 331 raise NonZeroExitCode(case.process.returncode) |
332 case.has_called_back = True | 332 case.has_called_back = True |
333 callback() | 333 callback() |
334 with open(case.problem.config.outname, 'rU') as output: | 334 try: |
335 output = open(case.problem.config.outname, 'rU') | |
336 except IOError: | |
337 raise CannotReadOutputFile(sys.exc_info()[1]) | |
338 with output as output: | |
335 return case.validate(output) | 339 return case.validate(output) |
336 | 340 |
337 | 341 |
338 # This is the only test case type not executing any programs to be tested | 342 # This is the only test case type not executing any programs to be tested |
339 class OutputOnlyTestCase(ValidatedTestCase): | 343 class OutputOnlyTestCase(ValidatedTestCase): |
345 | 349 |
346 def test(case, callback): | 350 def test(case, callback): |
347 case.time_stopped = case.time_started = 0 | 351 case.time_stopped = case.time_started = 0 |
348 case.has_called_back = True | 352 case.has_called_back = True |
349 callback() | 353 callback() |
350 with open(case.problem.config.outname.replace('$', case.id), 'rU') as output: | 354 try: |
355 output = open(case.problem.config.outname.replace('$', case.id), 'rU') | |
356 except IOError: | |
357 raise CannotReadOutputFile(sys.exc_info()[1]) | |
358 with output as output: | |
351 return case.validate(output) | 359 return case.validate(output) |
352 | 360 |
353 | 361 |
354 class BestOutputTestCase(ValidatedTestCase): | 362 class BestOutputTestCase(ValidatedTestCase): |
355 __slots__ = () | 363 __slots__ = () |