test_api.py 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. "guess_datetime_format",
  54. "add_overflowsafe",
  55. "get_supported_dtype",
  56. "is_supported_dtype",
  57. ]
  58. expected = set(submodules + api)
  59. names = [x for x in dir(tslibs) if not x.startswith("__")]
  60. assert set(names) == expected