[802d3e]: runtest / testobj.py  Maximize  Restore  History

Download this file

70 lines (55 with data), 2.0 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import string
import runtest
# Test object contains a test identifier and an associated command
# line. The constructor is passed a string which contains an id
# token followed by the tokens of the command line of the test.
# TestNoObjectError is raised when the line is blank or contains only
# comments.
# TestBadObjectError is raised when there are not two tokens in the
# line: id & cmd
class test:
TestNoObjectError = 'Failed attempt to create test object with no information'
TestBadObjectError = 'Failed attempt to create test object with incomplete information'
def __init__(self, t_line):
l_line = string.strip(t_line)
# look for comments
cmt_start=string.find(l_line,'#')
if cmt_start != -1:
l_line = l_line[:cmt_start]
l_line = string.strip(l_line)
if l_line == '':
raise test.TestNoObjectError
self.d_name = string.split(l_line)[0]
self.d_cmd = string.join(string.split(l_line)[1:])
if self.d_name == '' or self.d_cmd == '':
raise test.TestBadObjectError
def name(self):
return self.d_name
def command(self):
return self.d_cmd
def __cmp__(self,other):
if type(other) == type(self.d_name):
return cmp(self.d_name,other)
else:
return cmp(self.d_name,other.d_name)
# test_list is a class which is intended to contain a list of the test objects.
# The test object ids must be unique, otherwise a TestNameExistsError exception
# is thrown.
class test_list:
TestNameExistsError = 'Attempt to add test object with duplicate id'
def __init__(self):
self.d_testlist = []
def add(self, a_tobj):
for obj in self.d_testlist:
if obj == a_tobj:
raise test_list.TestNameExistsError, a_tobj.name()
self.d_testlist.append(a_tobj)
def echo(self):
for obj in self.d_testlist:
print "%s %s" % \
(obj.name(),obj.command())
def run(self):
exit_report=0
for obj in self.d_testlist:
exit_report = exit_report | runtest.execute(obj.name(),obj.command())
return exit_report

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks