1 68
import sys
2 68
import unittest
3

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

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

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

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

15

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

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

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

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

28

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

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

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

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

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

48

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

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

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

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

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

68

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

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

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

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

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

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

97

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

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

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

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

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

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

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

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

141 68
    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 68
class ImportZoneInfoTest(unittest.TestCase):
152 68
    def testZoneinfoDirect(self):
153 68
        import dateutil.zoneinfo
154

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

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

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

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

Read our documentation on viewing source code .

Loading