Mercurial > ~astiob > upreckon > hgweb
diff problem.py @ 90:1fb319ec33af
Skimming mode added (-k/--skim option)
In skimming mode, as soon as a single test case within a test group
is failed, the remaining test cases in the same group are skipped.
Bug fix and simply a bit of refactoring: TestCase.has_iofiles and
TestCase.has_ansfile are now defined (the meaning should be clear
from the names).
author | Oleg Oshmyan <chortos@inbox.lv> |
---|---|
date | Mon, 28 Feb 2011 15:32:22 +0000 |
parents | cd347cfca272 |
children | c62c9bfd614a |
line wrap: on
line diff
--- a/problem.py Mon Feb 28 15:10:40 2011 +0000 +++ b/problem.py Mon Feb 28 15:32:22 2011 +0000 @@ -46,7 +46,7 @@ self.__dict__ = mydict class TestContext(object): - pass + __slots__ = () test_context_end = object() @@ -138,6 +138,8 @@ sys.stdout.flush() try: granted = case(lambda: (say('%7.3f%s s, ' % (case.time_stopped - case.time_started, case.time_limit_string), end=''), sys.stdout.flush())) + except testcases.TestCaseSkipped: + verdict = 'skipped due to skimming mode' except testcases.CanceledByUser: verdict = 'canceled by the user' except testcases.WallTimeLimitExceeded: @@ -187,6 +189,7 @@ comment = ' (%s)' % comment if granted >= 1: contexts[-1].case_correct() + prob.testcases.send(True) verdict = 'OK' + comment elif not granted: verdict = 'wrong answer' + comment @@ -206,8 +209,7 @@ sys.stdout.flush() return weighted, prob.config.taskweight finally: - if options.erase and (not prob.config.stdio or case and - (case.validator and not callable(case.validator))): + if options.erase and case and case.has_iofiles: for var in 'in', 'out': name = getattr(prob.config, var + 'name') if name: @@ -215,7 +217,7 @@ os.remove(name) except Exception: pass - if case.validator and not callable(case.validator): + if case.has_ansfile: if prob.config.ansname: try: os.remove(prob.config.ansname)