1 |
schorsch |
1.1 |
|
2 |
|
|
import os |
3 |
|
|
import math |
4 |
|
|
import string |
5 |
|
|
import unittest |
6 |
|
|
|
7 |
|
|
from unit_tools import support |
8 |
|
|
from unit_tools import lcompare |
9 |
|
|
|
10 |
|
|
class GenbeadsTestCase(unittest.TestCase): |
11 |
|
|
def setUp(self): |
12 |
|
|
self.oldpath = os.environ['PATH'] |
13 |
|
|
os.environ['PATH'] = os.path.abspath(support.BINDIR) |
14 |
|
|
|
15 |
|
|
def tearDown(self): |
16 |
|
|
os.environ['PATH'] = self.oldpath |
17 |
|
|
|
18 |
|
|
def test_genbeads(self): |
19 |
|
|
cmd = 'genbeads mymat myname 0 0 0 1 1 1 2 0 0 0 2 0 .1 .4' |
20 |
|
|
raw = os.popen(cmd).read() |
21 |
|
|
result = map(string.split,string.split(raw,'\n')) |
22 |
|
|
expect = [['mymat', 'sphere', 'myname.0'], [0], [0], |
23 |
|
|
[4, 0, 0, 0, 0.1], |
24 |
|
|
['mymat', 'sphere', 'myname.1'], [0], [0], |
25 |
|
|
[4, 0.36, 0.04, 0.104, 0.1], |
26 |
|
|
['mymat', 'sphere', 'myname.2'], [0], [0], |
27 |
|
|
[4, 0.651440715413, 0.167781092737, 0.365893348046, 0.1], |
28 |
|
|
['mymat', 'sphere', 'myname.3'], [0], [0], |
29 |
|
|
[4, 0.844350245496, 0.366600314978, 0.655866088042, 0.1], |
30 |
|
|
['mymat', 'sphere', 'myname.4'], [0], [0], |
31 |
|
|
[4, 0.960791445178, 0.643185551339, 0.897901825177, 0.1], |
32 |
|
|
] |
33 |
|
|
try: lcompare.llcompare(result, expect, ignore_empty=1) |
34 |
|
|
except lcompare.error, e: |
35 |
|
|
self.fail('%s [%s]' % (str(e),cmd)) |
36 |
|
|
|
37 |
|
|
|
38 |
|
|
def main(): |
39 |
|
|
support.run_case(GenbeadsTestCase) |
40 |
|
|
|
41 |
|
|
if __name__ == '__main__': |
42 |
|
|
main() |
43 |
|
|
|
44 |
|
|
# vi: set ts=4 sw=4 : |