test_idatetime.py 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. ##############################################################################
  2. #
  3. # Copyright (c) 2003 Zope Foundation and Contributors.
  4. # All Rights Reserved.
  5. #
  6. # This software is subject to the provisions of the Zope Public License,
  7. # Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
  8. # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
  9. # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  10. # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
  11. # FOR A PARTICULAR PURPOSE.
  12. #
  13. ##############################################################################
  14. """Test for datetime interfaces
  15. """
  16. import unittest
  17. from zope.interface.verify import verifyObject, verifyClass
  18. from zope.interface.common.idatetime import ITimeDelta, ITimeDeltaClass
  19. from zope.interface.common.idatetime import IDate, IDateClass
  20. from zope.interface.common.idatetime import IDateTime, IDateTimeClass
  21. from zope.interface.common.idatetime import ITime, ITimeClass, ITZInfo
  22. from datetime import timedelta, date, datetime, time, tzinfo
  23. class TestDateTimeInterfaces(unittest.TestCase):
  24. def test_interfaces(self):
  25. verifyObject(ITimeDelta, timedelta(minutes=20))
  26. verifyObject(IDate, date(2000, 1, 2))
  27. verifyObject(IDateTime, datetime(2000, 1, 2, 10, 20))
  28. verifyObject(ITime, time(20, 30, 15, 1234))
  29. verifyObject(ITZInfo, tzinfo())
  30. verifyClass(ITimeDeltaClass, timedelta)
  31. verifyClass(IDateClass, date)
  32. verifyClass(IDateTimeClass, datetime)
  33. verifyClass(ITimeClass, time)