Debian Codegraph @

tests/stream/conftest.py

raw symbols SCIP
1 import pytest
2 import os
3 import sys
4
5 test_data = [
6 (b''),
7 (os.urandom(8 * 1024)),
8 # (b'0' * 8 * 1024),
9 # (bytearray(b'')),
10 # (bytearray(os.urandom(8 * 1024))),
11 (bytearray(open(os.path.join(os.path.dirname(__file__), 'numpy_byte_array.bin'), 'rb').read()))
12 ]
13
14 if sys.version_info > (2, 7):
15 test_data += [
16 (memoryview(b'')),
17 (memoryview(os.urandom(8 * 1024)))
18 ]
19
20
21 @pytest.fixture(
22 params=test_data,
23 ids=[
24 'data' + str(i) for i in range(len(test_data))
25 ]
26 )
27 def data(request):
28 return request.param
29
30
31 @pytest.fixture(
32 params=[
33 ("double_buffer"),
34 # ("ring_buffer"), # not implemented
35 ]
36 )
37 def strategy(request):
38 return request.param
39
40
41 test_buffer_size = sorted(
42 [1,
43 # 4,
44 # 8,
45 # 64,
46 # 256,
47 941,
48 # 1 * 1024,
49 # 4 * 1024,
50 # 8 * 1024,
51 # 16 * 1024,
52 # 32 * 1024,
53 64 * 1024,
54 # 128 * 1024
55 ]
56 )
57
58
59 @pytest.fixture(
60 params=test_buffer_size,
61 ids=[
62 'buffer_size' + str(i) for i in range(len(test_buffer_size))
63 ]
64 )
65 def buffer_size(request):
66 return request.param
67
68
69 @pytest.fixture(
70 params=[
71 (
72 {
73 'store_comp_size': 1
74 }
75 ),
76 (
77 {
78 'store_comp_size': 2
79 }
80 ),
81 # (
82 # {
83 # 'store_comp_size': 4
84 # }
85 # ),
86 ]
87 )
88 def store_comp_size(request):
89 return request.param
90
91
92 @pytest.fixture(
93 params=[
94 (
95 {
96 'return_bytearray': True
97 }
98 ),
99 (
100 {
101 'return_bytearray': False
102 }
103 ),
104 ]
105 )
106 def return_bytearray(request):
107 return request.param
108
109
110 @pytest.fixture
111 def c_return_bytearray(return_bytearray):
112 return return_bytearray
113
114
115 @pytest.fixture
116 def d_return_bytearray(return_bytearray):
117 return return_bytearray
118
119
120 @pytest.fixture(
121 params=[
122 ('default', None)
123 ] + [
124 ('fast', None)
125 ] + [
126 ('fast', {'acceleration': 2 * s}) for s in range(5)
127 ] + [
128 ('high_compression', None)
129 ] + [
130 ('high_compression', {'compression_level': 2 * s}) for s in range(9)
131 ] + [
132 (None, None)
133 ]
134 )
135 def mode(request):
136 return request.param
137
138
139 dictionary = [
140 None,
141 (0, 0),
142 (100, 200),
143 (0, 8 * 1024),
144 os.urandom(8 * 1024)
145 ]
146
147
148 @pytest.fixture(
149 params=dictionary,
150 ids=[
151 'dictionary' + str(i) for i in range(len(dictionary))
152 ]
153 )
154 def dictionary(request):
155 return request.param