view 2.00/testcases.py @ 19:d4fc9341664e 1.20.2

Fixed an exception when tests.zip contained test cases in its root
author Oleg Oshmyan <chortos@inbox.lv>
date Sun, 13 Jun 2010 12:46:49 +0000
parents f2279b7602d3
children ec6f1a132109
line wrap: on
line source

#!/usr/bin/python
# Copyright (c) 2010 Chortos-2 <chortos@inbox.lv>

try:
	import files as _files, problem as _problem
except ImportError as e:
	import __main__
	__main__.import_error(e)

class TestCase(object):
	__slots__ = 'problem', 'infile', 'outfile'
	
	def __init__(case, prob, infile, outfile):
		case.problem = prob
		case.infile = infile
		case.outfile = outfile
	
	def __call__(case):
		os.copy()

def load_problem(prob):
	if prob.config.usegroups:
		pass
	else:
		for i in prob.config.tests:
			s = str(i).zfill(prob.config.padwithzeroestolength)
			prob.cache.padoutputtolength = max(prob.cache.padoutputtolength, len(s))
			infile = _files.TestCaseFile(prob, prob.config.testcaseinname.replace('$', s))
			if infile:
				if prob.config.kind != _problem.BATCH:
					yield TestCase(prob, infile, None)
				else:
					outfile = _files.TestCaseFile(prob, prob.config.testcaseoutname.replace('$', s))
					if outfile:
						yield TestCase(prob, infile, outfile)