Mercurial > ~astiob > upreckon > hgweb
comparison upreckon/testcases.py @ 232:f94f9724c543
Switched from str to bytes for external validator output
author | Oleg Oshmyan <chortos@inbox.lv> |
---|---|
date | Fri, 29 Jun 2012 03:32:49 +0300 |
parents | 65b5c9390010 |
children |
comparison
equal
deleted
inserted
replaced
229:928a6091454c | 232:f94f9724c543 |
---|---|
1 # Copyright (c) 2010-2011 Chortos-2 <chortos@inbox.lv> | 1 # Copyright (c) 2010-2012 Chortos-2 <chortos@inbox.lv> |
2 | 2 |
3 # TODO: copy the ansfile if not options.erase even if no validator is used | 3 # TODO: copy the ansfile if not options.erase even if no validator is used |
4 | 4 |
5 from __future__ import division, with_statement | 5 from __future__ import division, with_statement |
6 | 6 |
225 output.close() | 225 output.close() |
226 if case.problem.config.ansname: | 226 if case.problem.config.ansname: |
227 case.open_outfile() | 227 case.open_outfile() |
228 case.outfile.copy(case.problem.config.ansname) | 228 case.outfile.copy(case.problem.config.ansname) |
229 try: | 229 try: |
230 case.process = Popen(case.validator, stdin=devnull, stdout=PIPE, stderr=STDOUT, universal_newlines=True, bufsize=-1) | 230 case.process = Popen(case.validator, stdin=devnull, stdout=PIPE, stderr=STDOUT, bufsize=-1) |
231 except OSError: | 231 except OSError: |
232 raise CannotStartValidator(sys.exc_info()[1]) | 232 raise CannotStartValidator(sys.exc_info()[1]) |
233 with signal_ignorer: | 233 with signal_ignorer: |
234 comment = case.process.communicate()[0].strip() | 234 comment = case.process.communicate()[0].strip() |
235 match = re.match(r'(?i)(?:ok|(?:(?:in)?correct|wrong)(?:(?:\s|_)*answer)?)(?:$|\s+|[.,!:]+\s*)', comment) | 235 match = re.match(r'(?i)(?:ok|(?:(?:in)?correct|wrong)(?:(?:\s|_)*answer)?)(?:$|\s+|[.,!:]+\s*)'.encode('ascii'), comment) |
236 if match: | 236 if match: |
237 comment = comment[match.end():] | 237 comment = comment[match.end():] |
238 if not case.problem.config.maxexitcode: | 238 if not case.problem.config.maxexitcode: |
239 if case.process.returncode: | 239 if case.process.returncode: |
240 raise WrongAnswer(comment) | 240 raise WrongAnswer(comment) |