Imported Upstream version 3.8.0
[contrib/python-zope.interface.git] / src / zope / interface / common / tests / test_idatetime.py
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
17 import unittest
18
19 from zope.interface.verify import verifyObject, verifyClass
20 from zope.interface.common.idatetime import ITimeDelta, ITimeDeltaClass
21 from zope.interface.common.idatetime import IDate, IDateClass
22 from zope.interface.common.idatetime import IDateTime, IDateTimeClass
23 from zope.interface.common.idatetime import ITime, ITimeClass, ITZInfo
24 from datetime import timedelta, date, datetime, time, tzinfo
25
26 class TestDateTimeInterfaces(unittest.TestCase):
27
28     def test_interfaces(self):
29         verifyObject(ITimeDelta, timedelta(minutes=20))
30         verifyObject(IDate, date(2000, 1, 2))
31         verifyObject(IDateTime, datetime(2000, 1, 2, 10, 20))
32         verifyObject(ITime, time(20, 30, 15, 1234))
33         verifyObject(ITZInfo, tzinfo())
34         verifyClass(ITimeDeltaClass, timedelta)
35         verifyClass(IDateClass, date)
36         verifyClass(IDateTimeClass, datetime)
37         verifyClass(ITimeClass, time)
38
39
40 def test_suite():
41     suite = unittest.TestSuite()
42     suite.addTest(unittest.makeSuite(TestDateTimeInterfaces))
43     return suite
44
45
46 if __name__ == '__main__':
47     unittest.main()