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
|
import unittest
from scilab import Scilab
import sciscipy
class test_call(unittest.TestCase):
def setUp(self):
self.sci = Scilab()
def test_spec(self):
""" [test_call] Testing spec
"""
spec1 = self.sci.spec([[1, 2],[3, 4]])
sciscipy.eval("spec1 = spec([1,2;3,4])")
spec2 = sciscipy.read("spec1")
for l1, l2 in zip(spec1, spec2):
self.assertAlmostEqual(l1, l2)
def test_mean(self):
""" [test_call] Testing mean
"""
mean1 = self.sci.mean([[1, 2],[3, 4]])
sciscipy.eval("mean1 = mean([1,2;3,4])")
mean2 = sciscipy.read("mean1")
comp = mean1 == mean2
assert(comp)
def test_strcat(self):
""" [test_call] Testing strcat
"""
strcat1 = self.sci.strcat(["1", "4"], "x")
sciscipy.eval("strcat1 = strcat(['1', '4'], 'x')")
strcat2 = sciscipy.read("strcat1")
comp = strcat1 == strcat2
assert(comp)
def test_length(self):
""" [test_call] Testing length
"""
strlength1 = self.sci.length(["3ch","5char","plenty of char"])
sciscipy.eval("strlength = length(['3ch','5char','plenty of char'])")
strlength2 = sciscipy.read("strlength")
for l1, l2 in zip(strlength1, strlength2):
self.assertEquals(l1, l2)
if __name__ == '__main__':
unittest.main()
|