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

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

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

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

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

15

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

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

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

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

28

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

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

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

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

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

48

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

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

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

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

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

68

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

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

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

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

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

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

97

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

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

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

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

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

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

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

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

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

145 2
        tzwin_all = [tzwin, tzwinlocal]
146

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

150

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

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

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

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

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

Read our documentation on viewing source code .

Loading