Skip to content

Commit fc284ca

Browse files
committed
add twap test
1 parent a038694 commit fc284ca

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed

pyth/tests/test_twap.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, 'twap')
14+
15+
class TestQset(object):
16+
17+
def run_test(self, test_id):
18+
test_file = os.path.join(test_folder, '%s.csv' % (test_id,))
19+
output = check_output(['test_twap', 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, '*.csv')
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()
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)