Skip to content

Commit edaf999

Browse files
committed
add qset regression tests
1 parent 7ea3432 commit edaf999

File tree

5 files changed

+55
-0
lines changed

5 files changed

+55
-0
lines changed

pyth/__init__.py

Whitespace-only changes.

pyth/tests/__init__.py

Whitespace-only changes.

pyth/tests/qset/1.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"exponent": -3,
3+
"quotes": [
4+
{
5+
"price": 10000,
6+
"conf": 1000
7+
},
8+
{
9+
"price": 10000,
10+
"conf": 1000
11+
},
12+
{
13+
"price": 10000,
14+
"conf": 1000
15+
}
16+
]
17+
}

pyth/tests/qset/1.result

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"exponent":-3,"price":10000,"conf":1000}

pyth/tests/test_qset.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
from __future__ import absolute_import
2+
3+
import os
4+
from glob import glob
5+
from subprocess import check_output
6+
7+
_this_path = os.path.abspath(__file__)
8+
_this_dir = os.path.dirname(_this_path)
9+
10+
11+
def _get_test_class():
12+
13+
test_folder = os.path.join(_this_dir, 'qset')
14+
15+
class TestQset(object):
16+
17+
def run_test(self, test_id):
18+
test_file = os.path.join(test_folder, '%s.json' % (test_id,))
19+
output = check_output(['test_qset', test_file])
20+
output = output.decode()
21+
reg_file = os.path.join(test_folder, '%s.result' % (test_id,))
22+
with open(reg_file, 'r') as f:
23+
reg_output = f.read()
24+
assert output == reg_output
25+
26+
test_files = os.path.join(test_folder, '*.json')
27+
for test_file in glob(test_files):
28+
test_id = os.path.basename(test_file).rsplit('.')[0]
29+
30+
def test_func(self):
31+
self.run_test(test_id)
32+
setattr(TestQset, 'test_%s' % (test_id,), test_func)
33+
34+
return TestQset
35+
36+
37+
TestQset = _get_test_class()

0 commit comments

Comments
 (0)