@@ -168,10 +168,10 @@ def test_thai_strftime(self):
168168 # ### pythainlp.util.thai_time
169169
170170 def test_thai_time (self ):
171+ self .assertEqual (thai_time ("8:17" ), thai_time ("08:17" ))
171172 self .assertEqual (thai_time ("8:17" ), "แปดนาฬิกาสิบเจ็ดนาที" )
172173 self .assertEqual (thai_time ("8:17" , "6h" ), "สองโมงเช้าสิบเจ็ดนาที" )
173174 self .assertEqual (thai_time ("8:17" , "m6h" ), "แปดโมงสิบเจ็ดนาที" )
174- self .assertEqual (thai_time ("18:30" , "m6h" ), "หกโมงครึ่ง" )
175175 self .assertEqual (thai_time ("13:30:01" , "6h" , "m" ), "บ่ายโมงครึ่ง" )
176176 self .assertEqual (
177177 thai_time (datetime .time (12 , 3 , 0 )), "สิบสองนาฬิกาสามนาที"
@@ -181,23 +181,38 @@ def test_thai_time(self):
181181 "สิบสองนาฬิกาสามนาทีหนึ่งวินาที" ,
182182 )
183183 self .assertEqual (
184- thai_time (
185- datetime .datetime (2014 , 5 , 22 , 12 , 3 , 0 ), precision = "s"
186- ),
184+ thai_time (datetime .datetime (2014 , 5 , 22 , 12 , 3 , 0 ), precision = "s" ),
187185 "สิบสองนาฬิกาสามนาทีศูนย์วินาที" ,
188186 )
189187 self .assertEqual (
190- thai_time (
191- datetime .datetime (2014 , 5 , 22 , 12 , 3 , 1 ), precision = "m"
192- ),
188+ thai_time (datetime .datetime (2014 , 5 , 22 , 12 , 3 , 1 ), precision = "m" ),
193189 "สิบสองนาฬิกาสามนาที" ,
194190 )
195191 self .assertEqual (
196- thai_time (
197- datetime .datetime (1976 , 10 , 6 , 12 , 30 , 1 ), "6h" , "m"
198- ),
192+ thai_time (datetime .datetime (1976 , 10 , 6 , 12 , 30 , 1 ), "6h" , "m" ),
199193 "เที่ยงครึ่ง" ,
200194 )
195+ self .assertEqual (thai_time ("18:30" ), "สิบแปดนาฬิกาสามสิบนาที" )
196+ self .assertEqual (thai_time ("18:30:00" ), "สิบแปดนาฬิกาสามสิบนาที" )
197+ self .assertEqual (
198+ thai_time ("18:30:01" ), "สิบแปดนาฬิกาสามสิบนาทีหนึ่งวินาที"
199+ )
200+ self .assertEqual (
201+ thai_time ("18:30:01" , precision = "m" ), "สิบแปดนาฬิกาสามสิบนาที"
202+ )
203+ self .assertEqual (
204+ thai_time ("18:30:01" , precision = "s" ),
205+ "สิบแปดนาฬิกาสามสิบนาทีหนึ่งวินาที" ,
206+ )
207+ self .assertEqual (
208+ thai_time ("18:30:01" , fmt = "m6h" , precision = "m" ), "หกโมงครึ่ง"
209+ )
210+ self .assertEqual (
211+ thai_time ("18:30:01" , fmt = "m6h" ), "หกโมงสามสิบนาทีหนึ่งวินาที"
212+ )
213+ self .assertEqual (
214+ thai_time ("18:30:01" , fmt = "m6h" , precision = "m" ), "หกโมงครึ่ง"
215+ )
201216 self .assertIsNotNone (thai_time ("0:30" ))
202217 self .assertIsNotNone (thai_time ("0:30" , "6h" ))
203218 self .assertIsNotNone (thai_time ("0:30" , "m6h" ))
@@ -228,7 +243,12 @@ def test_thai_time(self):
228243 def test_delete_tone (self ):
229244 self .assertEqual (delete_tone ("จิ้น" ), "จิน" )
230245 self .assertEqual (delete_tone ("เก๋า" ), "เกา" )
231- self .assertEqual (delete_tone ("จิ้น" ), deletetone ("จิ้น" ))
246+
247+ # Commented out until this unittest bug get fixed:
248+ # https://bugs.python.org/issue29620
249+ # with self.assertWarns(DeprecationWarning):
250+ # deletetone("จิ้น")
251+ self .assertEqual (deletetone ("จิ้น" ), delete_tone ("จิ้น" ))
232252
233253 def test_normalize (self ):
234254 self .assertEqual (normalize ("เเปลก" ), "แปลก" )
@@ -256,7 +276,6 @@ def test_isthai(self):
256276 self .assertEqual (isthai ("(ต.ค.)" , ignore_chars = ".()" ), True )
257277
258278 def test_is_native_thai (self ):
259- self .assertEqual (is_native_thai ("เลข" ), thaicheck ("เลข" ))
260279 self .assertEqual (is_native_thai (None ), False )
261280 self .assertEqual (is_native_thai ("" ), False )
262281 self .assertEqual (is_native_thai ("116" ), False )
@@ -276,3 +295,9 @@ def test_is_native_thai(self):
276295 self .assertEqual (is_native_thai ("เลข" ), False )
277296 self .assertEqual (is_native_thai ("เทเวศน์" ), False )
278297 self .assertEqual (is_native_thai ("เทเวศร์" ), False )
298+
299+ # Commented out until this unittest bug get fixed:
300+ # https://bugs.python.org/issue29620
301+ # with self.assertWarns(DeprecationWarning):
302+ # thaicheck("เลข")
303+ self .assertEqual (thaicheck ("เลข" ), is_native_thai ("เลข" ))
0 commit comments