-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_functional_tests.py
31 lines (25 loc) · 962 Bytes
/
run_functional_tests.py
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
import glob
import yaml
import cli
def functional_test():
for file in glob.glob('functional_tests/*.yml'):
with open(file, 'r') as fd:
suite = yaml.load(fd.read())
for idx, case in enumerate(suite):
if 'skip' in case and case['skip']:
continue
yield (FunctionalTestCase(file, idx, case),)
class FunctionalTestCase(object):
def __init__(self, file, idx, case):
self.case = case
self.description = '%s case %d: %s' % (file, idx, case)
def __call__(self):
output = cli.main(self.case['filter'], yaml.dump(self.case['input']))
if 'output' in self.case:
expected_list = [self.case['output']]
else:
expected_list = self.case['output_list']
for expected in expected_list:
actual = output.next()
print 'Actual: %s\nExpected: %s' % (actual, expected)
assert actual == expected