dateutil / dateutil
1 20
import sys
2 20
import unittest
3

4 20
class ImportVersionTest(unittest.TestCase):
5
    """ Test that dateutil.__version__ can be imported"""
6

7 20
    def testImportVersionStr(self):
8 20
        from dateutil import __version__
9

10 20
    def testImportRoot(self):
11 20
        import dateutil
12

13 20
        self.assertTrue(hasattr(dateutil, '__version__'))
14

15

16 20
class ImportEasterTest(unittest.TestCase):
17
    """ Test that dateutil.easter-related imports work properly """
18

19 20
    def testEasterDirect(self):
20 20
        import dateutil.easter
21

22 20
    def testEasterFrom(self):
23 20
        from dateutil import easter
24

25 20
    def testEasterStar(self):
26 20
        from dateutil.easter import easter
27

28

29 20
class ImportParserTest(unittest.TestCase):
30
    """ Test that dateutil.parser-related imports work properly """
31 20
    def testParserDirect(self):
32 20
        import dateutil.parser
33

34 20
    def testParserFrom(self):
35 20
        from dateutil import parser
36

37 20
    def testParserAll(self):
38
        # All interface
39 20
        from dateutil.parser import parse
40 20
        from dateutil.parser import parserinfo
41

42
        # Other public classes
43 20
        from dateutil.parser import parser
44

45 20
        for var in (parse, parserinfo, parser):
46 20
            self.assertIsNot(var, None)
47

48

49 20
class ImportRelativeDeltaTest(unittest.TestCase):
50
    """ Test that dateutil.relativedelta-related imports work properly """
51 20
    def testRelativeDeltaDirect(self):
52 20
        import dateutil.relativedelta
53

54 20
    def testRelativeDeltaFrom(self):
55 20
        from dateutil import relativedelta
56

57 20
    def testRelativeDeltaAll(self):
58 20
        from dateutil.relativedelta import relativedelta
59 20
        from dateutil.relativedelta import MO, TU, WE, TH, FR, SA, SU
60

61 20
        for var in (relativedelta, MO, TU, WE, TH, FR, SA, SU):
62 20
            self.assertIsNot(var, None)
63

64
        # In the public interface but not in all
65 20
        from dateutil.relativedelta import weekday
66 20
        self.assertIsNot(weekday, None)
67

68

69 20
class ImportRRuleTest(unittest.TestCase):
70
    """ Test that dateutil.rrule related imports work properly """
71 20
    def testRRuleDirect(self):
72 20
        import dateutil.rrule
73

74 20
    def testRRuleFrom(self):
75 20
        from dateutil import rrule
76

77 20
    def testRRuleAll(self):
78 20
        from dateutil.rrule import rrule
79 20
        from dateutil.rrule import rruleset
80 20
        from dateutil.rrule import rrulestr
81 20
        from dateutil.rrule import YEARLY, MONTHLY, WEEKLY, DAILY
82 20
        from dateutil.rrule import HOURLY, MINUTELY, SECONDLY
83 20
        from dateutil.rrule import MO, TU, WE, TH, FR, SA, SU
84

85 20
        rr_all = (rrule, rruleset, rrulestr,
86
                  YEARLY, MONTHLY, WEEKLY, DAILY,
87
                  HOURLY, MINUTELY, SECONDLY,
88
                  MO, TU, WE, TH, FR, SA, SU)
89

90 20
        for var in rr_all:
91 20
            self.assertIsNot(var, None)
92

93
        # In the public interface but not in all
94 20
        from dateutil.rrule import weekday
95 20
        self.assertIsNot(weekday, None)
96

97

98 20
class ImportTZTest(unittest.TestCase):
99
    """ Test that dateutil.tz related imports work properly """
100 20
    def testTzDirect(self):
101 20
        import dateutil.tz
102

103 20
    def testTzFrom(self):
104 20
        from dateutil import tz
105

106 20
    def testTzAll(self):
107 20
        from dateutil.tz import tzutc
108 20
        from dateutil.tz import tzoffset
109 20
        from dateutil.tz import tzlocal
110 20
        from dateutil.tz import tzfile
111 20
        from dateutil.tz import tzrange
112 20
        from dateutil.tz import tzstr
113 20
        from dateutil.tz import tzical
114 20
        from dateutil.tz import gettz
115 20
        from dateutil.tz import tzwin
116 20
        from dateutil.tz import tzwinlocal
117 20
        from dateutil.tz import UTC
118 20
        from dateutil.tz import datetime_ambiguous
119 20
        from dateutil.tz import datetime_exists
120 20
        from dateutil.tz import resolve_imaginary
121

122 20
        tz_all = ["tzutc", "tzoffset", "tzlocal", "tzfile", "tzrange",
123
                  "tzstr", "tzical", "gettz", "datetime_ambiguous",
124
                  "datetime_exists", "resolve_imaginary", "UTC"]
125

126 20
        tz_all += ["tzwin", "tzwinlocal"] if sys.platform.startswith("win") else []
127 20
        lvars = locals()
128

129 20
        for var in tz_all:
130 20
            self.assertIsNot(lvars[var], None)
131

132 20
@unittest.skipUnless(sys.platform.startswith('win'), "Requires Windows")
133 20
class ImportTZWinTest(unittest.TestCase):
134
    """ Test that dateutil.tzwin related imports work properly """
135 20
    def testTzwinDirect(self):
136 9
        import dateutil.tzwin
137

138 20
    def testTzwinFrom(self):
139 9
        from dateutil import tzwin
140

141 20
    def testTzwinStar(self):
142 9
        from dateutil.tzwin import tzwin
143 9
        from dateutil.tzwin import tzwinlocal
144

145 9
        tzwin_all = [tzwin, tzwinlocal]
146

147 9
        for var in tzwin_all:
148 9
            self.assertIsNot(var, None)
149

150

151 20
class ImportZoneInfoTest(unittest.TestCase):
152 20
    def testZoneinfoDirect(self):
153 20
        import dateutil.zoneinfo
154

155 20
    def testZoneinfoFrom(self):
156 20
        from dateutil import zoneinfo
157

158 20
    def testZoneinfoStar(self):
159 20
        from dateutil.zoneinfo import gettz
160 20
        from dateutil.zoneinfo import gettz_db_metadata
161 20
        from dateutil.zoneinfo import rebuild
162

163 20
        zi_all = (gettz, gettz_db_metadata, rebuild)
164

165 20
        for var in zi_all:
166 20
            self.assertIsNot(var, None)

Read our documentation on viewing source code .

Loading