conftest.py 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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. (
  28. {
  29. 'store_size': True
  30. }
  31. ),
  32. (
  33. {
  34. 'store_size': False
  35. }
  36. ),
  37. ]
  38. )
  39. def store_size(request):
  40. return request.param
  41. @pytest.fixture(
  42. params=[
  43. (
  44. {
  45. 'return_bytearray': True
  46. }
  47. ),
  48. (
  49. {
  50. 'return_bytearray': False
  51. }
  52. ),
  53. ]
  54. )
  55. def return_bytearray(request):
  56. return request.param
  57. @pytest.fixture
  58. def c_return_bytearray(return_bytearray):
  59. return return_bytearray
  60. @pytest.fixture
  61. def d_return_bytearray(return_bytearray):
  62. return return_bytearray
  63. @pytest.fixture(
  64. params=[
  65. ('fast', None)
  66. ] + [
  67. ('fast', {'acceleration': s}) for s in range(10)
  68. ] + [
  69. ('high_compression', None)
  70. ] + [
  71. ('high_compression', {'compression': s}) for s in range(17)
  72. ] + [
  73. (None, None)
  74. ]
  75. )
  76. def mode(request):
  77. return request.param
  78. dictionary = [
  79. None,
  80. (0, 0),
  81. (100, 200),
  82. (0, 8 * 1024),
  83. os.urandom(8 * 1024)
  84. ]
  85. @pytest.fixture(
  86. params=dictionary,
  87. ids=[
  88. 'dictionary' + str(i) for i in range(len(dictionary))
  89. ]
  90. )
  91. def dictionary(request):
  92. return request.param