-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheck3.py
74 lines (57 loc) · 1.24 KB
/
check3.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
63
64
65
66
67
68
69
70
71
72
73
74
import bison
import numpy
import os
alist = [4,5,(6,),[8,9+3j]]
atuple = (4,5,(6,))
array = numpy.arange(32**4).astype('i4')
astr = 'hello there'
afl = 3.14
arange = range(4,127,3)
numpys = [numpy.int32(32), numpy.int64(64)]
all = [alist, atuple, atuple, array, astr, afl, arange, numpys]
f = bison.FILE('test3', mode='w')
k = 0
for field in all:
f.write(f'tag{k}', field)
k+=1
f.close(dest='test33')
f2 = bison.FILE('test3', mode='r')
res = f2.read()
k=0
for field in all:
assert numpy.all(field == res[f'tag{k}'])
k+=1
f3 = bison.FILE('test33',mode='r')
res = f3.read()
k=0
for field in all:
assert numpy.all(field == res[f'tag{k}'])
k+=1
f3.close()
try:
bison.FILE('test3', mode='w')
except bison.BisonError:
print('error caugth')
try:
bison.FILE('test333', mode='r')
except bison.BisonError:
print('error caugth')
try:
bison.FILE('test333', mode='read')
except bison.BisonError:
print('error caugth')
try:
f.read()
except bison.BisonError:
print('error caugth')
try:
f2.write('pi',3.14)
except bison.BisonError:
print('error caugth')
try:
f.write('tag0', 3.14)
except bison.BisonError:
print('error caugth')
f.close()
f2.close()
os.popen('rm test3 test33')