test_libfrequencies.py 769 B

1234567891011121314151617181920212223242526272829
  1. import pytest
  2. from pandas._libs.tslibs.parsing import get_rule_month
  3. from pandas.tseries import offsets
  4. @pytest.mark.parametrize(
  5. "obj,expected",
  6. [
  7. ("W", "DEC"),
  8. (offsets.Week().freqstr, "DEC"),
  9. ("D", "DEC"),
  10. (offsets.Day().freqstr, "DEC"),
  11. ("Q", "DEC"),
  12. (offsets.QuarterEnd(startingMonth=12).freqstr, "DEC"),
  13. ("Q-JAN", "JAN"),
  14. (offsets.QuarterEnd(startingMonth=1).freqstr, "JAN"),
  15. ("A-DEC", "DEC"),
  16. ("Y-DEC", "DEC"),
  17. (offsets.YearEnd().freqstr, "DEC"),
  18. ("A-MAY", "MAY"),
  19. ("Y-MAY", "MAY"),
  20. (offsets.YearEnd(month=5).freqstr, "MAY"),
  21. ],
  22. )
  23. def test_get_rule_month(obj, expected):
  24. result = get_rule_month(obj)
  25. assert result == expected