-
Notifications
You must be signed in to change notification settings - Fork 556
/
StockTypeInfo.py
45 lines (38 loc) · 1.45 KB
/
StockTypeInfo.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/python
# -*- coding: utf8 -*-
# gb18030
#===============================================================================
# 作者:fasiondog
# 历史:1)20120927, Added by fasiondog
#===============================================================================
import unittest
from test_init import *
class StockTypeInfoTest(unittest.TestCase):
def test_stockType(self):
stockType = sm.getStockTypeInfo(1)
self.assertEqual(stockType.type, 1)
self.assertEqual(unicodeFunc(stockType.description), u"A股")
self.assertEqual(stockType.tick, 0.01)
self.assertEqual(stockType.tickValue, 0.01)
self.assertEqual(stockType.unit, 1.0)
self.assertEqual(stockType.precision, 2)
self.assertEqual(stockType.minTradeNumber, 100)
self.assertEqual(stockType.maxTradeNumber, 1000000)
def test_pickle(self):
if not constant.pickle_support:
return
#TODO: Python3 出错,暂未解决
"""import pickle as pl
filename = sm.tmpdir() + '/StockTypeInfo.plk'
a = sm.getStockTypeInfo(1)
fh = open(filename, 'wb')
pl.dump(a, fh)
fh.close()
fh = open(filename, 'rb')
b = pl.load(fh)
fh.close()
self.assertEqual(a.type, b.type)
self.assertEqual(a.description, b.description)
"""
def suite():
return unittest.TestLoader().loadTestsFromTestCase(StockTypeInfoTest)