1import pytest
2import os
3import sys
4
5
6test_data = [
7    (b''),
8    (os.urandom(8 * 1024)),
9    (b'0' * 8 * 1024),
10    (bytearray(b'')),
11    (bytearray(os.urandom(8 * 1024))),
12    (bytearray(open(os.path.join(os.path.dirname(__file__), 'numpy_byte_array.bin'), 'rb').read()))
13]
14
15if sys.version_info > (2, 7):
16    test_data += [
17        (memoryview(b'')),
18        (memoryview(os.urandom(8 * 1024)))
19    ]
20
21
22@pytest.fixture(
23    params=test_data,
24    ids=[
25        'data' + str(i) for i in range(len(test_data))
26    ]
27)
28def data(request):
29    return request.param
30
31
32@pytest.fixture(
33    params=[
34        (
35            {
36                'store_size': True
37            }
38        ),
39        (
40            {
41                'store_size': False
42            }
43        ),
44    ]
45)
46def store_size(request):
47    return request.param
48
49
50@pytest.fixture(
51    params=[
52        (
53            {
54                'return_bytearray': True
55            }
56        ),
57        (
58            {
59                'return_bytearray': False
60            }
61        ),
62    ]
63)
64def return_bytearray(request):
65    return request.param
66
67
68@pytest.fixture
69def c_return_bytearray(return_bytearray):
70    return return_bytearray
71
72
73@pytest.fixture
74def d_return_bytearray(return_bytearray):
75    return return_bytearray
76
77
78@pytest.fixture(
79    params=[
80        ('fast', None)
81    ] + [
82        ('fast', {'acceleration': s}) for s in range(10)
83    ] + [
84        ('high_compression', None)
85    ] + [
86        ('high_compression', {'compression': s}) for s in range(17)
87    ] + [
88        (None, None)
89    ]
90)
91def mode(request):
92    return request.param
93
94
95dictionary = [
96    None,
97    (0, 0),
98    (100, 200),
99    (0, 8 * 1024),
100    os.urandom(8 * 1024)
101]
102
103
104@pytest.fixture(
105    params=dictionary,
106    ids=[
107        'dictionary' + str(i) for i in range(len(dictionary))
108    ]
109)
110def dictionary(request):
111    return request.param
112