Feature (contd.): Variable fields - filled in the placeholder with the actual test suite; some tests are failing - need to fix the code
This commit is contained in:
parent
60c47c34a1
commit
4093e52d48
55
test/harness.py
Normal file
55
test/harness.py
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
#! /usr/bin/env python
|
||||||
|
|
||||||
|
class Test:
|
||||||
|
pass
|
||||||
|
|
||||||
|
class TestSuite:
|
||||||
|
def __init__(self):
|
||||||
|
self.results = []
|
||||||
|
self.total = 0
|
||||||
|
self.passed = 0
|
||||||
|
self.completed = False
|
||||||
|
|
||||||
|
def test_begin(self, name):
|
||||||
|
test = Test()
|
||||||
|
test.name = name
|
||||||
|
test.passed = False
|
||||||
|
self.running = test
|
||||||
|
print('-----------------------------------------------------------')
|
||||||
|
print('@@TEST: %s' % name)
|
||||||
|
print('-----------------------------------------------------------')
|
||||||
|
|
||||||
|
def test_end(self, result):
|
||||||
|
if self.running:
|
||||||
|
self.running.passed = result
|
||||||
|
self.results.append(self.running)
|
||||||
|
self.total = self.total + 1
|
||||||
|
if result:
|
||||||
|
self.passed = self.passed + 1
|
||||||
|
self.running = None
|
||||||
|
print('@@RESULT: %s' % ('PASS' if result else 'FAIL'))
|
||||||
|
else:
|
||||||
|
raise Exception('Test end without a test begin')
|
||||||
|
|
||||||
|
def report(self):
|
||||||
|
print('===========================================================')
|
||||||
|
print('TEST REPORT')
|
||||||
|
print('===========================================================')
|
||||||
|
for test in self.results:
|
||||||
|
print('%d: %s' % (test.passed, test.name))
|
||||||
|
print('Passed: %d/%d' % (self.passed, self.total))
|
||||||
|
print('Completed: %d' % (self.completed))
|
||||||
|
|
||||||
|
def complete(self):
|
||||||
|
self.completed = True
|
||||||
|
|
||||||
|
def passed(self):
|
||||||
|
return passed == total and self.completed
|
||||||
|
|
||||||
|
def extract_column(text, col):
|
||||||
|
"""Given a text table, return items in the specified column as a list"""
|
||||||
|
lines = text.splitlines()
|
||||||
|
cols = []
|
||||||
|
for line in lines:
|
||||||
|
cols.append(line.split(None, col)[col-1])
|
||||||
|
return cols
|
957
test/vftest.py
957
test/vftest.py
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user