conftest.py 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. import operator
  2. import pytest
  3. @pytest.fixture
  4. def dtype():
  5. """A fixture providing the ExtensionDtype to validate."""
  6. raise NotImplementedError
  7. @pytest.fixture
  8. def data():
  9. """Length-100 array for this type.
  10. * data[0] and data[1] should both be non missing
  11. * data[0] and data[1] should not gbe equal
  12. """
  13. raise NotImplementedError
  14. @pytest.fixture
  15. def data_missing():
  16. """Length-2 array with [NA, Valid]"""
  17. raise NotImplementedError
  18. @pytest.fixture(params=['data', 'data_missing'])
  19. def all_data(request, data, data_missing):
  20. """Parametrized fixture giving 'data' and 'data_missing'"""
  21. if request.param == 'data':
  22. return data
  23. elif request.param == 'data_missing':
  24. return data_missing
  25. @pytest.fixture
  26. def data_repeated(data):
  27. """
  28. Generate many datasets.
  29. Parameters
  30. ----------
  31. data : fixture implementing `data`
  32. Returns
  33. -------
  34. Callable[[int], Generator]:
  35. A callable that takes a `count` argument and
  36. returns a generator yielding `count` datasets.
  37. """
  38. def gen(count):
  39. for _ in range(count):
  40. yield data
  41. return gen
  42. @pytest.fixture
  43. def data_for_sorting():
  44. """Length-3 array with a known sort order.
  45. This should be three items [B, C, A] with
  46. A < B < C
  47. """
  48. raise NotImplementedError
  49. @pytest.fixture
  50. def data_missing_for_sorting():
  51. """Length-3 array with a known sort order.
  52. This should be three items [B, NA, A] with
  53. A < B and NA missing.
  54. """
  55. raise NotImplementedError
  56. @pytest.fixture
  57. def na_cmp():
  58. """Binary operator for comparing NA values.
  59. Should return a function of two arguments that returns
  60. True if both arguments are (scalar) NA for your type.
  61. By default, uses ``operator.is_``
  62. """
  63. return operator.is_
  64. @pytest.fixture
  65. def na_value():
  66. """The scalar missing value for this type. Default 'None'"""
  67. return None
  68. @pytest.fixture
  69. def data_for_grouping():
  70. """Data for factorization, grouping, and unique tests.
  71. Expected to be like [B, B, NA, NA, A, A, B, C]
  72. Where A < B < C and NA is missing
  73. """
  74. raise NotImplementedError
  75. @pytest.fixture(params=[True, False])
  76. def box_in_series(request):
  77. """Whether to box the data in a Series"""
  78. return request.param