view 2.00/testcases.py @ 17:dfe872cafbd0

$Rev: $ in test-svn.py 2.00 should now work
author Oleg Oshmyan <chortos@inbox.lv>
date Mon, 07 Jun 2010 23:38:13 +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)