
    SOg@                     b    S r SSKJr  SSKrSSKrSSKJr  SSKr " S S\R                  5      r	g)zu
testtimeparse.py
(c) Will Roberts <wildwilhelm@gmail.com>  1 February, 2014

Unit tests for the `timeparse` module.
    )absolute_importN   )	timeparsec                   D   \ rS rSrSrS rS rS rS rS r	S r
S	 rS
 rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS r S r!S  r"S! r#S" r$S# r%S$ r&S% r'S& r(S' r)S( r*S) r+S* r,S+ r-S, r.S- r/S. r0S/ r1S0 r2S1 r3S2 r4S3 r5S4 r6S5r7g6)7TestTimeparse   z(
Unit tests for the `timeparse` module.
c                     g)zSetup function.N selfs    d/Users/admin/workspace/ai/Jarvis/env/lib/python3.13/site-packages/pytimeparse/tests/testtimeparse.pysetUpTestTimeparse.setUp   s        c                 @   U R                  [        R                  " [        R                  S5      R                  5       SS05        U R                  [        R                  " [        R                  S5      R                  5       SS05        U R                  [        R                  " [        R                  S5      R                  5       SS05        U R                  [        R                  " [        R                  S5      R                  5       SS05        U R                  [        R                  " [        R                  S5      R                  5       SS05        U R                  [        R                  " [        R                  S5      R                  5       SS05        g)zTest parsing minutes.32minmins3232mins32minute	32minutesN)assertEqualrematchr   MINS	groupdictr   s    r   	test_minsTestTimeparse.test_mins   s   )..':DDF $	))..(;EEG $	))..*=GGI $	))..+>HHJ $	))..(;EEG $	))..':DDF $	)r   c                    U R                  [        R                  " [        R                  S5      R                  5       SS05        U R                  [        R                  " [        R                  S5      R                  5       SS05        U R                  [        R                  " [        R                  S5      R                  5       SS05        U R                  [        R                  " [        R                  S5      R                  5       SS05        U R                  [        R                  " [        R                  S5      R                  5       SS05        U R                  [        R                  " [        R                  S5      R                  5       SS05        U R                  [        R                  " [        R                  S	5      R                  5       SS05        g
)zTest parsing hours.32hhoursr   32hr32hrs32hour32hoursz32 hoursz32 hN)r   r   r   r   HOURSr   r   s    r   test_hrsTestTimeparse.test_hrs)   sK   )//59CCE!4	*)//6:DDF!4	*)//7;EEG!4	*)//8<FFH!4	*)//9=GGI!4	*)//:>HHJ!4	*)//6:DDF!4	*r   c                     U R                  [        [        R                  " [        R
                  S   S-   S5      R                  5       R                  5       5      [        / SQ5      5        g)zTest parsing time expression.r   z\s*$z16h32m64s  ))r!   16)r   r   )secs64N)assertGreatersetr   r   r   TIMEFORMATSr   itemsr   s    r   	test_timeTestTimeparse.test_time:   sO    ..q1G;&((1	EEG=AB	Dr   c                    U R                  [        R                  " S5      S5        U R                  [        R                  " S5      S5        U R                  [        R                  " S5      S5        U R                  [        R                  " S5      S5        U R                  [        R                  " S	5      S
5        g)z#Test parsing time unit multipliers.z32 min  z1 min<   z1 hoursi  z1 dayiQ z1 sec   Nr   r   r   s    r   test_timeparse_multipliers(TestTimeparse.test_timeparse_multipliersA   s    ,,X6	,,W5	,,Y7	,,W5	 ,,W5	r   c                    U R                  [        R                  " S5      S5        U R                  [        R                  " S5      S5        U R                  [        R                  " S5      S5        U R                  [        R                  " S5      S5        U R                  [        R                  " S5      5        U R                  [        R                  " S5      5        g	)
zTest parsing time signs.z	+32 m 1 si  z
+ 32 m 1 sz	-32 m 1 siz
- 32 m 1 sz
32 m - 1 sz
32 m + 1 sN)r   r   assertIsNoner   s    r   test_timeparse_signs"TestTimeparse.test_timeparse_signsN   s    ,,[94@,,\:DA,,[95A,,\:EB)--l;<)--l;<r   c                     U R                  [        R                  " S5      S5        U R                  [        R                  " S5      S5        U R                  [        R                  " S5      S5        g)ztimeparse test case 1.32mr4   z+32mz-32miNr7   r   s    r   test_timeparse_1TestTimeparse.test_timeparse_1W   sS    ,,U3T:,,V4d;,,V4e<r   c                     U R                  [        R                  " S5      S5        U R                  [        R                  " S5      S5        U R                  [        R                  " S5      S5        g)ztimeparse test case 2.2h32mi#  z+2h32mz-2h32mi`Nr7   r   s    r   test_timeparse_2TestTimeparse.test_timeparse_2]   sS    ,,W5t<,,X6=,,X6>r   c                     U R                  [        R                  " S5      S5        U R                  [        R                  " S5      S5        U R                  [        R                  " S5      S5        g)ztimeparse test case 3.3d2h32mi  z+3d2h32mz-3d2h32miNr7   r   s    r   test_timeparse_3TestTimeparse.test_timeparse_3c   S    ,,Y7@,,Z8&A,,Z8'Br   c                     U R                  [        R                  " S5      S5        U R                  [        R                  " S5      S5        U R                  [        R                  " S5      S5        g)ztimeparse test case 4.	1w3d2h32mR z
+1w3d2h32mz
-1w3d2h32m`Nr7   r   s    r   test_timeparse_4TestTimeparse.test_timeparse_4i   S    ,,[96B,,\:FC,,\:GDr   c                     U R                  [        R                  " S5      S5        U R                  [        R                  " S5      S5        U R                  [        R                  " S5      S5        g)ztimeparse test case 5.z1w 3d 2h 32mrM   z+1w 3d 2h 32mz-1w 3d 2h 32mrN   Nr7   r   s    r   test_timeparse_5TestTimeparse.test_timeparse_5o   sS    ,,^<fE,,_=vF,,_=wGr   c                     U R                  [        R                  " S5      S5        U R                  [        R                  " S5      S5        U R                  [        R                  " S5      S5        g)ztimeparse test case 6.z1 w 3 d 2 h 32 mrM   z+1 w 3 d 2 h 32 mz-1 w 3 d 2 h 32 mrN   Nr7   r   s    r   test_timeparse_6TestTimeparse.test_timeparse_6u   sV    ,,-?@&I,,-@A6J,,-@A7Kr   c                     U R                  [        R                  " S5      S5        U R                  [        R                  " S5      S5        U R                  [        R                  " S5      S5        g)ztimeparse test case 7.z4:13   z+4:13z-4:13iNr7   r   s    r   test_timeparse_7TestTimeparse.test_timeparse_7{   sS    ,,V4c:,,W5s;,,W5t<r   c                     U R                  [        R                  " S5      S5        U R                  [        R                  " S5      S5        U R                  [        R                  " S5      S5        g)z-timeparse test bare seconds, without minutes.z:13   z+:13z-:13iNr7   r   s    r   test_timeparse_bare_seconds)TestTimeparse.test_timeparse_bare_seconds   sS    ,,U3R8,,V4b9,,V4c:r   c                     U R                  [        R                  " S5      S5        U R                  [        R                  " S5      S5        U R                  [        R                  " S5      S5        g)ztimeparse test case 8.z4:13:02iN;  z+4:13:02z-4:13:02iNr7   r   s    r   test_timeparse_8TestTimeparse.test_timeparse_8   sS    ,,Y7?,,Z8%@,,Z8&Ar   c                     U R                  [        R                  " S5      S5        U R                  [        R                  " S5      S5        U R                  [        R                  " S5      S5        g)ztimeparse test case 9.z4:13:02.266g^I"@z+4:13:02.266z-4:13:02.266g^I"NassertAlmostEqualr   r   s    r   test_timeparse_9TestTimeparse.test_timeparse_9   sS    y22=A9My22>BINy22>BJOr   c                     U R                  [        R                  " S5      S5        U R                  [        R                  " S5      S5        U R                  [        R                  " S5      S5        g)ztimeparse test case 10.z2:04:13:02.266禛 rAz+2:04:13:02.266z-2:04:13:02.266禛 rNrd   r   s    r   test_timeparse_10TestTimeparse.test_timeparse_10   s_    y223CD)	+y223DE)	+y223DE*	,r   c                     U R                  [        R                  " SSS9S5        U R                  [        R                  " SSS9S5        U R                  [        R                  " SSS9S5        g)	z6Check that minute-level granularity applies correctly.z4:32minutesgranularityi?  z+4:32z-4:32i@Nr7   r   s    r   test_timeparse_granularity_1*TestTimeparse.test_timeparse_granularity_1   sY    ,,VKVT,,W)LfU,,W)LgVr   c                     U R                  [        R                  " SSS9S5        U R                  [        R                  " SSS9S5        U R                  [        R                  " SSS9S5        g)	CCheck that minute-level granularity does not apply inappropriately.z4:32:02rn   ro   i?  z+4:32:02z-4:32:02i>Nr7   r   s    r   test_timeparse_granularity_2*TestTimeparse.test_timeparse_granularity_2   s\    ,,YINPXY,,ZYOQYZ,,ZYOQ\]r   c                     U R                  [        R                  " SSS9S5        U R                  [        R                  " SSS9S5        U R                  [        R                  " SSS9S5        g)	rt   z7:02.223rn   ro   g!rhcz@z	+7:02.223z	-7:02.223g!rhczNrd   r   s    r   test_timeparse_granularity_3*TestTimeparse.test_timeparse_granularity_3   s\    y22:9UWcdy22;IVXdey22;IVXghr   c                     U R                  [        R                  " SSS9S5        U R                  [        R                  " SSS9S5        U R                  [        R                  " SSS9S5        g)	rt   z0:02secondsro   r   z+0:02z-0:02Nr7   r   s    r   test_timeparse_granularity_4*TestTimeparse.test_timeparse_granularity_4   sY    ,,VKQO,,W)LaP,,W)LbQr   c                     U R                  [        R                  " S5      S5        U R                  [        R                  " S5      S5        U R                  [        R                  " S5      S5        g)ztimeparse test case 11.z2 days,  4:13:02iN z+2 days,  4:13:02z-2 days,  4:13:02i!Nr7   r   s    r   test_timeparse_11TestTimeparse.test_timeparse_11   sX     	,,-?@&I,,-@A6J,,-@A7Kr   c                     U R                  [        R                  " S5      S5        U R                  [        R                  " S5      S5        U R                  [        R                  " S5      S5        g)ztimeparse test case 12.z2 days,  4:13:02.266ri   z+2 days,  4:13:02.266z-2 days,  4:13:02.266rj   Nrd   r   s    r   test_timeparse_12TestTimeparse.test_timeparse_12   s_    y223IJ)	+y223JK)	+y223JK*	,r   c                     U R                  [        R                  " S5      S5        U R                  [        R                  " S5      S5        U R                  [        R                  " S5      S5        g)ztimeparse test case 13.	5hr34m56sN  z
+5hr34m56sz
-5hr34m56s週Nr7   r   s    r   test_timeparse_13TestTimeparse.test_timeparse_13   sS    ,,[95A,,\:EB,,\:FCr   c                     U R                  [        R                  " S5      S5        U R                  [        R                  " S5      S5        U R                  [        R                  " S5      S5        g)ztimeparse test case 14.z5 hours, 34 minutes, 56 secondsr   z +5 hours, 34 minutes, 56 secondsz -5 hours, 34 minutes, 56 secondsr   Nr7   r   s    r   test_timeparse_14TestTimeparse.test_timeparse_14   s_    ,,-NO	 ,,-OP	 ,,-OP	!r   c                     U R                  [        R                  " S5      S5        U R                  [        R                  " S5      S5        U R                  [        R                  " S5      S5        g)ztimeparse test case 15.z5 hrs, 34 mins, 56 secsr   z+5 hrs, 34 mins, 56 secsz-5 hrs, 34 mins, 56 secsr   Nr7   r   s    r   test_timeparse_15TestTimeparse.test_timeparse_15   sV    ,,-FGO,,-GH%P,,-GH&Qr   c                     U R                  [        R                  " S5      S5        U R                  [        R                  " S5      S5        U R                  [        R                  " S5      S5        g)ztimeparse test case 16.z'2 days, 5 hours, 34 minutes, 56 secondsi z(+2 days, 5 hours, 34 minutes, 56 secondsz(-2 days, 5 hours, 34 minutes, 56 secondsiNr7   r   s    r   test_timeparse_16TestTimeparse.test_timeparse_16   sf     IJ	 	 JK	 	 JK	r   c                     U R                  [        R                  " S5      S5        U R                  [        R                  " S5      S5        U R                  [        R                  " S5      S5        g)ztimeparse test case 16b.z1.75 s      ?z+1.75 sz-1.75 s      Nrd   r   s    r   test_timeparse_16b TestTimeparse.test_timeparse_16b   sS    y228<dCy229=tDy229=uEr   c                     U R                  [        R                  " S5      S5        U R                  [        R                  " S5      S5        U R                  [        R                  " S5      S5        g)ztimeparse test case 16c.z1.75 secr   z	+1.75 secz	-1.75 secr   Nrd   r   s    r   test_timeparse_16c TestTimeparse.test_timeparse_16c   sS    y22:>Ey22;?Fy22;?Gr   c                     U R                  [        R                  " S5      S5        U R                  [        R                  " S5      S5        U R                  [        R                  " S5      S5        g)ztimeparse test case 16d.z	1.75 secsr   z
+1.75 secsz
-1.75 secsr   Nrd   r   s    r   test_timeparse_16d TestTimeparse.test_timeparse_16d   sS    y22;?Fy22<@$Gy22<@%Hr   c                     U R                  [        R                  " S5      S5        U R                  [        R                  " S5      S5        U R                  [        R                  " S5      S5        g)ztimeparse test case 16e.z1.75 secondr   z+1.75 secondz-1.75 secondr   Nrd   r   s    r   test_timeparse_16e TestTimeparse.test_timeparse_16e   sS    y22=A4Hy22>BDIy22>BEJr   c                     U R                  [        R                  " S5      S5        U R                  [        R                  " S5      S5        U R                  [        R                  " S5      S5        g)ztimeparse test case 16f.z1.75 secondsr   z+1.75 secondsz-1.75 secondsr   Nrd   r   s    r   test_timeparse_16f TestTimeparse.test_timeparse_16f   sS    y22>BDIy22?CTJy22?CUKr   c                     U R                  [        R                  " S5      S5        U R                  [        R                  " S5      S5        U R                  [        R                  " S5      S5        g)ztimeparse test case 17.z1.2 mH   z+1.2 mz-1.2 mNr7   r   s    r   test_timeparse_17TestTimeparse.test_timeparse_17  sS    ,,W5r:,,X6;,,X6<r   c                     U R                  [        R                  " S5      S5        U R                  [        R                  " S5      S5        U R                  [        R                  " S5      S5        g)ztimeparse test case 18.z1.2 minr   z+1.2 minz-1.2 minr   Nr7   r   s    r   test_timeparse_18TestTimeparse.test_timeparse_18	  sS    ,,Y7<,,Z8"=,,Z8#>r   c                     U R                  [        R                  " S5      S5        U R                  [        R                  " S5      S5        U R                  [        R                  " S5      S5        g)ztimeparse test case 19.z1.2 minsr   z	+1.2 minsz	-1.2 minsr   Nr7   r   s    r   test_timeparse_19TestTimeparse.test_timeparse_19  sS    ,,Z8"=,,[92>,,[93?r   c                     U R                  [        R                  " S5      S5        U R                  [        R                  " S5      S5        U R                  [        R                  " S5      S5        g)ztimeparse test case 20.z
1.2 minuter   z+1.2 minutez-1.2 minuter   Nr7   r   s    r   test_timeparse_20TestTimeparse.test_timeparse_20  sS    ,,\:B?,,];R@,,];SAr   c                     U R                  [        R                  " S5      S5        U R                  [        R                  " S5      S5        U R                  [        R                  " S5      S5        g)ztimeparse test case 21.z1.2 minutesr   z+1.2 minutesz-1.2 minutesr   Nr7   r   s    r   test_timeparse_21TestTimeparse.test_timeparse_21  sS    ,,];R@,,^<bA,,^<cBr   c                     U R                  [        R                  " S5      S5        U R                  [        R                  " S5      S5        U R                  [        R                  " S5      S5        g)ztimeparse test case 22.z	172 hoursr	 z
+172 hoursz
-172 hours@Nr7   r   s    r   test_timeparse_22TestTimeparse.test_timeparse_22!  rQ   r   c                     U R                  [        R                  " S5      S5        U R                  [        R                  " S5      S5        U R                  [        R                  " S5      S5        g)ztimeparse test case 23.z172 hrr   z+172 hrz-172 hrr   Nr7   r   s    r   test_timeparse_23TestTimeparse.test_timeparse_23'  S    ,,X6?,,Y7@,,Y7Ar   c                     U R                  [        R                  " S5      S5        U R                  [        R                  " S5      S5        U R                  [        R                  " S5      S5        g)ztimeparse test case 24.z172 hr   z+172 hz-172 hr   Nr7   r   s    r   test_timeparse_24TestTimeparse.test_timeparse_24-  S    ,,W5v>,,X6?,,X6@r   c                     U R                  [        R                  " S5      S5        U R                  [        R                  " S5      S5        U R                  [        R                  " S5      S5        g)ztimeparse test case 25.z172 hrsr   z+172 hrsz-172 hrsr   Nr7   r   s    r   test_timeparse_25TestTimeparse.test_timeparse_253  rJ   r   c                     U R                  [        R                  " S5      S5        U R                  [        R                  " S5      S5        U R                  [        R                  " S5      S5        g)ztimeparse test case 26.z172 hourr   z	+172 hourz	-172 hourr   Nr7   r   s    r   test_timeparse_26TestTimeparse.test_timeparse_269  sS    ,,Z8&A,,[96B,,[97Cr   c                     U R                  [        R                  " S5      S5        U R                  [        R                  " S5      S5        U R                  [        R                  " S5      S5        g)ztimeparse test case 27.z	1.24 daysi z
+1.24 daysz
-1.24 daysi]Nr7   r   s    r   test_timeparse_27TestTimeparse.test_timeparse_27?  rQ   r   c                     U R                  [        R                  " S5      S5        U R                  [        R                  " S5      S5        U R                  [        R                  " S5      S5        g)ztimeparse test case 28.z5 d逗 z+5 dz-5 dhNr7   r   s    r   test_timeparse_28TestTimeparse.test_timeparse_28E  sS    ,,U3V<,,V4f=,,V4g>r   c                     U R                  [        R                  " S5      S5        U R                  [        R                  " S5      S5        U R                  [        R                  " S5      S5        g)ztimeparse test case 29.z5 dayr   z+5 dayz-5 dayr   Nr7   r   s    r   test_timeparse_29TestTimeparse.test_timeparse_29K  r   r   c                     U R                  [        R                  " S5      S5        U R                  [        R                  " S5      S5        U R                  [        R                  " S5      S5        g)ztimeparse test case 30.z5 daysr   z+5 daysz-5 daysr   Nr7   r   s    r   test_timeparse_30TestTimeparse.test_timeparse_30Q  r   r   c                     U R                  [        R                  " S5      S5        U R                  [        R                  " S5      S5        U R                  [        R                  " S5      S5        g)ztimeparse test case 31.z5.6 wk 3 z+5.6 wkz-5.6 wk RNr7   r   s    r   test_timeparse_31TestTimeparse.test_timeparse_31W  sS    ,,X6@,,Y7A,,Y7Br   c                     U R                  [        R                  " S5      S5        U R                  [        R                  " S5      S5        U R                  [        R                  " S5      S5        g)ztimeparse test case 32.z5.6 weekr   z	+5.6 weekz	-5.6 weekr   Nr7   r   s    r   test_timeparse_32TestTimeparse.test_timeparse_32]  sS    ,,Z8'B,,[97C,,[98Dr   c                     U R                  [        R                  " S5      S5        U R                  [        R                  " S5      S5        U R                  [        R                  " S5      S5        g)ztimeparse test case 33.z	5.6 weeksr   z
+5.6 weeksz
-5.6 weeksr   Nr7   r   s    r   test_timeparse_33TestTimeparse.test_timeparse_33c  sS    ,,[97C,,\:GD,,\:HEr   c                 T    U R                  [        R                  " [        SS95        g)zRun timeparse doctests.T)raise_on_errorN)
assertTruedoctesttestmodr   r   s    r   test_doctestTestTimeparse.test_doctesti  s    	$GHr   r
   N)8__name__
__module____qualname____firstlineno____doc__r   r   r'   r1   r8   r<   r@   rD   rH   rO   rS   rV   rZ   r^   ra   rf   rk   rq   ru   rx   r}   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   __static_attributes__r
   r   r   r   r      s#   )*"D==?CEHL=;BP,W^iRL,D!R
FHIKL=?@BCEBACDE?ABCEFIr   r   )
r   
__future__r   r   r    r   unittestTestCaser   r
   r   r   <module>r      s1    '  	  ZIH%% ZIr   