comparison testcases.py @ 83:37c4ad87583c

Several small fixes Bug fix: testconf.py bytecode is written on Python 2.5. It is not written on newer versions of Python, but Python 2.5 lacks the facility to disable writing it; before this fix, the code just raised an unhandled exception. Bug fix: callable validators no longer require the outfile configuration variable to be set. Bug fix: the pause configuration variable (if not callable) is run in a shell just like it did in test.py v1; in particular, auto-detected values of the pause configuration variable now work again. Extras: *.{class,orig} added to .hgignore; Sublime Text 1 project file removed as I am using Sublime Text 2 now.
author Oleg Oshmyan <chortos@inbox.lv>
date Thu, 24 Feb 2011 00:10:19 +0000
parents 06356af50bf9
children 741ae3391b61
comparison
equal deleted inserted replaced
82:06356af50bf9 83:37c4ad87583c
277 else: 277 else:
278 inputdatafname = case.problem.config.inname 278 inputdatafname = case.problem.config.inname
279 contextmgr = Copying(case.infile, inputdatafname) 279 contextmgr = Copying(case.infile, inputdatafname)
280 with contextmgr: 280 with contextmgr:
281 with open(inputdatafname) as infile: 281 with open(inputdatafname) as infile:
282 with tempfile.TemporaryFile('w+') if options.erase and not case.validator else open(case.problem.config.outname, 'w+') as outfile: 282 with tempfile.TemporaryFile('w+') if options.erase and (not case.validator or callable(case.validator)) else open(case.problem.config.outname, 'w+') as outfile:
283 call(case.problem.config.path, case=case, stdin=infile, stdout=outfile, stderr=devnull, universal_newlines=True, bufsize=-1) 283 call(case.problem.config.path, case=case, stdin=infile, stdout=outfile, stderr=devnull, universal_newlines=True, bufsize=-1)
284 if config.globalconf.force_zero_exitcode and case.process.returncode or case.process.returncode < 0: 284 if config.globalconf.force_zero_exitcode and case.process.returncode or case.process.returncode < 0:
285 raise NonZeroExitCode(case.process.returncode) 285 raise NonZeroExitCode(case.process.returncode)
286 callback() 286 callback()
287 case.has_called_back = True 287 case.has_called_back = True