test_api.py 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. """Tests that the tslibs API is locked down"""
  2. from pandas._libs import tslibs
  3. def test_namespace():
  4. submodules = [
  5. "base",
  6. "ccalendar",
  7. "conversion",
  8. "dtypes",
  9. "fields",
  10. "nattype",
  11. "np_datetime",
  12. "offsets",
  13. "parsing",
  14. "period",
  15. "strptime",
  16. "vectorized",
  17. "timedeltas",
  18. "timestamps",
  19. "timezones",
  20. "tzconversion",
  21. ]
  22. api = [
  23. "BaseOffset",
  24. "NaT",
  25. "NaTType",
  26. "iNaT",
  27. "nat_strings",
  28. "OutOfBoundsDatetime",
  29. "OutOfBoundsTimedelta",
  30. "Period",
  31. "IncompatibleFrequency",
  32. "Resolution",
  33. "Tick",
  34. "Timedelta",
  35. "dt64arr_to_periodarr",
  36. "Timestamp",
  37. "is_date_array_normalized",
  38. "ints_to_pydatetime",
  39. "normalize_i8_timestamps",
  40. "get_resolution",
  41. "delta_to_nanoseconds",
  42. "ints_to_pytimedelta",
  43. "localize_pydatetime",
  44. "tz_convert_from_utc",
  45. "tz_convert_from_utc_single",
  46. "to_offset",
  47. "tz_compare",
  48. "is_unitless",
  49. "astype_overflowsafe",
  50. "get_unit_from_dtype",
  51. "periods_per_day",
  52. "periods_per_second",
  53. "is_supported_unit",
  54. "get_supported_reso",
  55. "npy_unit_to_abbrev",
  56. ]
  57. expected = set(submodules + api)
  58. names = [x for x in dir(tslibs) if not x.startswith("__")]
  59. assert set(names) == expected