Mercurial > ~astiob > upreckon > hgweb
comparison 2.00/testcases.py @ 16:f2279b7602d3
Initial 2.00 commit
| author | Oleg Oshmyan <chortos@inbox.lv> | 
|---|---|
| date | Mon, 07 Jun 2010 23:36:52 +0000 | 
| parents | |
| children | ec6f1a132109 | 
   comparison
  equal
  deleted
  inserted
  replaced
| 15:c0e925ae721e | 16:f2279b7602d3 | 
|---|---|
| 1 #!/usr/bin/python | |
| 2 # Copyright (c) 2010 Chortos-2 <chortos@inbox.lv> | |
| 3 | |
| 4 try: | |
| 5 import files as _files, problem as _problem | |
| 6 except ImportError as e: | |
| 7 import __main__ | |
| 8 __main__.import_error(e) | |
| 9 | |
| 10 class TestCase(object): | |
| 11 __slots__ = 'problem', 'infile', 'outfile' | |
| 12 | |
| 13 def __init__(case, prob, infile, outfile): | |
| 14 case.problem = prob | |
| 15 case.infile = infile | |
| 16 case.outfile = outfile | |
| 17 | |
| 18 def __call__(case): | |
| 19 os.copy() | |
| 20 | |
| 21 def load_problem(prob): | |
| 22 if prob.config.usegroups: | |
| 23 pass | |
| 24 else: | |
| 25 for i in prob.config.tests: | |
| 26 s = str(i).zfill(prob.config.padwithzeroestolength) | |
| 27 prob.cache.padoutputtolength = max(prob.cache.padoutputtolength, len(s)) | |
| 28 infile = _files.TestCaseFile(prob, prob.config.testcaseinname.replace('$', s)) | |
| 29 if infile: | |
| 30 if prob.config.kind != _problem.BATCH: | |
| 31 yield TestCase(prob, infile, None) | |
| 32 else: | |
| 33 outfile = _files.TestCaseFile(prob, prob.config.testcaseoutname.replace('$', s)) | |
| 34 if outfile: | |
| 35 yield TestCase(prob, infile, outfile) | 
