test_datetimelike.py 991 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. """ generic tests from the Datetimelike class """
  2. import pytest
  3. from pandas import (
  4. DatetimeIndex,
  5. date_range,
  6. )
  7. import pandas._testing as tm
  8. from pandas.tests.indexes.datetimelike import DatetimeLike
  9. class TestDatetimeIndex(DatetimeLike):
  10. _index_cls = DatetimeIndex
  11. @pytest.fixture
  12. def simple_index(self) -> DatetimeIndex:
  13. return date_range("20130101", periods=5)
  14. @pytest.fixture(
  15. params=[tm.makeDateIndex(10), date_range("20130110", periods=10, freq="-1D")],
  16. ids=["index_inc", "index_dec"],
  17. )
  18. def index(self, request):
  19. return request.param
  20. def test_format(self, simple_index):
  21. # GH35439
  22. idx = simple_index
  23. expected = [f"{x:%Y-%m-%d}" for x in idx]
  24. assert idx.format() == expected
  25. def test_shift(self):
  26. pass # handled in test_ops
  27. def test_intersection(self):
  28. pass # handled in test_setops
  29. def test_union(self):
  30. pass # handled in test_setops