-
Notifications
You must be signed in to change notification settings - Fork 556
/
Parameter.py
62 lines (54 loc) · 1.86 KB
/
Parameter.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/usr/bin/python
# -*- coding: utf8 -*-
# gb18030
#===============================================================================
# 作者:fasiondog
# 历史:1)20130220, Added by fasiondog
#===============================================================================
from test_init import *
import unittest
from hikyuu import Parameter
class ParameterTest(unittest.TestCase):
def test_Parameter(self):
p = Parameter()
self.assertEqual("n" in p, False)
self.assertEqual("b" in p, False)
self.assertEqual("d" in p, False)
self.assertEqual("s" in p, False)
p["n"] = 10
p["b"] = True
p["d"] = 10.01
p["s"] = "string"
self.assertEqual("n" in p, True)
self.assertEqual("b" in p, True)
self.assertEqual("d" in p, True)
self.assertEqual("s" in p, True)
self.assertEqual(p["n"], 10)
self.assertEqual(p["b"], True)
self.assertEqual(p["d"], 10.01)
self.assertEqual(p["s"], "string")
p["n"] = 20
p["b"] = False
p["d"] = 10.001
p["s"] = "string2"
self.assertEqual(p["n"], 20)
self.assertEqual(p["b"], False)
self.assertEqual(p["d"], 10.001)
self.assertEqual(p["s"], "string2")
# def test_pickle(self):
# if not constant.pickle_support:
# return
# tmpdir = sm.tmpdir()
# fh = open(tmpdir + "/Parameter.plk", "wb")
# a = Parameter()
# a["bool"] = True
# a["string"] = "This is Parameter"
# import pickle as pl
# pl.dump(a, fh)
# fh.close()
# fh = open(tmpdir + "/Parameter.plk", "rb")
# b = pl.load(fh)
# self.assertEqual(b["bool"], True)
# self.assertEqual(b["string"], "This is Parameter")
def suite():
return unittest.TestLoader().loadTestsFromTestCase(ParameterTest)