File tree Expand file tree Collapse file tree 1 file changed +20
-2
lines changed Expand file tree Collapse file tree 1 file changed +20
-2
lines changed Original file line number Diff line number Diff line change
1
+ # !/usr/bin/python
2
+ # coding=utf-8
3
+
4
+
1
5
import unittest2 as unittest
2
6
import arrow
3
7
from datetime import datetime as pydatetime
4
- from datemath import dm
5
- from datemath import datemath
8
+ from datemath import dm , datemath
9
+ from datemath . helpers import DateMathException as DateMathException
6
10
from dateutil import tz
7
11
8
12
iso8601 = 'YYYY-MM-DDTHH:mm:ssZZ'
@@ -124,6 +128,20 @@ def testParse(self):
124
128
self .assertEqual (dm ('now-2.5d' ).format (iso8601 ), arrow .utcnow ().shift (days = - 2.5 ).format (iso8601 ))
125
129
126
130
131
+ # Catch invalid timeunits
132
+ self .assertRaises (DateMathException , dm , '+1,' )
133
+ self .assertRaises (DateMathException , dm , '+1.' )
134
+ self .assertRaises (DateMathException , dm , '+1ö' )
135
+ self .assertRaises (DateMathException , dm , '+1ä' )
136
+ self .assertRaises (DateMathException , dm , '+1ü' )
137
+ self .assertRaises (DateMathException , dm , '+1ß' )
138
+
139
+ try :
140
+ dm ('+1,' )
141
+ except DateMathException as e :
142
+ self .assertTrue ('is not a valid timeunit' in str (e ))
143
+
144
+
127
145
if __name__ == "__main__" :
128
146
unittest .main ()
129
147
You can’t perform that action at this time.
0 commit comments