conftest.py 2.5 KB

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