Mini Shell

Direktori : /opt/cppython/lib/python3.8/test/__pycache__/
Upload File :
Current File : //opt/cppython/lib/python3.8/test/__pycache__/datetimetester.cpython-38.pyc

U

��eg[��@s�dZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlmZddl
mZmZmZmZmZmZmZmZmZddlmZddlmZmZmZmZddlZddlm Z m!Z!ddlm"Z"dd	lm#Z#dd
lm$Z$ddlm%Z%ddlm&Z&mZddl$Z'ddl(Z(ddl)Z)ej*ej+hZ,d
d�e-ej.d�D�Z/e0e/�ej.dk�sdt1�dddigdfZ2e3d�Z4e3d�Z5Gdd�dej6�Z7Gdd�de#�Z8Gdd�de8�Z9Gdd�de#�Z:Gdd�dej6�Z;Gd d!�d!ej6�Z<Gd"d#�d#�Z=Gd$d%�d%e=ej6�Z>Gd&d'�d'ej6�Z?Gd(d)�d)e&�Z@Gd*d+�d+e=ej6�ZAGd,d-�d-e�ZBGd.d/�d/eA�ZCGd0d1�d1eC�ZDGd2d3�d3e$�ZEGd4d5�d5e=ej6�ZFGd6d7�d7�ZGGd8d9�d9eFeGej6�ZHGd:d;�d;eCeGej6�ZId<d=�ZJe"d�ZKe"dd>�ZLe"dd?�ZMe"dd@�ZNeddAddB�ZOedddCd�ZPGdDdE�dEe#�ZQeQdFdGdHdI�ZReQdJdKdLdM�ZSeQdNdOdPdQ�ZTeQdRdSdTdU�ZUe8ddVd�ZVe8dWdXd�ZWGdYdZ�dZej6�ZXGd[d\�d\ej6�ZYGd]d^�d^e#�ZZGd_d`�d`eZ�Z[e[dFdadHdI�Z\e[dJdbdLdM�Z]e[dNdcdPdQ�Z^e[dRdddTdU�Z_Gdedf�dfe#�Z`Gdgdh�dhej6�Zae"dd�Zbdidj�ZcGdkdl�dle#�ZdGdmdn�dnej6�ZeGdodp�dpejf�ZgGdqdr�dree�ZhGdsdt�dtej6�Zidudv�Zjekdwk�r�e�l�dS)xzTTest date/time type.

See http://www.zope.org/Members/fdrake/DateTimeWiki/TestCases
�N)�array)	�lt�le�gt�ge�eq�ne�truediv�floordiv�mod)�support)�is_resource_enabled�	ALWAYS_EQ�LARGEST�SMALLEST)�MINYEAR�MAXYEAR��	timedelta��tzinfo)�time��timezone)�date�datetimecCsg|]}tt|f�qS�)�pickle)�.0�protorr�2/opt/cppython/lib/python3.8/test/datetimetester.py�
<listcomp>)s�r!��
g@A@�abcr�inf�nanc@s$eZdZdd�Zdd�Zdd�ZdS)�
TestModulecCs$t}|�|jd�|�|jd�dS)Nr"�')�datetime_module�assertEqualrr)�selfrrrr �test_constants<szTestModule.test_constantscCsdd|jjkr|�d�t}tdd�t|�D��}tddddd	d
ddd
dg
�}|�||tg��dS)NZ_Purez"Only run for Fast C implementationcss&|]}|�d�s|�d�s|VqdS)�__N)�
startswith�endswith)r�namerrr �	<genexpr>Fs

�z/TestModule.test_name_cleanup.<locals>.<genexpr>rrrrZ
datetime_CAPIrrrr�sys)�	__class__�__name__�skipTestr)�set�dirr*)r+r�names�allowedrrr �test_name_cleanupAs

�zTestModule.test_name_cleanupcCsd|jjkr|�d�tj}|�|dd�d�|�|dd�d�|�|dd�d	�|�|d
d�d�|�|dd�d�|�|d
d�d	�|�|dd�d	�|�|dd�d�|�|dd
�d�|�|dd
�d	�|�|dd�d	�|�|dd�d�|�|dd
�d�|�|dd
�d	�dS)N�_Fastz'Only run for Pure Python implementation����������������r#��������)r3r4r5r)Z_divide_and_roundr*)r+Zdarrrr �test_divide_and_roundMs"
z TestModule.test_divide_and_roundN)r4�
__module__�__qualname__r,r:rHrrrr r':sr'c@s6eZdZd
dd�Zdd�Zdd�Zdd	�Zd
d�ZdS)�FixedOffset�*cCs>t|t�rt|d�}t|t�r(t|d�}||_||_||_dS�N��minutes)�
isinstance�intr�_FixedOffset__offset�_FixedOffset__name�_FixedOffset__dstoffset�r+�offsetr0Z	dstoffsetrrr �__init__ns



zFixedOffset.__init__cCs
|j��S�N)rS�lower�r+rrr �__repr__vszFixedOffset.__repr__cCs|jSrX)rR�r+�dtrrr �	utcoffsetxszFixedOffset.utcoffsetcCs|jSrX)rSr\rrr �tznamezszFixedOffset.tznamecCs|jSrX)rTr\rrr �dst|szFixedOffset.dstN)rL)r4rIrJrWr[r^r_r`rrrr rKls

rKc@seZdZddd�Zdd�ZdS)�PicklableFixedOffsetNcCst�||||�dSrX)rKrWrUrrr rW�szPicklableFixedOffset.__init__cCs|jSrX)�__dict__rZrrr �__getstate__�sz!PicklableFixedOffset.__getstate__)NNN)r4rIrJrWrcrrrr ras
rac@seZdZdd�ZdS)�_TZInfocCst��SrX)�random)r+r)rrr r^�sz_TZInfo.utcoffsetN�r4rIrJr^rrrr rd�srdc@sDeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dS)�
TestTZInfoc	Cs>t�}tddddddd|�}|�t��|��W5QRXdS)N��rA��� r>r)rdr�assertRaises�	TypeErrorr^)r+Ztz1�dt1rrr �test_refcnt_crash_bug_22044�sz&TestTZInfo.test_refcnt_crash_bug_22044cCs@t�}tj}|�t|j|�|�t|j|�|�t|j|�dSrX)rr�maxrl�NotImplementedErrorr_r^r`)r+Zuselessr]rrr �test_non_abstractness�s
z TestTZInfo.test_non_abstractnesscCsrGdd�dt�}|�t|t��|dd�}|�|t�t��}|�t|j|�|�t|j	|�|�t|j
|�dS)Nc@seZdZdd�ZdS)z9TestTZInfo.test_subclass_must_override.<locals>.NotEnoughcSs||_||_dSrX)Z_NotEnough__offsetZ_NotEnough__name)r+rVr0rrr rW�szBTestTZInfo.test_subclass_must_override.<locals>.NotEnough.__init__N)r4rIrJrWrrrr �	NotEnough�srsr>ZNotByALongShot)r�
assertTrue�
issubclass�assertIsInstancer�nowrlrqr_r^r`)r+rsrr]rrr �test_subclass_must_override�s
z&TestTZInfo.test_subclass_must_overridecCsntdd�}|�|t�t��dfD]F}|�|�|�tdd��|�|�|�d�|�|�	|�tdd��q"dS)Nr>ZThreerNrL)
rKrvrrrwr*r^rr_r`)r+�for]rrr �test_normal�s
zTestTZInfo.test_normalcCsTt�t�}|�t|�t�tD]0\}}}|�||�}|�|�}|�t|�t�qdSrX)r�__new__�assertIs�type�pickle_choices�dumps�loads)r+�orig�pickler�	unpicklerr�green�derivedrrr �test_pickling_base�s

zTestTZInfo.test_pickling_basecCs�tdd�}t|dfft|fft|dfffD]�\}}||�}|�d�}|�|t�|�t|�|�|�|�	d�|�|�|�d�|�t
D]`\}}}|�||�}	|�|	�}
|�|
t�|�t|
�|�|�|
�	d�|�|�|
�d�|�q�q*dS)N����rN�cookie�EST)
rrarr_rvrr|r}r*r^r~rr�)r+rVZotype�argsr�Zonamer�r�rr�r�rrr �test_pickling_subclass�s$


�

z!TestTZInfo.test_pickling_subclasscs`tdd���G��fdd�dt�}|�}tddddd|d	�}|�|�}|�||��|�dS)
Nr"��hourscs0eZdZdZ�fdd�Z�fdd�Zdd�ZdS)	z0TestTZInfo.test_issue23600.<locals>.UKSummerTimez~Simple time zone which pretends to always be in summer time, since
                that's what shows the failure.
            cs�SrXrr\)�	DSTOFFSETrr r^�sz:TestTZInfo.test_issue23600.<locals>.UKSummerTime.utcoffsetcs�SrXrr\)�DSTDIFFrr r`�sz4TestTZInfo.test_issue23600.<locals>.UKSummerTime.dstcSsdS)N�UKSummerTimerr\rrr r_�sz7TestTZInfo.test_issue23600.<locals>.UKSummerTime.tznameN)r4rIrJ�__doc__r^r`r_r�r�r�rr r��sr�rhrD��r)rrr�fromutcr*r^)r+r��tz�u�trr�r �test_issue23600�s
zTestTZInfo.test_issue23600N)
r4rIrJrorrrxrzr�r�r�rrrr rg�s
rgc@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#S)$�TestTimeZonecCs8ttdd�d�|_ttdd�d�|_tddd�|_dS)N�#@r��ACDTr?r���r")rrr�r�r�DTrZrrr �setUp�szTestTimeZone.setUpcCs8|j|jtjtjtjfD]}|�t|�|�d��qdSrX)	r�r�r�utc�minrpr*�strr_�r+r�rrr �test_str�s
�zTestTimeZone.test_strcCs>t}|j|jtjtjtjfD]}t|�}|�|t	|��qdSrX)
r)r�r�rr�r�rp�reprr*�eval)r+rr�Ztzreprrr �	test_repr�s�zTestTimeZone.test_reprcCsNtddd�}|�tj�d�t�|�tj�d�|�|�tj�d�|�dS)N��;�r�rO)rr*rr�r^�ZEROr�rp)r+�limitrrr �test_class_members�szTestTimeZone.test_class_membersc	Cs\|�tjttd���|�tjttd�d��|�tjttd�d��tdd�tdd�fD](}t|�}|�|�d�tdd�d�qZtdd�td�fD]"}|�t	t|�|�t	t|�q�|�t
��td�W5QRX|�t
��td�W5QRX|�t
��ttd�W5QRX|�t
��ttd�W5QRX|�t
��ttdd	�W5QRXdS)
Nr�UTCr"��microseconds��secondsrNrL�ABC�extra)r|rr�r�assertIsNotr*�assertNotEqualr^rl�
ValueErrorrmr�)r+Z	subminuter��invalidrrr �test_constructors&zTestTimeZone.test_constructorcCs |�tjt�|�|jt�dSrX)rvrr�rr�rZrrr �test_inheritanceszTestTimeZone.test_inheritancec	Cs�|j}dD]<}|t}|�|t|��|��|�|t|��|��q
|�t��|j�d�W5QRX|�t��|j�d�W5QRXdS)N)rg�?r��r?)r��HOURr*rr^rlrmr�)r+�dummy�hrVrrr �test_utcoffsetszTestTimeZone.test_utcoffsetc	Cs\|�tj�|j��|�t��|j�d�W5QRX|�t��|j�d�W5QRXdS)Nr�r?)�assertIsNonerr�r`r�rlrmr�rZrrr �test_dst%s
zTestTimeZone.test_dstc	Csn|�dtj�d��|�dtt��d��|�dtdt��d��|�dtdt��d��|�dttdd���d��|�d	tdtd	��d��|�d
ttd
��d��|�dttdd
���d��|�dttdd
���d��|�dttdd
d���d��|�dttdd
d���d��|�t��|j	�d�W5QRX|�t��|j	�d�W5QRXdS)Nr�z	UTC-05:00���z	UTC+09:30r�z	UTC-00:01���rNZXYZ��zUTC+01:06:40r�zUTC-01:06:40zUTC+01:06:40.000001r"zUTC-01:06:40.000001r�r?)
r*rr�r_r�r�rrlrmr�rZrrr �test_tzname+s*���zTestTimeZone.test_tznamec	Cs�|�t��tj�|j�W5QRX|�t��tj�d�W5QRX|j|jt	fD]J}|jj
|d�}|�|�}|�|||�|��|�||jj
tjd��qTdS)Nznot datetimer)
rlr�rr�r�r�rmr�r��Eastern�replacer*r^)r+r�Zutctime�localrrr �test_fromutcAs
�zTestTimeZone.test_fromutcc	Cs>|�tt�tt��|�tt�tt��|�tdt�tdtd��|�t��tt�tt�kW5QRX|�tt�tt�h�|�tt�dk�|�	tt�dk�tt�}|�|t
k�|�	|t
k�|�|tk�|�	|tk�|�|tk�|�	|tk�|�	|tk�|�|tk�|�	|tk�|�|tk�dS)Nr�r�)
r�rr�r�r*rlrm�assertInrt�assertFalserrrr�rrr �test_comparisonMs&zTestTimeZone.test_comparisoncCs�tddd�}tjtjtjfD]^}|�|�|�|j|d����|�|�|�|j|d����|�|�	|�|j|d��	��qdS)Nr"r)
rrr�rpr�r*r_r�r^r`�r+r�r�rrr �test_aware_datetimebs���z TestTimeZone.test_aware_datetimecCs�|j|jtjtjfD]2}tD](\}}}|�|�||��}|�||�qqtj	}tD](\}}}|�|�||��}|�
||�qRdSrX)r�r�rr�rpr~r�rr*r�r|)r+r�r�r�r�tz_copyrrr �test_picklemszTestTimeZone.test_picklecCsP|j|jtjtjfD]}t�|�}|�||�qtj}t�|�}|�||�dSrX)	r�r�rr�rp�copyr*r�r|�r+r�r�rrr �	test_copyws

zTestTimeZone.test_copycCsP|j|jtjtjfD]}t�|�}|�||�qtj}t�|�}|�	||�dSrX)
r�r�rr�rpr��deepcopyr*r�r|r�rrr �
test_deepcopys

zTestTimeZone.test_deepcopycCs�tddd�tdddd�tddddd�g}|�dd�|D��|D]&}|jd	|d
��t|�W5QRXq@tdd�tdd
d�g}|�dd�|D��|D]<}|jd|d
��$|�t��t|�W5QRXW5QRXq�dS)Nr�r�r��r�rOr��?B�r�rOr�r�cSsg|]
}|�qSrr�r�deltarrr r!�sz7TestTimeZone.test_offset_boundaries.<locals>.<listcomp>Zgood)Z	test_typer��r�r")r�r�cSsg|]
}|�qSrrr�rrr r!�sZbad)r�extend�subTestrrlr�)r+Ztime_deltasr�Zbad_time_deltasrrr �test_offset_boundaries�s 
�
�z#TestTimeZone.test_offset_boundariescCs,|�tjt��|�ttdd��t��dS)Nr"r�)r�rr�rrrZrrr �test_comparison_with_tzinfo�sz(TestTimeZone.test_comparison_with_tzinfoN)r4rIrJr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrr r��s"
r�c@seZdZdd�Zdd�ZdS)�HarmlessMixedComparisoncCs�|�ddd�}|�|dk�|�|dk�|�d|k�|�d|k�|�|ddg|g�|�g|ddgg�|�|tk�|�|tk�|�|tk�|�|tk�|�|tk�|�|tk�|�|tk�|�|tk�|�|tk�|�|tk�dS)Nr"r�)�theclassr�rtr�rrr)r+�merrr �test_harmless_mixed_comparison�s"z6HarmlessMixedComparison.test_harmless_mixed_comparisoncs�|�ddd��|�t�fdd��|�t�fdd��|�t�fdd��|�t�fdd��|�t�fdd��|�t�fdd��|�t�fd	d��|�t�fd
d��dS)Nr"cs�dkS�Nrrr�r�rr �<lambda>��zGHarmlessMixedComparison.test_harmful_mixed_comparison.<locals>.<lambda>cs�dkSr�rrr�rr r��r�cs�dkSr�rrr�rr r��r�cs�dkSr�rrr�rr r��r�csd�kSr�rrr�rr r��r�csd�kSr�rrr�rr r��r�csd�kSr�rrr�rr r��r�csd�kSr�rrr�rr r��r�)r�rlrmrZrr�r �test_harmful_mixed_comparison�sz5HarmlessMixedComparison.test_harmful_mixed_comparisonN)r4rIrJr�r�rrrr r��sr�c@s�eZdZeZdd�Zdd�Zdd�Zej	dd��Z
d	d
�Zdd�Zd
d�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zej	dd ��Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3d4�Z d5d6�Z!d7S)8�
TestTimeDeltacCsv|j}t}||�|dddddddd��||d�|dd��||dd�|dd��||ddd�|dd��||dd�|dd��||dd�|d	d
��||dd
�|dd��||dd�|dd��||dd�|d
d��||dd�|d
d��||dd�|dd��||dd�|dd
��||dd
�|dd��||dd�|dd��||dd�|dd��||dd�|dd��dS)Nr)�weeks�daysr�rOr��millisecondsr�r"�r�r�r��r�rAr�r��<rN���r�g�$I�$I�?gUUUUUU�?g�?g����MbP?)r*r)r+r�tdrrr r��s*�zTestTimeDelta.test_constructorcCsb|j}t}|d�}|dd�}|ddd�}|||||ddd��||||dd��||�|�|dd��|||d��||
|d��|||dd��|||dd	d
��|t|�|�|t|�|�||dd�|�||ddd�|�||d
|d��||d
d
|�||d
d
|�||d
|dd��|d
||dd��||d
|dd��||d
|ddd��|d
||ddd��||d
|ddd��||d|�||d||�||d||�||d|dd�||dd|d�||d|dd��|d||dd��||d|d��||d
|dd��||d|ddd��||d
|dd��||d|ddd��||d|d��||d|dd��||d|d��||d
|dd��||d|ddd��||d
|dd��||d|ddd��|dd�}|d|dd|�|d|dd|�|dd|d|�|dd|d|�|d|dd|�|d |dd|�||dd!�d"|d#d��||dd!�d$|d%d��|d|dd|�|d|dd|�|d|d&d|�|d |d&d|�|d|dd|�|d|dd|�|d|d'd|�|d|d'd|�td(d
�D]$}|||d|t|d���q�td(d
�D]$}|||d|t|d���q�||dd!�d)|d%d��||d*d	d+�|d*d	d,�|ddd��||d*dd�|d*dd�|ddd��dS)-NrArr�r�rFiDQrCr��Q�X>�Qi��r#�FiX�'r@�r�r"i@�i��6i@���?��xr�r>rBr?r=r�r�翶~�Ϛ�?�@�g�6+1��?i�S	g@g�r<g`""K?-�?�ɚ;r��>B)r*r�__rsub__�abs�range�round)r+rr��a�b�c�us�irrr �test_computations�s�

""
�
�zTestTimeDelta.test_computationscs�td��dD]\�|�t��fdd��|�t��fdd��|�t��fdd��|�t��fdd��qd�|�t��fd	d��|�t��fd
d��|�t��fdd��|�t�fdd��|�t�fd
d��dS)NrL�r"��?cs��SrXrr�rr
rr r�Rr�z<TestTimeDelta.test_disallowed_computations.<locals>.<lambda>cs��SrXrrrrr r�Sr�cs��SrXrrrrr r�Tr�cs��SrXrrrrr r�Ur�rcs��SrXrr�r�zerorr r�Zr�cs��SrXrrrrr r�[r�cs��SrXrrrrr r�\r�cs�dS)N�rr�rrr r�]r�cs�dS)Nr�rrrrr r�^r�)rrlrm�ZeroDivisionErrorrZr)rr
rr �test_disallowed_computationsMsz*TestTimeDelta.test_disallowed_computationscCs,td�}|�t|jt�|�t|jt�dS)NrL)rrlr��__mul__�NAN�__truediv__)r+rrrr �test_disallowed_special`sz%TestTimeDelta.test_disallowed_specialcCsDd\}}}t|||�}|�|j|�|�|j|�|�|j|�dS)N)r"rA��rr*r�r�r�)r+r�r�r	r�rrr �test_basic_attributesfs

z#TestTimeDelta.test_basic_attributescCsptdd�}|�|��d�dD]}t|d�}|�|��|�qdD](}t|d�}|�|��|tdd��qBdS)	N�mr�g8~A)g˟$�@g˟$��r�rg��.Ar�)r�r@i����r�r")rr*�
total_seconds)r+r�r�msrrr �test_total_secondsms


z TestTimeDelta.test_total_secondscCs.tddddddd�}tdd	�}|�||�dS)
N�drC�8���r=r�g��A�r�r�r�rOr�r�r"r�)rr*�r+�t1�t2rrr �test_carriesys�
zTestTimeDelta.test_carriescCs�tddddddd�}t�}|�t|�t|��|tdd	�7}|td
d�7}|�||�|�t|�t|��|di}d
||<|�t|�d�|�||d
�dS)Nr rCr!r=r�iz
r"rAr��1r�r"rB)rr*�hash�len)r+r$r%�drrr �test_hash_equality�s"�z TestTimeDelta.test_hash_equalitycCsBd}t|�}tD],\}}}|�||�}|�|�}|�||�qdS)N)r��"�8)rr~rr�r*�r+r�r�r�r�rr�r�rrr �
test_pickling�s
zTestTimeDelta.test_picklingcs$tddd��tddd�}|��|�|��|k�|��|k�|��|k�|��|k�|��|k�dD]�}t|�}|��|k�|�|�k�|��|k�|�|�k�|��|k�|�|�k�|��|k�|�|�k�|��|k�|�|�k�|��|k�|�|�k�qntD]��|���kd�|���kd�|���kd�|���kd�|�t��fdd��|�t��fd	d��|�t��fd
d��|�t��fdd��|�t��fdd��|�t��fd
d��|�t��fdd��|�t��fdd���q(dS)NrBr>rD�)r>r>r>)rBrDrD)rBr>r?FTcs��kSrXrr�Zbadargr$rr r��r�z,TestTimeDelta.test_compare.<locals>.<lambda>cs��kSrXrrr1rr r��r�cs��kSrXrrr1rr r��r�cs��kSrXrrr1rr r��r�cs��kSrXrrr1rr r��r�cs��kSrXrrr1rr r��r�cs��kSrXrrr1rr r��r�cs��kSrXrrr1rr r��r�)rr*rtr��
OTHERSTUFFrlrm�r+r%r�rr1r �test_compare�sFzTestTimeDelta.test_comparec	Cs�t}|j}|t|d��d�|t|d��d�|t|d��d�|t|d��d�|t|d	d
dd��d
�|t|dddd��d�|t|ddd	dd��d�|t|dd��d�|t|dd��d�|t|dddddd��d�dS)Nr"z1 day, 0:00:00r�z-1 day, 0:00:00rBz2 days, 0:00:00r@z-2 days, 0:00:00r��:r�r�z12:58:59r>rDz2:03:04i��r�r,)r�r�rOr�z-210 days, 23:12:34r�z0:00:00.001000r�z0:00:00.000003rr��r�r�rOr�r�z999999999 days, 23:59:59.999999)rr*r�)r+r�rrrr r��s$���zTestTimeDelta.test_strcCs�d|jj}|�t|�d��d|�|�t|�dd��d|�|�t|�ddd��d	|�|�t|jd
d��d|�|�t|���d
|�|�t|jdd��d|�|�t|jddd��d|�|�t|jddd��d|�dS)N�	datetime.r"z
%s(days=1)r#rBz%s(days=10, seconds=2)r<�z,%s(days=-10, seconds=2, microseconds=400000)r�r�z%s(seconds=60)z%s(0)r r�z%s(microseconds=100))r�r�z%s(days=1, microseconds=100))r�r�z%s(seconds=1, microseconds=100)�r�r4r*r��r+r0rrr r��s2��������zTestTimeDelta.test_reprcCs�tdddddd�tdd�tddd	�tdd
dd�fD]Z}t|�}|�|�d
��|dd�}t|�}|�||�t|j|j|j�}|�||�q2dS)Nrr�r�r�r6�6e�r�r"�r�r�rBr>�r�r�r�r7�	)	rr�rtr.r�r*r�r�r�)r+r��sZtd2rrr �test_roundtrip�s�
�zTestTimeDelta.test_roundtripcCs~|�tjt�|�tjt�|�tjt�|�tjtjk�|�tjtd��|�tjtddd��|�tjtddd��dS)Nr;rr�g~�.Arr")rvrr�rp�
resolutionrtr*rZrrr �test_resolution_infosz"TestTimeDelta.test_resolution_infocCs�tj}tj|}||8}|�t|j|�|�t|j|�tj|}||7}|�t|j|�|�t|j|�|�tdd��td�}|�t|jd�|�t|jd�|�t|j	d�|�t|j	d�|�t|j	d�dS)	NcSstjSrX)rrprrrr r�r�z-TestTimeDelta.test_overflow.<locals>.<lambda>r"�ʚ;ge��Ag#B����;g�����|�=gr��{�>)
rrAr�rl�
OverflowError�__sub__�__add__rprr)r+�tinyr��dayrrr �
test_overflow
s 

zTestTimeDelta.test_overflowcCs.td�}|�t|jt�|�t|jt�dS�Nr")rrlrDr�INF)r+rHrrr �_test_overflow_special sz$TestTimeDelta._test_overflow_specialcCs�t}|j}||dd�|d��||dd�|d��||dd�|dd��||dd�|dd��||dd�|d	d��||d
d�|dd��||dd�|d
d��||dd�|dd��||dd�|dd��||dd�|dd��||dd�|dd��||dd�|dd��d}|d}||d|d�|d��||d|d�|d��||d|d|d�|d	d��||d|d�|d��||d|d�|d��||d|d|d�|dd��||d d�d |d!d��||d d�|jd |j|j�dS)"Ng-C��6:?r�rg-C��6:�g����Mb@?r�g����Mb@�ga2U0*�C?r"ga2U0*�C�r�g�~j�t�X?rBg�~j�t�X�r@g���Ơ>r�g���Ơ���?����i|���t��Ar�g�������?r�g�������?r�)r�r�g������ٿg������ɿr�r
)rr*rA)r+r�rZus_per_hourZ
us_per_dayrrr �test_microsecond_rounding&s0  z'TestTimeDelta.test_microsecond_roundingcCs&tdd�}|�|j|j|jfd�dS)Nr�r�)r�r�r�r)r+r�rrr �test_massive_normalizationGs
�z(TestTimeDelta.test_massive_normalizationcCsR|�td��|�tdd��|�tddd��|�tdd��|�td��dS)Nr"rr�)rtrr�rZrrr �	test_boolLs
zTestTimeDelta.test_boolcs�G�fdd�dt���dd�}|�t|���|�|��d��ddd�}|�t|���|�|��d	�||}|�t|�t���|�}|�t|���|�|j|j�|�|j|j�|�|j|j�|�t	|�t	|��|�|��d�dS)
Ncs$eZdZe�fdd��Zdd�ZdS)z0TestTimeDelta.test_subclass_timedelta.<locals>.Tcs�|j|j|j�SrXr=)r���Trr �from_tdVsz8TestTimeDelta.test_subclass_timedelta.<locals>.T.from_tdcSs&|jd|jd|jd}t|�S)Nr�g �@rP)r�r�r�r)r+�sumrrr �as_hoursZs��z9TestTimeDelta.test_subclass_timedelta.<locals>.T.as_hoursN)r4rIrJ�staticmethodrVrXrrTrr rUUsrUr"r�r�r�i��r<i��)
rr|r}r*rXrVr�r�r�r�)r+r$r%�t3�t4rrTr �test_subclass_timedeltaSs 

z%TestTimeDelta.test_subclass_timedeltac	
Cs�Gdd�dt�}|ddd�}tdd�}ddd	�|ddd
�fddd	�|ddd
�fd
dd	�|ddd�fg}|D]B\}}}|�|��(|||�}|�||�|�||�W5QRXqjdS)Nc@seZdZdS)z6TestTimeDelta.test_subclass_date.<locals>.DateSubclassN�r4rIrJrrrr �DateSubclassssr^��r"r?r��addcSs||SrXr�r*r�rrr r�zr�z2TestTimeDelta.test_subclass_date.<locals>.<lambda>rF�raddcSs||SrXrrarrr r�{r��subcSs||SrXrrarrr r�|r�rD)rrr�r*rv)	r+r^�d1r��testsr0�func�expected�actrrr �test_subclass_daters
�
z TestTimeDelta.test_subclass_datec	
Cs�Gdd�dt�}|ddddd�}tddd�}d	d
d�|dddd
�fddd�|dddd
�fddd�|dddd�fg}|D]B\}}}|�|��(|||�}|�||�|�||�W5QRXqvdS)Nc@seZdZdS)z>TestTimeDelta.test_subclass_datetime.<locals>.DateTimeSubclassNr]rrrr �DateTimeSubclass�srjr_r"r?r��)r�rOr`cSs||SrXrrarrr r��r�z6TestTimeDelta.test_subclass_datetime.<locals>.<lambda>rF�
rbcSs||SrXrrarrr r��r�rccSs||SrXrrarrr r��r�rD)rrr�r*rv)	r+rjrdr�rer0rfrgrhrrr �test_subclass_datetime�s�
z$TestTimeDelta.test_subclass_datetimecCs�tdddd�}tdd�}|�||d�|�||d�tdd	d
�}tdd�}|�||d�|�||d�td
�}|�tt||�|�tt||�dS)Nr"r��r�r�gó@i�rBrk�rOr�rNg@r)rr*rlrr	r
)r+r��second�minute�zerotdrrr �
test_division�s

zTestTimeDelta.test_divisioncCs�tddd�}tdd�}||}|�|tdd��tddd�}||}|�|tdd��td�}|�tt||�|�tt|d	�dS�
NrBrkror"rNr�r@rr#)rr*rlrrrm)r+r�rq�rrrrrr �test_remainder�s
zTestTimeDelta.test_remaindercCs�tddd�}tdd�}t||�\}}|�|d�|�|tdd��tddd�}t||�\}}|�|d�|�|tdd��td�}|�tt||�|�tt|d	�dSrt)r�divmodr*rlrrm)r+r�rq�qrurrrrr �test_divmod�s
zTestTimeDelta.test_divmodc
Cs�dd�}|�t��t�|dd>�W5QRX|�t��t�|dd>�W5QRXdD]L}|�t��t�||�W5QRX|�t��t�||�W5QRXq\dS)NcsG�fdd�dt�}|�S)NcseZdZ�fdd�ZdS)zFTestTimeDelta.test_issue31293.<locals>.get_bad_float.<locals>.BadFloatcs�SrXrrZ��	bad_ratiorr �as_integer_ratio�szWTestTimeDelta.test_issue31293.<locals>.get_bad_float.<locals>.BadFloat.as_integer_ratioN)r4rIrJr|rrzrr �BadFloat�sr})�float)r{r}rrzr �
get_bad_float�sz4TestTimeDelta.test_issue31293.<locals>.get_bad_floatr"r�)r)rL)r"rBr>)rlrmrr�)r+rr{rrr �test_issue31293�szTestTimeDelta.test_issue31293csfG�fdd�dt�}G�fdd�d��G�fdd�dt��dD�] �|j�d���zt|d	�d
�Wntk
rzYnXzt|d	�d�Wntk
r�YnXzt|d	�d�Wnttfk
r�YnXztd	�|d	�Wnttfk
r�YnXz|d	�td	�Wntk
�r(YnXztd	�|d	�Wntk
�rTYnXW5QRXq>dS)
Ncs<eZdZ�fdd�Z�fdd�Z�fdd�Z�fdd�Zd	S)
z-TestTimeDelta.test_issue31752.<locals>.BadIntcs��SrXr�r+�other��Prodrr r�sz5TestTimeDelta.test_issue31752.<locals>.BadInt.__mul__cs��SrXrr�r�rr �__rmul__�sz6TestTimeDelta.test_issue31752.<locals>.BadInt.__rmul__cs��SrXrr�r�rr �__floordiv__�sz:TestTimeDelta.test_issue31752.<locals>.BadInt.__floordiv__cs��SrXrr�r�rr �
__rfloordiv__�sz;TestTimeDelta.test_issue31752.<locals>.BadInt.__rfloordiv__N)r4rIrJrr�r�r�rr�rr �BadInt�sr�cs$eZdZ�fdd�Z�fdd�ZdS)z+TestTimeDelta.test_issue31752.<locals>.Prodcs��SrXrr���Sumrr rF�sz3TestTimeDelta.test_issue31752.<locals>.Prod.__add__cs��SrXrr�r�rr �__radd__�sz4TestTimeDelta.test_issue31752.<locals>.Prod.__radd__N)r4rIrJrFr�rr�rr r��sr�cseZdZ�fdd�ZdS)z*TestTimeDelta.test_issue31752.<locals>.Sumcs�SrXrr���divmodresultrr �
__divmod__�sz5TestTimeDelta.test_issue31752.<locals>.Sum.__divmod__N)r4rIrJr�rr�rr r��sr�)Nr)rr"rB)rr�r�r"r�r�r�)rQr�rrmr�)r+r�r)r�r�r�r �test_issue31752�s:

zTestTimeDelta.test_issue31752N)"r4rIrJrr�r�rrrZrequires_IEEE_754rrrr&r+r/r4r�r�r@rBrIrLrQrRrSr\rirmrsrvryr�r�rrrr r��s<S

(	
!r�c@seZdZdd�ZdS)�TestDateOnlycCs�tddd�}tdddddd�}t|j�}|�|td��||}|�|||�||}|�|||�||}|�|||�|}t|j�}|�|td��||}|�|||�||}|�|||�||}|�|||�dS)	N��r"rBr>rDr?r6r@)rrr�r*)r+r]r�r��dt2rrr �test_delta_non_days_ignoreds*
�

z(TestDateOnly.test_delta_non_days_ignoredN)r4rIrJr�rrrr r�sr�c@seZdZdZdS)�SubclassDater"N�r4rIrJZsub_varrrrr r�7sr�c@sXeZdZeZdd�Zdd�Zdd�Zdd�Zd	d
�Z	dd�Z
d
d�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3d4�Zd5d6�Zd7d8�Z d9d:�Z!d;d<�Z"d=d>�Z#d?d@�Z$dAdB�Z%dCdD�Z&dEdF�Z'dGdH�Z(dIdJ�Z)dKdL�Z*dMdN�Z+dOdP�Z,dQdR�Z-dSS)T�TestDatecCs<|�ddd�}|�|jd�|�|jd�|�|jd�dS)N��r>r")r�r*�year�monthrHr\rrr r@szTestDate.test_basic_attributescCsz|�ddd�|j��fD]\}t|�}|�|�d��|dd�}t|�}|�||�|�|j|j|j	�}|�||�qdS)Nr"rBr>r7r>)
r��todayr�rtr.r�r*r�r�rH�r+r]r?r�rrr r@Fs�zTestDate.test_roundtripc
Cs�dD]�\}}}}|�|||�}|�||���|j�|�}|�||�t|d�r|�|jd�|�|jd�|�|jd�|�|jd�qt	t
tdd�D]|}|�|dd�}|��}|j�|�}|�||�|dkr�|j�|d�}|�|ddd�}|�||�|�|��|d�q�dddd	dd	ddd	dd	dg}d
D]�\}}	|�|dd���}tt	dd�|�D]r\}
}|
dk�r�|	�r�|d7}t	d|d�D]@}|�||
|�}|�|��|�|�||j�|��|d7}�q��qb�q8dS)
N))r"r"r"r")r"r�rr)rBr"r"�n)i�rjr�i��
�hourrr"rAr�r�rk))r�T)r�FrlrB)
r�r*�	toordinal�fromordinal�hasattrr�rqrp�microsecondrrr�zip)
r+�y�mr*�nZfromordr��d2ZdimZisleapr�ZmaxdayrHrrr �test_ordinal_conversionsTs>
z!TestDate.test_ordinal_conversionscs|jj�|��j�j�j����������}|��|�|�t	��fdd���t
dd�}|�|���d�|�||j��d��|jj�|��j�j�j����������}|��|�|�t	��fdd���t
dd�}|�|���d�|�||j��d��dS)Ncs���d�SrJ�r�r�rZaordrr r��r�z0TestDate.test_extreme_ordinals.<locals>.<lambda>r"r�cs���d�SrJr�rr�rr r��r�)r�r�r�r�rHr�r�r*rlr�rrp)r+rrr�r �test_extreme_ordinals�s$

zTestDate.test_extreme_ordinalscCs6|�tdd�|�tdd�|�t|jtddd�|�t|jtddd�|�ddd�|�ddd�|�t|jddd�|�t|jddd�|�ddd�|�ddd�|�d	dd�|�t|jddd
�|�t|jddd�|�t|jddd�|�t|jd
dd�|�t|jddd�|�t|jddd�dS)Nr"r�r�rrlrB����`	rk���4�lrk)r�rrrlr�rZrrr �test_bad_constructor_arguments�s"z'TestDate.test_bad_constructor_argumentscCs�|�ddd�}|�ddd�}|�||�|�t|�t|��|di}d||<|�t|�d�|�||d�|�||d�|�ddd�}|�ddd�}|�||�|�t|�t|��|di}d||<|�t|�d�|�||d�|�||d�dS)Nr�r�rr"rBr��r�r*r(r)�r+r*�eZdicrrr r+�s$zTestDate.test_hash_equalityc	s2|�ddd��|�ddd�}|�ddd�}�|}|�|jdttddd���|�|jd	�|�|jd	�td��td
�}|�ddd��|���|�ddd��|���|�ddd��|���|�ddd��|���|�ddd��|��||�ddd��|��||�ddd
��|��d||�ddd��|��d||�ddd��|��|�|�|������|��|�|�|������|���||�|������|���||�|������|�||���dD]^�|�t	��fdd��|�t	��fdd��|�t	��fdd��|�t	��fdd���q$|�t	��fdd��|�t	��fdd��|�t	��fdd��|�t	��fdd��|�t	��fdd��|�t	�fdd��|�t	�fdd��|�t	�fdd��dS)Nr�r"r�r�rB�ArDrrAr>r>r��4��rcs��SrXrrrrr r��r�z,TestDate.test_computations.<locals>.<lambda>cs��SrXrrrrr r��r�cs��SrXrrrrr r��r�cs��SrXrrrrr r��r�cs��SrXrr�rrHrr r��r�cs��SrXrrr�rr r��r�cs��SrXrrr�rr r��r�cs��SrXrrr�rr r��r�cs��SrXrrr�rr r��r�cs��SrXrrrrr r��r�cs��SrXrrrrr r��r�cs��SrXrrrrr r��r��
r�r*r�r)rr�r�rrlrm)r+rr�diff�weekr�rrHr
r r�sPzTestDate.test_computationscCs�|jj}|td�td�fD]p}|jj|}||8}|�t|j|�|�t|j|�|jj|}||7}|�t|j|�|�t|j|�qdS)Nr"rB)	r�rArr�rlrDrErFrp)r+rGr�r]rrr rI�szTestDate.test_overflowcCshddl}d\}}}|�|||ddddddf	�}|j�|�}|�|j|�|�|j|�|�|j|�dS)Nr)i�r>rnr�)r�mktimer��
fromtimestampr*r�r�rH)r+rr�r�rH�tsr*rrr �test_fromtimestamps
zTestDate.test_fromtimestampcCs dD]}|�t|jj|�qdS�N)gZb���t�gZb���ti�rlrDr�r��r+Zinsanerrr �test_insane_fromtimestamps�z"TestDate.test_insane_fromtimestampcCslddl}td�D]8}|j��}|��}|j�|�}||kr>qJ|�d�q||krh|j||tdd�d�dS)Nrr>g�������?r�r�)r�)rrr�r�r��sleepZassertAlmostEqualr)r+rr�r�r�Z
todayagainrrr �
test_todays
�zTestDate.test_todayc	Cs�td�D]�}|�|�ddd|���|�|�|�ddd|���|d�|�|�ddd|���|�|�|�ddd|���|d�qdS)NrAr�r>rDr"r�rB)rr*r��weekdayZ
isoweekday)r+r
rrr �test_weekday<s
"zTestDate.test_weekdaycCs$td�D�]}|�ddd|�}|�|��dd|df�|�ddd�t|�}|�|��dd|df�|�ddd	|�}|�|��dd
|df�|�ddd|�}|�|��dd|df�|�ddd
�t|�}|�|��dd|df�|�ddd|�}|�|��dd|df�qdS)NrAr�r��r�r"r�r�r?rB��rir��5r�rD)rr�r*�isocalendarr)r+r
r*rrr �test_isocalendarEszTestDate.test_isocalendarcCs�d}ttt|����}g}td�D]f}|�d|dd�}|�d|dd�}|�|��dd�|��dd��|��ddkr"|�|�q"|�||�dS)	NaK
              4   32   60   88
              9   37   65   93
             15   43   71   99
             20   48   76
             26   54   82

            105  133  161  189
            111  139  167  195
            116  144  172
            122  150  178
            128  156  184

            201  229  257  285
            207  235  263  291
            212  240  268  296
            218  246  274
            224  252  280

            303  331  359  387
            308  336  364  392
            314  342  370  398
            320  348  376
            325  353  381
        i�r�r�ri@r"r�)	�sorted�maprQ�splitrr�r*r��append)r+ZISO_LONG_YEARS_TABLEZiso_long_years�Lr
r*rdrrr �test_iso_long_yearsVs$zTestDate.test_iso_long_yearscCs"|�ddd�}|�|��d�dS)NrBr>z
0002-03-02)r�r*�	isoformat�r+r�rrr �test_isoformat|szTestDate.test_isoformatcCs"|�ddd�}|�|��d�dS)Nr�r>rBzSat Mar  2 00:00:00 2002)r�r*�ctimer�rrr �
test_ctime�szTestDate.test_ctimec	Cs�|�ddd�}|�|�d�d�|�|�d�d�|�|�d�d�|�t|j�|�t|jdd	�|�t|jd
�|�|�d�d�|�|�d
�d�dD](}z|�|�Wq�tk
r�Yq�Xq�z|�d�Wntk
r�YnX|�d�dS)N��r>rB�m:%m d:%d y:%yzm:03 d:02 y:05r�A�xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx�oneZtworL�%mZ03�	'%z' '%Z'�'' '')z%e�%z%#u%y�%mz%f)r�r*�strftimerlrmr��UnicodeEncodeError)r+r��frrr �
test_strftime�s&
zTestDate.test_strftimecCs||�ddd�}zt�d�Wntk
r:|�d�YnX|�|�d�t�d|����|�|�d�t�d|����dS)Nr�r>rBr�z'time module does not support trailing %zm:%m d:%d y:%y %zm:03 d:02 y:05 %)r��_timer�r�r5r*�	timetupler�rrr �test_strftime_trailing_percent�s�z'TestDate.test_strftime_trailing_percentc	Cs�|�ddd�}|�|�d�t|��|�td��|�d�W5QRXGdd�d|j�}|ddd�}|�|�d�d�Gd	d
�d
|j�}|ddd�}|�|�d�t|��dD]F}|�|�|�|�|��|�|�|�|�|��|�|�|�d
�q�dS)N��r>r#r��must be str, not int�{c@seZdZdd�ZdS)zTestDate.test_format.<locals>.AcSsdS�N�ArrZrrr �__str__�sz'TestDate.test_format.<locals>.A.__str__N�r4rIrJr�rrrr r��sr�c@seZdZdd�ZdS)zTestDate.test_format.<locals>.BcSsdS�N�Br�r+�format_specrrr r��sz(TestDate.test_format.<locals>.B.strftimeN�r4rIrJr�rrrr r��sr��r�zm:%m d:%d y:%y H:%H M:%M S:%S�%z %Z�r�r*�
__format__r��assertRaisesRegexrmr��r+r]r�rr�r�fmtrrr �test_format�szTestDate.test_formatcCs`t|jt�rt}nt}|�|jj|�|�|jj|�|�|jjt�|�	|jj|jjk�dSrX)
rur�rrrvr�rprArrt)r+Zexpected_classrrr rB�szTestDate.test_resolution_infocCsz|jj|jj}|jdd|jd|j}tdd|�}|�||�|�|jj||jj�|�|jj||jj�dS)Nr���@Br)r�rpr�r�r�r�rr*)r+�bigr�Z	justasbigrrr �test_extreme_timedelta�szTestDate.test_extreme_timedeltac
Csrtd�D�]b}|�ddd|�}|��}|�|ddd|ddd|d|df	�|�ddd|�}|��}|�|ddd|dddd|dd|df	�|�ddd|�}|��}|�|ddd|dddd|dd	|df	�|�|jd�|�|jd�|�|jd|�|�|jd�|�|jd�|�|j	d�|�|j
d|d�|�|jd	|�|�|jd�qdS)
NrAr�r"rBrr�rkr>�=)
rr�r�r*�tm_year�tm_mon�tm_mday�tm_hour�tm_min�tm_sec�tm_wday�tm_yday�tm_isdst)r+r
r*r�rrr �test_timetuple�s&&..zTestDate.test_timetuplecCsZd}|j|�}tD],\}}}|�||�}|�|�}|�||�q|�|��|�d��dS)N�rFrAr�rB�r�r~rr�r*�
__reduce__�
__reduce_ex__r.rrr r/s

zTestDate.test_picklingcCsHdddg}d}|j|�}|D]&}tD]}||dd�}|�||�q$qdS)Ns'cdatetime
date
(S'\x07\xdf\x0b\x1b'
tR.scdatetime
date
(U�tR.s�cdatetime
date
U��R.)��rj��latin1��encoding�r��pickle_loadsr*�r+rer�rg�datar�r�rrr �test_compat_unpickles�
zTestDate.test_compat_unpicklecs|�ddd��|�ddd�}|��|�|��|k�|��|k�|��|k�|��|k�|��|k�dD]�}|j|�}|��|k�|�|�k�|��|k�|�|�k�|��|k�|�|�k�|��|k�|�|�k�|��|k�|�|�k�|��|k�|�|�k�qrtD]�|���kd�|���kd�|���kd�|���kd�|�t��fdd��|�t��fd	d��|�t��fd
d��|�t��fdd��|�t��fdd��|�t��fd
d��|�t��fdd���q.dS)NrBr>rDr0FTcs��kSrXrrr1rr r�;r�z'TestDate.test_compare.<locals>.<lambda>cs��kSrXrrr1rr r�<r�cs��kSrXrrr1rr r�=r�cs��kSrXrrr1rr r�>r�cs��kSrXrrr1rr r�?r�cs��kSrXrrr1rr r�@r�cs��kSrXrrr1rr r�Ar�)r�r*rtr�r2rlrmr3rr1r r4sD
zTestDate.test_comparecs�|�ddd��|��dkd�|�d�kd�|��dkd�|�d�kd�|�t�fdd��|�t�fd	d��Gd
d�d�}|��|���kd�|���kd�|���kd�|���kd�|�t��fdd��|�t��fd
d��dS)Nr�rDr?r"FTcs�dkSrJrr��ourrr r�Mr�z-TestDate.test_mixed_compare.<locals>.<lambda>csd�kSrJrrrrr r�Nr�c@seZdZdS)z.TestDate.test_mixed_compare.<locals>.SomeClassNr]rrrr �	SomeClassRsrcs��kSrXrr�rZtheirrr r�Zr�cs��kSrXrrrrr r�[r�)r�r*rlrm)r+rrrr �test_mixed_compareCszTestDate.test_mixed_comparecCs |�|jj�|�|jj�dSrX)rtr�r�rprZrrr rS]szTestDate.test_boolcCsZdD]P}|�|dd�}|�d�d|kr|�|�d�d|�|�|�d�d|�qdS)N)r"r'r��cr i�r��r"z%Yz%04d�%dz%4Y)r�r�r*)r+r�r*rrr �test_strftime_y2kbs
zTestDate.test_strftime_y2kc
Cs�|j}dddg}||�}|�||���d}dD]H\}}|dd�}|||<||�}|jf||i�}	|�||	�|d7}q0|ddd�}|jt|jdd	�dS)
Nr"rBr>r)�r�rB�r�r>�rHrDr�r�r��r��r�r*r�rlr��
r+�clsr��baser
r0�newval�newargsrg�gotrrr �test_replaceos

zTestDate.test_replacecCs:Gdd�d|j�}|ddd�}|�t|jdd��|�dS)Nc@seZdZdS)z4TestDate.test_subclass_replace.<locals>.DateSubclassNr]rrrr r^�sr^��r"i�r&�r�r|r}r�)r+r^r]rrr �test_subclass_replace�szTestDate.test_subclass_replacecs�G�fdd�d�j�}d}�j|�}||ddi�}��|j|���|jd���|jd���|��|�����|�d�|j|jd�dS)Ncs$eZdZdZ�fdd�Zdd�ZdS)z&TestDate.test_subclass_date.<locals>.CrLcs0|��}|�d�}�jj|f|�|�}||_|S�Nr��r��popr�r{r��r)r��kwsZtempr��resultrZrr r{�s

z.TestDate.test_subclass_date.<locals>.C.__new__cSs||j|jSrX)r�r��r+�startrrr �newmeth�sz.TestDate.test_subclass_date.<locals>.C.newmethN�r4rIrJ�	theAnswerr{r:rrZrr �C�sr=�r�rDr�r�rArLrC)	r�r*r3r<r�r�r:r�r��r+r=r�rnr�rrZr ri�s

zTestDate.test_subclass_datec
s�G�fdd�d�j�}d}d}d}||�}��||���|jd�t�|td����}d|ffd	|ffd
|ffg}|D]l\}}	||fD]Z}
�jt	|
�|d��>t
|
|�}||	�}��||���||���|jd�W5QRXq�qxdS)NcseZdZ�fdd�ZdS)zCTestDate.test_subclass_alternate_constructors.<locals>.DateSubclasscs�jj|f|�|�}d|_|S�NrA�r�r{r��r)r��kwargsr7rZrr r{�szKTestDate.test_subclass_alternate_constructors.<locals>.DateSubclass.__new__N�r4rIrJr{rrZrr r^�sr^r>i�(z
2003-04-14rArr�r��
fromisoformat�Z
base_obj_type�constr_name)r�rvr*r�r�combiner�	timestampr�r}�getattr)
r+r^r�Zd_ord�d_isoformat�base_dr��
test_casesrG�constr_args�base_obj�constrr]rrZr �$test_subclass_alternate_constructors�s,�
�
z-TestDate.test_subclass_alternate_constructorscCsRd}t|�}tD]<\}}}|�||�}|�|�}|�||�|�t|t��qdS)Nr)r�r~rr�r*rtrPr.rrr �test_pickling_subclass_date�s
z$TestDate.test_pickling_subclass_datec	Cs�d}t|jt�s|dd�}dD],}|�t|j|dd�||dd��q t|jt�r�|�td�� |�tdgt|��d�W5QRXtdd	�D],}|�|dd�t|g�|dd��q�dS)
Ns
1995-03-25rD)�9��
��rBr>�^bad tzinfo state arg$r"r�rl)	rur�rrlrmr��bytesr)r)r+r*Z
month_byteZord_byterrr �test_backdoor_resistance�s	
�$z!TestDate.test_backdoor_resistancec
Csfdddddddg}|D]J}|j|�}|��}|j|d��"|j�|���}|�||�W5QRXqdS)	N�r"r"r")r�rBr��r�r"r")r�rBr��r�rjr�)r�rDr>�i�r?rk)�dt_str�r�r�r�rEr*)r+�
base_dates�dt_tupler]r^�dt_rtrrr �test_fromisoformat�s�

zTestDate.test_fromisoformatcCs<Gdd�d|j�}|ddd�}|�|���}|�||�dS)Nc@seZdZdS)z:TestDate.test_fromisoformat_subclass.<locals>.DateSubclassNr]rrrr r^
sr^rhr�r�)r�rEr�rv)r+r^r]rbrrr �test_fromisoformat_subclass	sz$TestDate.test_fromisoformat_subclasscCsJddddddddd	d
dg}|D]&}|�t��|j�|�W5QRXqdS)Nr�r�z	009-03-04Z	123456789z
200a-12-04z
2009-1a-04z
2009-12-0az
2009-01-32z
2009-02-29Z20090228u2009�02�28)rlr�r�rE�r+Zbad_strs�bad_strrrr �test_fromisoformat_failss�z!TestDate.test_fromisoformat_failsc
CsHddl}dd|�d�g}|D]&}|�t��|j�|�W5QRXqdS)Nrs
2009-03-01z
2009-03-01��io�StringIOrlrmr�rE�r+riZ	bad_typesZbad_typerrr �"test_fromisoformat_fails_typeerror's
z+TestDate.test_fromisoformat_fails_typeerrorcCs~ddddddddd	d
ddd
tddftddfg}|D]F}|j|d��0|j|�}|��}|jj|�}|�||�W5QRXq2dS)N)��rDr>)r�r"rB)i�r�rk)r�r"rB)r�r�rr[)r�r�r)r�r"r")r�r�r)r�r"r")r�r�rrZ)r(r�rr"r�r)�	datecomps)rrr�r�r��fromisocalendarr*)r+ZdatesrnZdobj�isocalZd_roundtriprrr �test_fromisocalendar0s,�
zTestDate.test_fromisocalendarc
Csfddddddddd	d
ddd
g
}|D]>}|j|d��(|�t��|jj|�W5QRXW5QRXq"dS)N)��rr")rrr�r")rr�6r")rrr"r)rrr"r�)rrr"�)rrr�r")r�r"r")rr"r")i��r"r")�r"r")rrrur")rrr"ru�rp)r�rlr�r�ro)r+�isocalsrprrr �!test_fromisocalendar_value_errorsNs$�z*TestDate.test_fromisocalendar_value_errorscCs�ttdd�g}g}d}td�D]4}|D]*}t|�}|||�||<|�t|��q&q|D]>}|j|d��(|�t��|j	j
|�W5QRXW5QRXqXdS)NcSsdSrXr)�xrrr r�hr�z;TestDate.test_fromisocalendar_type_errors.<locals>.<lambda>)rrr"r"r>rv)r�r~r�listr��tupler�rlrmr�ro)r+Z
err_txformersrwr*r
ZtxformerZerr_valrprrr � test_fromisocalendar_type_errorsds�	z)TestDate.test_fromisocalendar_type_errorsN).r4rIrJrr�rr@r�r�r�r+rrIr�r�r�r�r�r�r�r�r�r�r�rBrrr/rr4rrSr"r.r1rirQrRrYrcrdrgrlrqrxr|rrrr r�:sT/2		&'
	
'
,

	r�c@seZdZdZdS)�SubclassDatetimer"Nr�rrrr r}sr}c@s�eZdZeZdd�Zdd�Zdd�Zdd�Zd	d
�Z	dd�Z
d
d�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Ze�d)�d*d+��Zd,d-�Ze�d.�d/d0��Zd1d2�Zd3d4�Zd5d6�Z e!�"e#j$d7kd8�d9d:��Z%e!�"e#j$d7kd8�d;d<��Z&d=d>�Z'd?d@�Z(dAdB�Z)dCdD�Z*dEdF�Z+dGdH�Z,dIdJ�Z-dKdL�Z.e�dM�dNdO��Z/dPdQ�Z0dRdS�Z1dTdU�Z2dVdW�Z3dXdY�Z4dZd[�Z5d\d]�Z6d^d_�Z7d`da�Z8dbdc�Z9ddde�Z:dfdg�Z;dhS)i�TestDateTimecCsx|�ddddd�}|�|jd�|�|jd�|�|jd�|�|jd�|�|jd�|�|jd�|�|jd�dS)Nr�r>r"r�r�	r�r*r�r�rHr�rqrpr�r\rrr r�sz"TestDateTime.test_basic_attributesc	Cs||�ddddddd�}|�|jd�|�|jd�|�|jd�|�|jd�|�|jd�|�|jd�|�|jd�dS)Nr�r>r"r�r��@rr\rrr �test_basic_attributes_nonzero�sz*TestDateTime.test_basic_attributes_nonzeroc
Cs�|�ddddddd�|j��fD]l}t|�}|�|�d��|d	d�}t|�}|�||�|�|j|j|j	|j
|j|j|j
�}|�||�q dS)
Nr"rBr>rDr?rFrAr7r>)r�rwr�rtr.r�r*r�r�rHr�rqrpr�r�rrr r@�s��zTestDateTime.test_roundtripc
Csb|�ddddddd�}|�|��d�|�|�d�d�|�|�d	�d
�|�|�d�d�|�|�d
�d�|�|jdd�d�|�|jdd�d�|�|jdd�d�|�|jdd�d�|�|jdd�d�|�|jdd�d�|�|jd	dd�d�|jt|jdd�|jt|jd
d�|�t|�d
�|jdddddddtjd�}|�|jdd�d�|�ddddddd�}|�|jdd�d �|�dddddd�}|�|jdd�d�|�|jdd�d�|�|jdd�d!�|�ddd�}|�|��d"�|�|�d�d"�|�|�d	�d#�|�t|�d#�tt	d$d%�d&�}|jddd|d�}|�|��d'�dS)(Nr"rBr>rDr?r�z0001-02-03T04:05:01.000123rU� z0001-02-03 04:05:01.000123�z0001-02-0304:05:01.000123r�u0001-02-03�04:05:01.000123r���timespecz
0001-02-03T04rOz0001-02-03T04:05r�z0001-02-03T04:05:01r�z0001-02-03T04:05:01.000r��auto)�sepr�z0001-02-03 04:05�foo�L@rz0001-02-03T04:05:01.999+00:00z0001-02-03T04:05:01.999z0001-02-03T04:05:01.000000z0002-03-02T00:00:00z0002-03-02 00:00:00�r�ZXXXz0002-03-02T00:00:00+00:00:16)
r�r*r�rlr�r�rr�rKrr�rrr r��sD�zTestDateTime.test_isoformatc	Cs�dtdd�fdtdd�fdtddd	�fd
tddd
d�fdtddddd�fg}ddtjfdttd��fg}|dd�|D�7}|�dddddd�}d}|D]D\}}|j|d�}||}|j|d��|��|ks�t�W5QRXq�dS)N�05:00r?r��02:00rB�06:27rFrr��12:32:30r�rkrkr��02:04:09.123456rDr>r�r��r�N�+00:00rcSs2g|]*\}}dD]\}}||t||�f�qqS�))�-r�)�+r"r�rrgr��prefix�signrrr r!�s�z8TestDateTime.test_isoformat_timezone.<locals>.<listcomp>rmr"�%z2016-04-01T12:37:09r��tzi�rrr�r�r�r�r��AssertionError)	r+�	tzoffsets�tzinfosZdt_base�exp_base�exp_tzr�r]�exprrr �test_isoformat_timezone�s(�	��z$TestDateTime.test_isoformat_timezonec	Cs|�ddddddd�}|�|�d�t|��|�td	��|�d�W5QRXGd
d�d|j�}|ddddddd�}|�|�d�d�Gdd
�d
|j�}|ddddddd�}|�|�d�t|��dD]F}|�|�|�|�|��|�|�|�|�|��|�|�|�d
�q�dS)Nr�r>r#rDr?r"r�r�r�c@seZdZdd�ZdS)z#TestDateTime.test_format.<locals>.AcSsdSr�rrZrrr r��sz+TestDateTime.test_format.<locals>.A.__str__Nr�rrrr r��sr�c@seZdZdd�ZdS)z#TestDateTime.test_format.<locals>.BcSsdSr�rr�rrr r�sz,TestDateTime.test_format.<locals>.B.strftimeNr�rrrr r�sr�r�r�r�rrr r��szTestDateTime.test_formatc	Cshddl}|�ddddddd�}|�|��d�|�ddd	dddd�}|�|��|�|�|�����dS)
Nrr�r>rB�r?r�zSat Mar  2 18:03:05 2002r�)rr�r*r�r�r�)r+rr�rrr �test_more_ctimes
zTestDateTime.test_more_ctimec	Cs�|�dddddd�}|�dddddd�}|�dddddd�}|�||�|�||k�|�tddd	d
d
d�}tdd�}||}|�|||�|�||k�dS)
Nr�r>r"r>rr#r�rr�r�rr�)r�r*rtrr)r+rnr��dt3r	rrr �test_tz_independent_comparing#s
z*TestDateTime.test_tz_independent_comparingcCsBGdd�dt�}|�ddddddd|dd��}|�t|jd�dS)	Nc@seZdZdd�ZdS)zDTestDateTime.test_strftime_with_bad_tzname_replace.<locals>.MyTzInfocSsGdd�dt�}|d�S)Nc@seZdZdd�ZdS)zZTestDateTime.test_strftime_with_bad_tzname_replace.<locals>.MyTzInfo.tzname.<locals>.MyStrcWsdSrXr)r+r�rrr r�:szbTestDateTime.test_strftime_with_bad_tzname_replace.<locals>.MyTzInfo.tzname.<locals>.MyStr.replaceN)r4rIrJr�rrrr �MyStr9sr�r0)r�)r+r]r�rrr r_8szKTestDateTime.test_strftime_with_bad_tzname_replace.<locals>.MyTzInfo.tznameN)r4rIrJr_rrrr �MyTzInfo7sr�r�r>rBrr0�%Z)rKr�rlrmr�)r+r�r�rrr �%test_strftime_with_bad_tzname_replace5sz2TestDateTime.test_strftime_with_bad_tzname_replacec
Cs�|�tdd�|�tdd�|�t|jtddd�|�t|jtddd�|�ddd�|�ddd�|�t|jddd�|�t|jddd�|�ddd�|�ddd�|�d	dd�|�t|jddd
�|�t|jddd�|�t|jddd�|�t|jd
dd�|�t|jddd�|�t|jddd�|�dddd�|�dddd�|�t|jdddd�|�t|jdddd�|�ddddd�|�ddddd�|�t|jddddd�|�t|jddddd�|�dddddd�|�dddddd�|�t|jdddddd�|�t|jdddddd�|�ddddddd�|�ddddddd�|�t|jddddddd�	|�t|jddddddd�	|jt|jddddd�|jt|jddddd�|�t|jddddddddd�dS)Nr"r�r�rrlrBr�r�r�rkr�r�r�rkrr�r�r�r�r�r�r���fold)r�rrrlr�rmrZrrr r�@s�
�
�
�
�
�z+TestDateTime.test_bad_constructor_argumentscCs|�dddddd�}|�dddddd�}|�||�|�t|�t|��|di}d||<|�t|�d�|�||d�|�||d�|�d	ddd
dd�}|�d	ddd
dd�}|�||�|�t|�t|��|di}d||<|�t|�d�|�||d�|�||d�dS)Nr�r�rr�rk�r"rBr�rr?r�r�rrr r+us$zTestDateTime.test_hash_equalitycs<|�ddd��|�ddd�}�|}|�|jdttddd���|�|jd�|�|jd�|�ddd	d
d��tddd�}tdd
�}td��td�}|��||�ddd	dd��|�|�|�ddd	dd��|��d||�ddddd��|��||�ddd	dd��|�|�|�ddd	dd��|��|�|�|��d||�ddddd��|���|�dddd
d��|���|�dddd
d��|��||�dddd
d��|��||�dd	dd
d��|��d||�dddd
d��|��d||�dddd
d��|��|�|�|������|��|�|�|��|�|�|��|�|�|������|��|�|�|��|�|�|���||�|������|���||�|���||�|���||�|������|���||�|���||�|��|�|||�ddddddd��|��|�||�|�||�|��|�|||�dd	ddddd��|��|�||�|�||�dD]^�|�t	��fdd��|�t	��fd d��|�t	��fd!d��|�t	��fd"d���q.|�t	��fd#d��|�t	��fd$d��|�t	��fd%d��|�t	��fd&d��|�t	��fd'd��|�t	�fd(d��|�t	�fd)d��|�t	�fd*d��dS)+Nr�r"rr�r�rDrr>rBr�rFr�r�rAr�r#r�r�rir>r�r�r�r�r�r?r�r�rcs��SrXrrrrr r��r�z0TestDateTime.test_computations.<locals>.<lambda>cs��SrXrrrrr r��r�cs��SrXrrrrr r��r�cs��SrXrrrrr r��r�cs��SrXrrr�rr r��r�cs��SrXrrr�rr r��r�cs��SrXrrr�rr r��r�cs��SrXrrr�rr r��r�cs��SrXrrr�rr r��r�cs��SrXrrrrr r��r�cs��SrXrrrrr r��r�cs��SrXrrrrr r��r�r�)r+rr�Zmillisecr�r�rr�r r�s�
" """����zTestDateTime.test_computationscCsZd}|j|�}tD],\}}}|�||�}|�|�}|�||�q|�|��|�d��dS)N�rFrAr�r�r�r"�rBr
r.rrr r/�s

zTestDateTime.test_picklingc	Csn|�ddddddd�}ttjd�D]D}t�||�}t�|�}|�|jd�|�|jd�|�|j	d�q$dS)	Nr�rBrAr��0r�i��r")
r�rr�HIGHEST_PROTOCOLrr�r*r�r�rH)r+rrr?rrrr �test_more_pickling�s
zTestDateTime.test_more_picklingcCsRd}t|�}tD]<\}}}|�||�}|�|�}|�||�|�t|t��qdS)Nr�)r}r~rr�r*rtrPr.rrr �test_pickling_subclass_datetime�s
z,TestDateTime.test_pickling_subclass_datetimecCsHdddg}d}|j|�}|D]&}tD]}||dd�}|�||�q$qdS)Ns@cdatetime
datetime
(S'\x07\xdf\x0b\x1b\x14;\x01\x00\x10\x00'
tR.s#cdatetime
datetime
(U
�;tR.s$�cdatetime
datetime
U
�;�R.)rrjrr�r�r"r�rrrrrrr r�s�

z!TestDateTime.test_compat_unpicklecCs\dddddddg}|j|�}|j|�}|�||�|�||k�|�||k�|�||k�|�||k�|�||k�tt|��D]�}|dd�}||d||<|j|�}|�||k�|�||k�|�||k�|�||k�|�||k�|�||k�|�||k�|�||k�|�||k�|�||k�|�||k�|�||k�q�dS)	Nr�rjr�r�r5r�rr")r�r*rtr�rr))r+r�r$r%r
r,rrr �test_more_compare�s2


zTestDateTime.test_more_comparecCsd|�|j|j�|�|j|j�|�|j|j�|�|j|j�|�|j	|j
�|�|j|j�dSrX)
r*rr�rr�rrHrr�rrqrrp)r+rgr-rrr �verify_field_equality	sz"TestDateTime.verify_field_equalitycCs6ddl}|��}|�|�}|j�|�}|�||�dS�Nr)r�	localtimer�r�r��r+rr�rgr-rrr r�&	s

zTestDateTime.test_fromtimestampcCs6ddl}|��}|�|�}|j�|�}|�||�dSr�)r�gmtimer��utcfromtimestampr�r�rrr �test_utcfromtimestamp.	s

z"TestDateTime.test_utcfromtimestamp�EST+05EDT,M3.2.0,M11.1.0c	Cs.|�ddd�}|�|��d�|�ddddddd�}|�|��d�|�ddd	dd
�}|jdd�}|�|j�|���|tdd��|�|j�|���|tdd��|�dd	ddd
�}|�|j�|���|�|�ddd�|�d
dd�fD]<}z|��}Wntk
�rYq�X|�|j�|�|�q�dS)Nr r"g��@rBr>rD���6�@r/rjrkr�r�i'r�)r�r*rIr�r�rrD)r+r��t0r$r?rrr �test_timestamp_naive8	s,
��� z!TestDateTime.test_timestamp_naivecCs�|jdddtjd�}|�|��d�|jdddddddtjd�}|�|��d�|jdddddddttd	d
�d�d�}|�|��d�dS)
Nr r"rrrBr>rDg�7��@r�r�r�r�)r�rr�r*rIrr�rrr �test_timestamp_awareT	s
��
�z!TestDateTime.test_timestamp_awarezMSK-03c	Csz|jj|jjfD�]b}|d�}|�|jd�|�|jd�|d�}z|d�}Wntk
rbYn~X|�|jd�|�|jd�|d�}|�||�|d�}|�||�|d�}|�||�|d	�}|�|jd�|�|jd
�|d�}|�||�|d�}|�||�|d
�}|�|jd�|�|jd�|d�}|�|jd�|�|jd�|d�}|�|jd�|�|jd�qdS)Nrg���ư>g���ư�r�r�g:�0�yE�g1E��2��gH�����z�rOi�#gH�����z>g1E��2�>g<"2��?g�P���?r"rMrN)r�r�r�r*rpr��OSError)r+Zftsrr�Z	minus_oner�rrr rQ_	sF�
z&TestDateTime.test_microsecond_roundingc
CsZ|jjjtjd�}|��}z|�|jj|tjd�|�Wn4tt	fk
rl}z|�
t|��W5d}~XYnX|jjjtjddd�}|��}|�|jj|tjd�|�d}||}|�
ttf��|j�|�W5QRX|�
ttf��|j�|�W5QRX|��|}|�
ttf��|j�|�W5QRX|�
ttf��|j�|�W5QRXdS)Nr�r�r)rrpr�iX)r�r�r�rr�rIr*r�rDr�r5r�rprlr�r�)r+Zmin_dtZmin_ts�excZmax_dtZmax_tsr�r�rrr �test_timestamp_limits�	s6� ��z"TestDateTime.test_timestamp_limitscCs dD]}|�t|jj|�qdSr�r�r�rrr r��	s�z&TestDateTime.test_insane_fromtimestampcCs dD]}|�t|jj|�qdSr�)rlrDr�r�r�rrr �test_insane_utcfromtimestamp�	s�z)TestDateTime.test_insane_utcfromtimestamp�win32z*Windows doesn't accept negative timestampscCs|j�d�dS)N��������)r�r�rZrrr �!test_negative_float_fromtimestamp�	sz.TestDateTime.test_negative_float_fromtimestampcCs.|j�d�}|�||�ddddddd��dS)	Nr�i�r�rr�r�r5i�~)r�r�r*)r+r*rrr �$test_negative_float_utcfromtimestamp�	sz1TestDateTime.test_negative_float_utcfromtimestampcCsfddl}tdd�}td�D]2}|j��}|j�|���}t||�|krqNq|�t||�|�dS)Nrr"r�r>)rrrr��utcnowr�rZassertLessEqual)r+rZ	tolerancer�Zfrom_now�from_timestamprrr �test_utcnow�	s

zTestDateTime.test_utcnowc
CsLd}d}t�|j||�}|j�||�}|�||�|�t|�|j�|�t|�|j�dddg}|D]L\}}|j||d��0t�|j||�}|j�||�}|�||�W5QRXqd|jj}|�|dd���d	t	�|�|d
d���dt	�|�|dd���t
d	d
dd��ddtjtj
dffD]z\}}|dk�rFd}	|}
nd}	|}
t|
dd�\}}d�|	|||�}
||
d�}|�|��t
|d��|�|�
�|��q(d\}
}||
|�}|�|��dtdt	�|�|�
�d�|�|�|�|
�|�|dd�jd�|�t��|dd�W5QRX|�t��|dd�W5QRXdS) Nz2004-12-01 13:02:47.197z%Y-%m-%d %H:%M:%S.%f)u2004-12-01�13:02:47.197u%Y-%m-%d�%H:%M:%S.%f)u2004�12-01 13:02:47.197u%Y�%m-%d %H:%M:%S.%f)u2004-12-01 13:02�47.197u%Y-%m-%d %H:%M�%S.%f)�string�formatz+0002�%zrBz-0002r@z-00:02:01.000003r"r>)rOr�r�)rr�)rZGMTrr�r�r�z{}{:02d}{:02d} {}r�r�)z	+1234 UTCr�r�r,r�r�z-2400z-000)�	_strptimeZ_strptime_datetimer��strptimer*r|r}r�r^�MINUTErr�rr_rwr�r�r�rrlr�)r+r�r�rgr-�inputsr�Z	tzsecondsr_r�r�r�rO�dtstrr]r�rrr �
test_strptime�	s`�
���


zTestDateTime.test_strptimec
Cs6|jj}|�t��|dd�}W5QRX|�dddddd�}|�dddddd�}|�dddd	d	d	�}|�ddd
d	d	d	�}ddd|fd
dd|fddd|fddd|fddd|fddd|fddd|fddd|fddd|fd dd!|fg
}|D]L\}}	}
}d"|}|j||	|
|d#�� ||	|
�}|j|||d$�W5QRXq�dS)%Nz01/02/3 04:05:06z%d/%m/%y %H:%M:%Sr�rBr"rDr?rFr�r!z
1/02/03 4:5:6r�z
01/2/03 4:5:6z%Hz01/02/03 4:05:06z%Mz01/02/03 04:5:06z%Sz01/02/03 04:05:6z%jz2/03 04am:05:06z%j/%y %I%p:%M:%Sz%Iz02/03 4am:05:06z%wz6/04/03z%w/%U/%yz%Wz6/4/2003z%u/%W/%Yz%Vz%u/%V/%Gztest single digit )�reasonr�r��target)�msg)r�r�rlr�r�r*)r+r�Znewdaternr�r�Zdt4r�r�r�r�r�rrr �test_strptime_single_digit
s6









�
�
z'TestDateTime.test_strptime_single_digitcCs$|�dddddd�}|�|��d�|�|��|j|j|j|j|j|j|�	�|�
�t|jdd��
�dd	f	�|��}|�|j|j�|�|j
|j�|�|j|j�|�|j|j�|�|j|j�|�|j|j�|�|j|�	��|�|j|�
�t|jdd��
�d�|�|jd	�dS)
Nr�r�rrFr��!)	r�r�rrFr�r�rDr�r�r"r�)r�r*r�r�r�rHr�rqrpr�r�rrrrrrrrr	r
)r+r��ttrrr �test_more_timetuple8
s4
����z TestDateTime.test_more_timetuplec	Cs�|�ddddddd�}|�|�d�d	�d
D]B\\}}}ttd||d��}|j|d
�}|�|�d�d|�q,z|�d�Wntk
r�YnXdS)Nr�r�rrFr�r��/z%m %d %y %f %S %M %H %jz12 31 04 000047 33 22 06 366)))r�r�z	33.000123))r�rZ33rB)r�r�r�rr�z-0200u%y�%m %H�%M)r�r*r�rrr�r�)r+r�r?r	�zr�rrr �test_more_strftimeN
s�zTestDateTime.test_more_strftimec	CsL|�ddddddd�}|�|��tddd��|�|��tdddd��dS)Nr�r>rDr��-��)r�r*rrr\rrr �test_extract^
szTestDateTime.test_extractc	Cs�tddd�}tdddd�}|�ddddddd�}|jj}|||�}|�||�|||d�}|�||�|�||���|�||���|�|||��|����|�t|�|�t||�|�t|||�|�t|||d�|�t|||dd	�|�t|d
d�|�t||d�|�t|d
|�|||tj�}|�	|j
tj�|||tjd�}|�	|j
tj�t�}|||�}|�|��|�|�|��|�dS)
Nr�r>rDr�r�r�)rrr"rBrrr)rrr�rHr*rlrmrr�r|r)r+r*r�rgrHr]rrr �test_combinec
s6

zTestDateTime.test_combinec
Cs�|j}dddddddg}||�}|�||���d}d	D]H\}}|dd�}|||<||�}|jf||i�}	|�||	�|d7}q8|d
dd�}|jt|jdd
�dS)Nr"rBr>rDr?rFrAr)r#r$r%�r�r?�rqrF�rprA�r�rtr�r�r�r&r'r(rrr r.�
s
zTestDateTime.test_replaceZEDT4c	CsF|j��}tdd�}|jttdd�d�d�}|�|��|�|�t	|j||�|�t	|j|�|j|d�tddd�}|�|�|�|�|�|j|d	�|�Gd
d�dt
�}|�}|�t|j|�|�|j|d��|�|�Gdd
�d
t
�}|�}|�t|j|�Gdd�dt
�}	|	�}
|j|
d�}|�t	��|��W5QRXdS)N�,Z0044rEr��EDTrrDr�r�c@seZdZdd�Zdd�ZdS)z+TestDateTime.test_astimezone.<locals>.BoguscSsdSrXrr\rrr r^�
r�z5TestDateTime.test_astimezone.<locals>.Bogus.utcoffsetcSstd�Sr�rr\rrr r`�
r�z/TestDateTime.test_astimezone.<locals>.Bogus.dstN�r4rIrJr^r`rrrr �Bogus�
sr�c@seZdZdd�Zdd�ZdS)z/TestDateTime.test_astimezone.<locals>.AlsoBoguscSstd�Sr�rr\rrr r^�
r�z9TestDateTime.test_astimezone.<locals>.AlsoBogus.utcoffsetcSsdSrXrr\rrr r`�
r�z3TestDateTime.test_astimezone.<locals>.AlsoBogus.dstNr�rrrr �	AlsoBogus�
sr�c@seZdZdd�Zdd�ZdS)z,TestDateTime.test_astimezone.<locals>.BrokencSsdSrJrr\rrr r^�
r�z6TestDateTime.test_astimezone.<locals>.Broken.utcoffsetcSsdSrJrr\rrr r`�
r�z0TestDateTime.test_astimezone.<locals>.Broken.dstNr�rrrr �Broken�
sr�)r�rwrKr�rrr*�
astimezonerlrmrr�)r+r]r��dt_utcZdt_fr�Zbogr�Zalsobogr��brokenZ	dt_brokenrrr �test_astimezone�
s*

zTestDateTime.test_astimezonecs�G�fdd�d�j�}d}�j|�}||ddi�}��|j|���|jd���|jd���|��|�����|�d�|j|j|j	d�dS)Ncs$eZdZdZ�fdd�Zdd�ZdS)z.TestDateTime.test_subclass_datetime.<locals>.CrLcs0|��}|�d�}�jj|f|�|�}||_|Sr2r3r5rZrr r{�
s

z6TestDateTime.test_subclass_datetime.<locals>.C.__new__cSs||j|j|jSrX)r�r�rpr8rrr r:�
sz6TestDateTime.test_subclass_datetime.<locals>.C.newmethNr;rrZrr r=�
sr=)r�rDr�r�rl�)r�rArLrC)
r�r*r3r<r�r�r:r�r�rpr?rrZr rm�
s

��z#TestDateTime.test_subclass_datetimecs,G�fdd�d�j�}d}d}d}||�}��||���|jd�|��}d|f|fd|tjf|�tj�fd|f|fd	|f|fd
|df|fdt|d
d��t	|dd��f|fg}|D]n\}}	}
||fD]Z}�j
t|�|d��>t||�}||	�}
��|
|���|
|
���|
jd�W5QRXq�q�dS)NcseZdZ�fdd�ZdS)zTTestDateTime.test_subclass_alternate_constructors_datetime.<locals>.DateTimeSubclasscs�jj|f|�|�}d|_|Sr@rArBrZrr r{�
sz\TestDateTime.test_subclass_alternate_constructors_datetime.<locals>.DateTimeSubclass.__new__NrDrrZrr rj�
srj)r�rDr�r�rk�r�z2003-04-14T12:30:15.123456gh͏�TM�ArAr�r�rEr�z%Y-%m-%dT%H:%M:%S.%frHrr>rF)
r�rvr*r�rIrr�r�rrr�r}rJ)r+rjr�rKZutc_tsrLr�rMrGrNrgrO�constructorr]rrZr �-test_subclass_alternate_constructors_datetime�
s6


�

$�
�
z:TestDateTime.test_subclass_alternate_constructors_datetimec
s�G�fdd�d�j�}ddifddifdddtjifdddttdd	�d
�ifg}|D]N\}}}��|��4t||�}|f|�}��||���|jd�W5QRXqTdS)NcseZdZ�fdd�ZdS)z8TestDateTime.test_subclass_now.<locals>.DateTimeSubclasscs�jj|f|�|�}d|_|Sr@rArBrZrr r{sz@TestDateTime.test_subclass_now.<locals>.DateTimeSubclass.__new__NrDrrZrr rj
srjrwr�Znow_utcr�Z	now_fixedr�r�r�rA)	r�rr�rr�rJrvr*r�)r+rjrMr0Z	meth_namerCrPr]rrZr �test_subclass_nows�

zTestDateTime.test_subclass_nowcs�ddddg}ddddg�d	d
g}dtjttdd��ttd
d��g����fdd�|D�}|D]J}|D]@}|j|d�}�j|d���j�|�}��||�W5QRXqdq\dS)NrZr[r\r]�rrrr)rrrih�)rrr�G�)r�rkr�r�r�rUr�r�rBcs4g|],}�D]"}�D]}�j||�d|i��qqqSr)r�)rZ
date_tupleZ
time_tupler��Z
base_timesr+r�rr r!9s�z<TestDateTime.test_fromisoformat_datetime.<locals>.<listcomp>�r��r�)rr�rr�r�r�rEr*)r+r`�
separators�dtsr]r�r�rbrr�r �test_fromisoformat_datetime#s0����z(TestDateTime.test_fromisoformat_datetimec
Cs�|�ddddddd�}tdd�tdd�td	d
d�tdddd
�tddddd�g}|dd�|D�7}dtjttdd��g}|dd�|D�7}|D]L}|j|d�}|��}|j|d��"|j�|�}||ks�t|��W5QRXq�dS)Nrhr�rkr��pQr?r�rBrFrr�rkr�rDr>r�r�cSsg|]}d|�qS�r�r�rr�rrr r!Psz<TestDateTime.test_fromisoformat_timezone.<locals>.<listcomp>rcSsg|]}t|��qSrrrrrr r!Usr��tstr�	r�rrr�r�r�r�rEr�)r+Zbase_dtr�r�r�r]r�rbrrr �test_fromisoformat_timezoneFs$
��z(TestDateTime.test_fromisoformat_timezonec
Csvddddddddd	g	}|D]V}|�d
ddd
ddd�}|j|d�}|j|d��|j�|�}|�||�W5QRXqdS)Nr�rU��€uʁuᛇu時u🐍r�r_r"rr�r�r�iu�r�r�r_�r+r�r�r]r�rbrrr �test_fromisoformat_separators_s �z*TestDateTime.test_fromisoformat_separatorsc
Csdddg}|D]R}|�ddddd�}|j|d�}|j|d	��|j�|�}|�||�W5QRXqdS)
Nr�r�r_r"rr�r�r�r�r_r	rrr �test_fromisoformat_ambiguouspsz)TestDateTime.test_fromisoformat_ambiguouscCs�ddg}dtjttdd��ttdd��ttddd��g}d	d
ddd
g}t|�D]�\}}|D]�}|D]�}|dkr�d|dd}|dd�|f}|j|dd|�d|i�}	|	j|d�}
|j|
d��|j�|
�}|�|	|�W5QRXqbqZqNdS)N)r�r�rDrtr�r�r�)r�r�rDrtr�r�rr�r�rBrFrr�r�rOr�r�r�r�rrDrr�r��	rr�r�	enumerater�r�r�rEr*)r+Zdatetime_basesr��	timespecs�ipr�r�ra�new_microsecondsr]r�rbrrr �test_fromisoformat_timespecs{s.���z)TestDateTime.test_fromisoformat_timespecscCs�ddddddddd	d
ddd
dddddddddddddddg}|D]>}|j|d��(|�t��|j�|�W5QRXW5QRXq@dS)Nr�r�z
2009.04-19T03z
2009-04.19T03z
2009-04-19T0az2009-04-19T03:1a:45z2009-04-19T03:15:4az2009-04-19T03;15:45z2009-04-19T03:15;45z2009-04-19T03:15:4500:00z2009-04-19T03:15:45.2345z2009-04-19T03:15:45.1234567z 2009-04-19T03:15:45.123456+24:30z 2009-04-19T03:15:45.123456-24:30u2009-04-10ᛇᛇᛇᛇᛇ12:15u2009-04�10T12:15u2009-04-10T12�15z2009-04-19T1z2009-04-19T12:3z2009-04-19T12:30:4z2009-04-19T12:z2009-04-19T12:30:z2009-04-19T12:30:45.z2009-04-19T12:30:45.123456+z2009-04-19T12:30:45.123456-z!2009-04-19T12:30:45.123456-05:00az2009-04-19T12:30:45.123-05:00az2009-04-19T12:30:45-05:00a�rf�r�rlr�r�rErerrr �!test_fromisoformat_fails_datetime�sB�z.TestDateTime.test_fromisoformat_fails_datetimec	Cs6d}|�tt�t|����|j�|�W5QRXdS)Nu2018-01-03�01:0113)r�r��re�escaper�r�rE)r+r�rrr �"test_fromisoformat_fails_surrogate�sz/TestDateTime.test_fromisoformat_fails_surrogatecCs$d}|j�|�}|�|jtj�dS)Nz2014-04-19T13:21:13+00:00)r�rEr|rrr�)r+r^r]rrr �test_fromisoformat_utc�sz#TestDateTime.test_fromisoformat_utcc
Cs`Gdd�d|j�}|ddddddd	ttd
dd��d�}|�|���}|�||�|�||�dS)
Nc@seZdZdS)zBTestDateTime.test_fromisoformat_subclass.<locals>.DateTimeSubclassNr]rrrr rj�srjrhr�r�r>rkr�i��r#r�r)r�rrrEr�r*rv)r+rjr]rbrrr rd�s�z(TestDateTime.test_fromisoformat_subclassN)<r4rIrJrr�rr�r@r�r�r�r�r�r�r�r+rr/r�r�rr�r�r�r�r�run_with_tzr�r�rQr�r�r��unittestZskipIfr2�platformr�r�r�r�r�r�r�r�r�r.r�rmr�r�r�rr
rrrrrrdrrrr r~�sn
,5D			!


()		

:""
 1#&r~c@s"eZdZeZe�d�dd��ZdS)�TestSubclassDateTimeznot appropriate for subclassescCsdSrXrrZrrr r@�sz#TestSubclassDateTime.test_roundtripN)r4rIrJr}r�r�skipr@rrrr r�src@seZdZdZdS)�SubclassTimer"Nr�rrrr r�src@s�eZdZeZdd�Zdd�Zdd�Zdd�Zd	d
�Z	dd�Z
d
d�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-S).�TestTimecCsH|�dd�}|�|jd�|�|jd�|�|jd�|�|jd�dS)Nr�r�r�r*r�rqrpr�r�rrr r�s
zTestTime.test_basic_attributescCsL|�dddd�}|�|jd�|�|jd�|�|jd�|�|jd�dS)Nr�r�r�r r�rrr r��s
z&TestTime.test_basic_attributes_nonzerocCsp|�dddd�}t|�}|�|�d��|dd�}t|�}|�||�|�|j|j|j|j	�}|�||�dS)Nr"rBr>rDr7r>)
r�r�rtr.r�r*r�rqrpr�)r+r�r?r%rrr r@�s�zTestTime.test_roundtripcsRddddg}|j|��|j|�}|��|�|��|k�|��|k�|��|k�|��|k�|��|k�tt|��D]�}|dd�}||d||<|j|�}|��|k�|�|�k�|��|k�|�|�k�|��|k�|�|�k�|��|k�|�|�k�|��|k�|�|�k�|��|k�|�|�k�q~tD]��|���kd�|���kd�|���kd�|���kd�|�t��fdd��|�t��fd	d��|�t��fd
d��|�t��fdd��|�t��fdd��|�t��fd
d��|�t��fdd��|�t��fdd���qVdS)Nr"rBr>rDFTcs��kSrXrrr1rr r�%r�z)TestTime.test_comparing.<locals>.<lambda>cs��kSrXrrr1rr r�&r�cs��kSrXrrr1rr r�'r�cs��kSrXrrr1rr r�(r�cs��kSrXrrr1rr r�)r�cs��kSrXrrr1rr r�*r�cs��kSrXrrr1rr r�+r�cs��kSrXrrr1rr r�,r�)	r�r*rtr�rr)r2rlrm)r+r�r%r
r,rr1r �test_comparingsL


zTestTime.test_comparingcCs|�dd�|�dd�|�t|jdd�|�t|jdd�|�dd�|�dd�|�t|jdd�|�t|jdd�|�ddd�|�ddd�|�t|jddd�|�t|jddd�|�dddd�|�dddd�|�t|jdddd�|�t|jdddd�dS)	Nrr�r�r�r�r�r�r�)r�rlr�rZrrr r�.s z'TestTime.test_bad_constructor_argumentscCs�|�ddd�}|�ddd�}|�||�|�t|�t|��|di}d||<|�t|�d�|�||d�|�||d�|�ddd�}|�ddd�}|�||�|�t|�t|��|di}d||<|�t|�d�|�||d�|�||d�dS)Nr�rkr�r"rBrr?r�r�rrr r+Ds$zTestTime.test_hash_equalitycCs�|�dddd�}|�|��d�|�|��t|��|��}|�|��d�|�|��t|��|jdd�}|�|��d�|�|��t|��|jd	d�}|�|��d
�|�|��t|��|jdd�}|�|��d�|�|��t|��|jd
d�}|�|��d�|�|��t|��|jdd�}|�|��d�|�|��t|��|jdd�}|�|��d�|�|��t|��|jddddd�}|�|jdd�d�|�|jdd�d�|�|jdd�d�|�|jdd�d �|�|jd!d�d"�|�|jd#d�d"�|jt|jd$d�|jt|jd%d�|jdddd&d�}|�|jdd�d'�|jdddd(d�}|�|jdd�d)�|�|jd!d�d*�|�|jd#d�d�dS)+NrDr?r"r�z04:05:01.000123z00:00:00�r�z00:00:00.000001r#z00:00:00.000010r z00:00:00.000100r�z00:00:00.001000r�z00:00:00.010000i��z00:00:00.100000r�r,r-r�)r�rqrpr�r�r�Z12rOz12:34r�z12:34:56r�z12:34:56.123r�z12:34:56.123456r�Zmonkeyr�r�z12:34:56.999rz12:34:56.000z12:34:56.000000)r�r*r�r�rlr�r�rrr r�[sNzTestTime.test_isoformatc	Cs�dtdd�fdtdd�fdtddd	�fd
tddd
d�fdtddddd�fg}ddtjfdttd��fg}|dd�|D�7}|�ddd�}d}|D]D\}}|j|d�}||}|j|d��|��|ks�t�W5QRXq�dS)Nr�r?r�r�rBr�rFrr�r�r�rkrkr�r�rDr>r�r�r�r�rcSs2g|]*\}}dD]\}}||t||�f�qqSr�rr�rrr r!�s�z4TestTime.test_isoformat_timezone.<locals>.<listcomp>r�z12:37:09rr�r�)	r+r�r�Zt_baser�r�r�r�r�rrr r��s(�	��z TestTime.test_isoformat_timezonecCs"|jdd�}|jt|jdd�dS)Nr"�rpr>)r�)r�rlrmr�r�rrr �test_1653736�szTestTime.test_1653736cCs\|�dddd�}|�|�d�d�|�|�d�d�z|�d	�Wntk
rVYnXdS)
Nr"rBr>rDz%H %M %S %fz01 02 03 000004r�r�u%H�%M)r�r*r�r�r�rrr r��szTestTime.test_strftimec	Cs|�dddd�}|�|�d�t|��|�td��|�d�W5QRXGdd	�d	|j�}|dddd�}|�|�d�d	�Gd
d�d|j�}|dddd�}|�|�d�t|��dD]F}|�|�|�|�|��|�|�|�|�|��|�|�|�d�q�dS)
Nr"rBr>rDr�r�r�c@seZdZdd�ZdS)zTestTime.test_format.<locals>.AcSsdSr�rrZrrr r��sz'TestTime.test_format.<locals>.A.__str__Nr�rrrr r��sr�c@seZdZdd�ZdS)zTestTime.test_format.<locals>.BcSsdSr�rr�rrr r��sz(TestTime.test_format.<locals>.B.strftimeNr�rrrr r��sr�)z%H %M %Sr�)r+r�r�rr�rr�rrr r��szTestTime.test_formatc	Cs�|�t|�dddd��d�|�t|�dddd��d�|�t|�d	ddd
��d�|�t|�dddd	��d
�|�t|�ddd	d	��d�dS)Nr"rBr>rDz01:02:03.000004r#r�z10:02:03.004000rr8z00:02:03.400000r�z12:02:03r�r�z23:15:00)r*r�r�rZrrr r��s
zTestTime.test_strc	Cs�d|jj}|�t|�dddd��d|�|�t|�dddd��d	|�|�t|�d
ddd��d|�|�t|�d
ddd
��d|�|�t|�ddd
d
��d|�dS)Nr7r"rBr>rDz%s(1, 2, 3, 4)r#r�z%s(10, 2, 3, 4000)rr8z%s(0, 2, 3, 400000)r�z%s(12, 2, 3)r�r�z
%s(23, 15)r9r:rrr r��s �����zTestTime.test_reprcCsN|�|jj|j�|�|jj|j�|�|jjt�|�|jj|jjk�dSrX)rvr�r�rprArrtrZrrr rB�szTestTime.test_resolution_infocCsZd}|j|�}tD],\}}}|�||�}|�|�}|�||�q|�|��|�d��dS)N�r�r�r�r�rBr
r.rrr r/�s

zTestTime.test_picklingcCsRd}t|�}tD]<\}}}|�||�}|�|�}|�||�|�t|t��qdS)Nr%)rr~rr�r*rtrPr.rrr �test_pickling_subclass_time�s
z$TestTime.test_pickling_subclass_timec
Csnddddddg}t|�D]P\}\}}|j|d��2|j|�}tD]}||dd	�}|�||�q@W5QRXqdS)
N)s,cdatetime
time
(S'\x14;\x10\x00\x10\x00'
tR.r%)scdatetime
time
(U;tR.r%)s�cdatetime
time
U;�R.r%)s,cdatetime
time
(S'\x14;\x19\x00\x10\x00'
tR.�r�r�r�r�)scdatetime
time
(U;tR.r')s�cdatetime
time
U;�R.r')r
rr)r
r�r�rr*)r+rer
rr�rgr�r�rrr r
s�
zTestTime.test_compat_unpicklecCsh|j}|�|d��|�|dd��|�|ddd��|�|dddd��|�|d��|�|��dS)Nr"r)r�rt)r+r)rrr rS
szTestTime.test_boolc
Cs�|j}ddddg}||�}|�||���d}dD]H\}}|dd�}|||<||�}|jf||i�}	|�||	�|d7}q2|d�}|jt|jdd�|jt|jd	d
�|jt|jdd�|jt|jd
d�dS)Nr"rBr>rDr)r�r�r�r�r��r�r��rqr r#r�r"r'r(rrr r.%
s"
zTestTime.test_replacecCs8Gdd�d|j�}|dd�}|�t|jdd��|�dS)Nc@seZdZdS)z4TestTime.test_subclass_replace.<locals>.TimeSubclassNr]rrrr �TimeSubclass?
sr*r�rkr#r(r0)r+r*r�rrr r1>
s
zTestTime.test_subclass_replacecs�G�fdd�d�j�}d}�j|�}||ddi�}��|j|���|jd���|jd���|��|�����|�d�|j|jd�dS)Ncs$eZdZdZ�fdd�Zdd�ZdS)z&TestTime.test_subclass_time.<locals>.CrLcs0|��}|�d�}�jj|f|�|�}||_|Sr2r3r5rZrr r{J
s

z.TestTime.test_subclass_time.<locals>.C.__new__cSs||j|jSrX�r�rpr8rrr r:Q
sz.TestTime.test_subclass_time.<locals>.C.newmethNr;rrZrr r=G
sr=)rDr?rFr�rArLrC)	r�r*r3r<r�r�r:r�rpr?rrZr �test_subclass_timeE
s

zTestTime.test_subclass_timec	Csld}ddtd�dfD] }|�t|j||dd��q|�td�� |�tdgt|��d�W5QRXdS)	Nz2:59.0r��9r��ÿr"rWr�)�chrrlrmr�r�rXr))r+r*Z	hour_byterrr rY_
s
�z!TestTime.test_backdoor_resistanceN)r4rIrJrr�rr�r@r!r�r+r�r�r$r�r�r�r�rBr/r&rrSr.r1r,rYrrrr r�s.	+4
		
rc@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�
TZInfoBasecCs�|j}Gdd�dt�}|ddd|�d�}|tkr4dp6d}|�|��|�t|tkrVd	pXd
d�}|�|��|�|�|��|�dS)Nc@s eZdZdd�Zdd�ZeZdS)z7TZInfoBase.test_argument_passing.<locals>.introspectivecSs|rdp
dS)N�real�nonerr\rrr r_r
r�z>TZInfoBase.test_argument_passing.<locals>.introspective.tznamecSst|r
dpdd�S)NrL����rNrr\rrr r^s
szATZInfoBase.test_argument_passing.<locals>.introspective.utcoffsetN)r4rIrJr_r^r`rrrr �
introspectiveq
sr4r"rBr>rr2r1r3rLrN)r�rrr*r_rr^r`)r+r)r4�objrgrrr �test_argument_passingn
sz TZInfoBase.test_argument_passingcCsz|j}|jt|ddddd�Gdd�dt�}|jt|ddd|d�Gdd�dt�}|�}|ddd|d�}|�|j|�dS)Nr"r�rc@seZdZdd�Zdd�ZdS)z3TZInfoBase.test_bad_tzinfo_classes.<locals>.NiceTrycSsdSrXrrZrrr rW�
r�z<TZInfoBase.test_bad_tzinfo_classes.<locals>.NiceTry.__init__cSsdSrXrr\rrr r^�
r�z=TZInfoBase.test_bad_tzinfo_classes.<locals>.NiceTry.utcoffsetN�r4rIrJrWr^rrrr �NiceTry�
sr8c@seZdZdd�Zdd�ZdS)z5TZInfoBase.test_bad_tzinfo_classes.<locals>.BetterTrycSsdSrXrrZrrr rW�
r�z>TZInfoBase.test_bad_tzinfo_classes.<locals>.BetterTry.__init__cSsdSrXrr\rrr r^�
r�z?TZInfoBase.test_bad_tzinfo_classes.<locals>.BetterTry.utcoffsetNr7rrrr �	BetterTry�
sr9)r�rlrm�objectrr|)r+r)r8r9rr�rrr �test_bad_tzinfo_classes�
sz"TZInfoBase.test_bad_tzinfo_classesc

Cs�Gdd�dt�}|j}dD]�\}}|tkr@|ddd||�d�}n0|tkrd|dddddd||�d�}nd	sptd
��|r�t|�}t|d�\}}d|d	kr�d
p�d||f}	t|t�r�|��}|�	t
|�d|	�q|�tt
|�qdS)Nc@seZdZdd�Zdd�ZdS)z6TZInfoBase.test_utc_offset_out_of_bounds.<locals>.EdgycSst|d�|_dSrM�rrV)r+rVrrr rW�
sz?TZInfoBase.test_utc_offset_out_of_bounds.<locals>.Edgy.__init__cSs|jSrX)rVr\rrr r^�
sz@TZInfoBase.test_utc_offset_out_of_bounds.<locals>.Edgy.utcoffsetNr7rrrr �Edgy�
sr=))�`���F)�a���T)�T)r�Fr"rBr>rrFrZ
impossibler�z%c%02d:%02dr�r�z01:02:03)
rr�rrr�rrwrP�timetzr*r�rlr�)
r+r=r)rVZlegitr�Zaofsr�r��tagrrr �test_utc_offset_out_of_bounds�
s 
z(TZInfoBase.test_utc_offset_out_of_boundscCs�|j}Gdd�dt�}|ddd�|ddddd�|ddd|�d�fD].}|�|���|�|���|�|���qBGdd�dt�}|ddd|�d�}|�|��tdd��|�|��td	d��|�|��d
�Gdd�dt�}|ddd|�d�}|�t	|j�|�t	|j�|�t	|j�Gd
d�dt�}|ddd|�d�}|�t
|j�|�t
|j�Gdd�dt�}|ddd|�d�}|�|��tdd��|�|��tdd��dS)Nc@s$eZdZdd�Zdd�Zdd�ZdS)z*TZInfoBase.test_tzinfo_classes.<locals>.C1cSsdSrXrr\rrr r^�
r�z4TZInfoBase.test_tzinfo_classes.<locals>.C1.utcoffsetcSsdSrXrr\rrr r`�
r�z.TZInfoBase.test_tzinfo_classes.<locals>.C1.dstcSsdSrXrr\rrr r_�
r�z1TZInfoBase.test_tzinfo_classes.<locals>.C1.tznameN�r4rIrJr^r`r_rrrr �C1�
srEr"rc@s$eZdZdd�Zdd�Zdd�ZdS)z*TZInfoBase.test_tzinfo_classes.<locals>.C3cSs
tdd�S)Nr?rNrr\rrr r^�
r�z4TZInfoBase.test_tzinfo_classes.<locals>.C3.utcoffsetcSs
tdd�S)Nr@rNrr\rrr r`�
r�z.TZInfoBase.test_tzinfo_classes.<locals>.C3.dstcSsdS�N�anamerr\rrr r_�
r�z1TZInfoBase.test_tzinfo_classes.<locals>.C3.tznameNrDrrrr �C3�
srHr?rNr@rGc@s$eZdZdd�Zdd�Zdd�ZdS)z*TZInfoBase.test_tzinfo_classes.<locals>.C4cSsdSrFrr\rrr r^�
r�z4TZInfoBase.test_tzinfo_classes.<locals>.C4.utcoffsetcSsdSr@rr\rrr r`�
r�z.TZInfoBase.test_tzinfo_classes.<locals>.C4.dstcSsdSr�rr\rrr r_�
r�z1TZInfoBase.test_tzinfo_classes.<locals>.C4.tznameNrDrrrr �C4�
srIc@seZdZdd�Zdd�ZdS)z*TZInfoBase.test_tzinfo_classes.<locals>.C6cSs
tdd�S)Ni��r�rr\rrr r^�
r�z4TZInfoBase.test_tzinfo_classes.<locals>.C6.utcoffsetcSs
tdd�S)Nr�r�rr\rrr r`�
r�z.TZInfoBase.test_tzinfo_classes.<locals>.C6.dstNr�rrrr �C6�
srJc@seZdZdd�Zdd�ZdS)z*TZInfoBase.test_tzinfo_classes.<locals>.C7cSs
tdd�S)Nrr�rr\rrr r^�
r�z4TZInfoBase.test_tzinfo_classes.<locals>.C7.utcoffsetcSs
tdd�S)N���r�rr\rrr r`�
r�z.TZInfoBase.test_tzinfo_classes.<locals>.C7.dstNr�rrrr �C7�
srLrr�rK)r�rr�r^r`r_r*rrlrmr�)r+r)rEr�rHrIrJrLrrr �test_tzinfo_classes�
s6
�zTZInfoBase.test_tzinfo_classescCs�|j}Gdd�dt�}|ddd|�d�}|jdd�}|jdd�}|jd	d�}|||fD]N}|||fD]>}ttttttfD](}	|	||�}
|	|j	|j	�}|�
|
|�qxqdqV|tk	�r�|jd|�d
�}|jd|�d
�}|jd	|�d
�}|||fD]�}|||fD]�}||k||k}
||k�s ||k�r:||k�s4||k�r:d}nD||k�rR|k�r\nnd}n"||k�rld}n||k�szt�d
}|�
|
|�q�q�dS)Nc@seZdZdd�ZdS)z=TZInfoBase.test_aware_compare.<locals>.OperandDependentOffsetcSs$|jdkrt|jd�Stdd�SdS�Nr#rNr��rqrr�rrr r^�
s
zGTZInfoBase.test_aware_compare.<locals>.OperandDependentOffset.utcoffsetNrfrrrr �OperandDependentOffset�
srPrtr>r#rr>r)rj�rqrrr�r")
r�rr�rrrrrrrqr*rr�)r+r)rPr*�d0rdr�ryr��opr-rgrrr �test_aware_compare�
s8	

(
zTZInfoBase.test_aware_compareN)r4rIrJr6r;rCrMrTrrrr r0l
s
0r0c@s�eZdZeZdd�Zdd�Zdd�Zdd�Zd	d
�Z	dd�Z
d
d�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�ZdS) �
TestTimeTZcCsP|��}|�|jd�|�|jd�|�|jd�|�|jd�|�|j�dSr�)r�r*r�rqrpr�r�rr�rrr �
test_emptyszTestTimeTZ.test_emptycs"tddd�}tddd�}tddd	�}td
d|d�}td
d|d�}tdd|d�}tdd��td|d��|�|j|�|�|j|�|�|j|�|��j�|��j|�|�|��tdd��|�|��tdd��|�|��tdd��|�����|�t|jd�|�|�	�d�|�|�	�d�|�|�	�d�|���	��|�t|j	d�|�|�
�tdd��|�|�
�tdd��|�|�
�td	d��|���
��|�t|j
d�|�t|�t|��|�t|�t|��|�t|�t|��|�||�|�||�|�||�|����|�t��fdd��|�t��fdd��|�t
|�d�|�t
|�d�|�t
|�d�|�t
��d�|�t
��d�|�|��d�|�|��d�|�|��d�|����d�|����d�d}|�t|�|d�|�t|�|d�|�t|�|d�|�t��|d �|�t��|d!�|�|�d"�d#�|�|�d$�d%�|�|�d$�d&�td'd(�}td)d*|d�}|�|�d+�d,�Gd-d.�d.t�}	td/d	d0|	�d�}
|�|
�d1�d2�|�t|
jd3�d4|jjk�rd5|	_|�t|
jd3�dS)6Nr�r�r"rr�r@r��METr>rAr�rr�rl�(r")r�rrNzno argscs��kSrXrr�r[Zt5rr r�Br�z'TestTimeTZ.test_zones.<locals>.<lambda>cs��kSrXrrrYrr r�Cr�z07:47:00-05:00z12:47:00+00:00z13:47:00+01:00z00:00:00.000040z00:00:00.000040+00:00z
datetime.timez(7, 47, tzinfo=est)z(12, 47, tzinfo=utc)z(13, 47, tzinfo=met)z
(0, 0, 0, 40)z(0, 0, 0, 40, tzinfo=utc)z%H:%M:%S %%Z=%Z %%z=%zz07:47:00 %Z=EST %z=-0500z%H:%M:%S %Z %zz12:47:00 UTC +0000z13:47:00 MET +0100r?z%z %Z %%z%%Zr�r�z%H:%M %%Z='%Z' %%z='%z'z"23:59 %Z='%z %Z %%z%%Z' %z='-2359'c@seZdZdZdd�ZdS)z(TestTimeTZ.test_zones.<locals>.BadtznamerLcSs|jSrXr�r\rrr r_er�z/TestTimeTZ.test_zones.<locals>.Badtzname.tznameN)r4rIrJr�r_rrrr �	BadtznamecsrZrBrDz%H:%M:%Sz02:03:04r�r;r�)rKrr*rr�r^rrlrmr_r`r(r�r�r�r�r�r3r4r�r�)r+�estr��metr$r%rZr*ZyuckrZr�rrYr �
test_zoness�
�
�zTestTimeTZ.test_zonescCs�|jddddtdd�d�}|jddddtdd�d�}|�t|�t|��|jd	d
ddtd
d�d�}|jd	dddtdd�d�}|�t|�t|��dS)Nrr"rBr>r@r�ri�r�r5rFr i���r�i���)r�rKr*r(r#rrr �test_hash_edge_casesoszTestTimeTZ.test_hash_edge_casesc	Cs�d}|j|�}tD],\}}}|�||�}|�|�}|�||�q|�|��|�d��tdd�}|jddd|d�}tD]`\}}}|�||�}|�|�}|�||�|�|j	t�|�|�
�tdd	��|�|��d�qv|�|��|�d��dS)
Nr%rBr�r�r?rFrArrN)
r�r~rr�r*rrrarvrr^rr_�	r+r�r�r�r�rr�r��tinforrr r/ys"



zTestTimeTZ.test_picklingcCs�dddg}tdd�}|jdddd	|d
�}|D]`}tD]V}||dd�}|�||t|��|�|jt�|�|��tdd
��|�|�	�d�q4q,dS)Ns�cdatetime
time
(S'\x05\x06\x07\x01\xe2@'
ctest.datetimetester
PicklableFixedOffset
(tR(dS'_FixedOffset__offset'
cdatetime
timedelta
(I-1
I68400
I0
tRsS'_FixedOffset__dstoffset'
NsS'_FixedOffset__name'
S'cookie'
sbtR.s�cdatetime
time
(U�@ctest.datetimetester
PicklableFixedOffset
)R}(U_FixedOffset__offsetcdatetime
timedelta
(J����J0KtRU_FixedOffset__dstoffsetNU_FixedOffset__nameUcookieubtR.s��cdatetime
time
U�@ctest.datetimetester
PicklableFixedOffset
)R}(U_FixedOffset__offsetcdatetime
timedelta
J����J0K�RU_FixedOffset__dstoffsetNU_FixedOffset__nameUcookieub�R.r�r�r?rFrAr�rrrrN)
rar�rr*r�rvrr^rr_)r+rer`rgrr�r�rrr r�s�
zTestTimeTZ.test_compat_unpicklecCs||j}|dtdd�d�}|�|�|dtdd�d�}|�|�|dtdd�d�}|�|�|ddtd	d�d�}|�|�dS)
Nrr�r�rr?i,r�r�r@)r�rKrt)r+r)r�rrr �test_more_bool�s


zTestTimeTZ.test_more_boolcCsX|j}tdd�}ttdd�d�}dddd	|g}||�}|�||���d
}ddd
dd|ffD]H\}}|dd�}	||	|<||	�}
|jf||i�}|�|
|�|d7}q\|�|��d�|jdd�}|�|j�|�|���|j|d�}
|�||
�|�|j|
j�|d�}|j	t
|jdd�|j	t
|jdd�|j	t
|jdd�|j	t
|jdd�dS)Nr �+100�8���rN�-200r"rBr>rDrr�r�r�r�rrr�r(r�r)r#r�r"�r�rKrr*r�r_r�rr|rlr��r+r)Zz100Zzm200r�r*r
r0r+r,rgr-Zbase2Zbase3rrr r.�s>
�
zTestTimeTZ.test_replacecCs|�ddd�}|�ddd�}|�||�|jdd�}|�||�|jtdd�d�}|�||�|jtdd�d�}|�||�Gdd�dt�}|�}|j|d�}|j|d�}|�|��td	d
��|�|��tdd
��|�||�|j|�d�}|�||k�dS)Nr"rBr>rr�rc@seZdZdd�Zdd�ZdS)z-TestTimeTZ.test_mixed_compare.<locals>.VariescSstdd�|_dS�Nr�rNr<rZrrr rW�sz6TestTimeTZ.test_mixed_compare.<locals>.Varies.__init__cSs|jtdd�7_|jS�Nr"rN�rVrr�rrr r^�sz7TestTimeTZ.test_mixed_compare.<locals>.Varies.utcoffsetNr7rrrr �Varies�srjr�rNr�)	r�r*r�rKr�rr^rrt�r+r$r%rj�vrrr r�s$zTestTimeTZ.test_mixed_comparecCs�ddg}d}d}d}d}|tt�||||��7}dtjttdd��ttd	d
d��g}|D]V}|D]L}|j|d|i�}	|	��}
|j|
d
��|j�	|
�}|�
|	|�W5QRXq`qXdS)Nr�)r�r�r�r�)r>r�r�)r?rk)rDr�)ri�i�[
rBr�rFrr�rr)rz�	itertools�productrr�rr�r�r�rEr*)r+Z
time_examplesZhhZmm�ssZusecr�Zttupr�r�r�t_rtrrr rcs&��zTestTimeTZ.test_fromisoformatc
Cs�|�dddd�}tdd�tdd�tdd	d
�tdddd�tdd
ddd�g}|dd�|D�7}dtjttdd��g}|dd�|D�7}|D]L}|j|d�}|��}|j|d��"|j�|�}||ks�t|��W5QRXq�dS)Nr�rkr�rr?r�rBrFrr�rkr�rDr>r�r�cSsg|]}d|�qSrrrrrr r!*sz:TestTimeTZ.test_fromisoformat_timezone.<locals>.<listcomp>rcSsg|]}t|��qSrrrrrr r!/srrr)r+Z	base_timer�r�r�r�rrprrr r s$
��z&TestTimeTZ.test_fromisoformat_timezonecCs�ddg}dtjttdd��ttdd��ttddd��g}d	d
ddd
g}t|�D]�\}}|D]�}|D]�}|dkr�d|dd}|dd�|f}|j|dd|�d|i�}	|	j|d�}
|j|
d��|j�|
�}|�|	|�W5QRXqbqZqNdS)N)rtr�r�r�)rtr�r�rr�r�rBrFrr�r�rOr�r�r�r�r�rr"rr�rr)r+Z
time_basesr�rrr�r�Zt_tuplerr�rrprrr r9s.���z'TestTimeTZ.test_fromisoformat_timespecscCsvddddddddd	d
ddd
ddddddddg}|D]>}|j|d��(|�t��|j�|�W5QRXW5QRXq2dS)Nr�u12�00z12:z12:30:z	12:30:15.�1z12:3z12:30:1z1a:30:45.334034z12:a0:45.334034z12:30:a5.334034z
12:30:45.1234z12:30:45.1234567z12:30:45.123456+24:30z12:30:45.123456-24:30u12:30:45u12:30:45․123456z	12:30:45az
12:30:45.123az12:30:45.123456az12:30:45.123456+12:00:30arrrerrr rgTs4�z#TestTimeTZ.test_fromisoformat_failsc
CsHddl}dd|�d�g}|D]&}|�t��|j�|�W5QRXqdS)Nrs12:30:45z12:30:45rhrkrrr rlrs
z-TestTimeTZ.test_fromisoformat_fails_typeerrorcCsPGdd�d|j�}|ddddtjd�}|�|���}|�||�|�||�dS)Nc@seZdZdS)z<TestTimeTZ.test_fromisoformat_subclass.<locals>.TimeSubclassNr]rrrr r*}sr*r�r�r�i�r)r�rr�rEr�r*rv)r+r*ZtscZtsc_rtrrr rd|s
z&TestTimeTZ.test_fromisoformat_subclasscs�G�fdd�d�j�}ddddtddd	�f}�j|�}||d
di�}��|j|���|jd���|jd���|��|�����|�d
�|j|j	d�dS)Ncs$eZdZdZ�fdd�Zdd�ZdS)z*TestTimeTZ.test_subclass_timetz.<locals>.CrLcs0|��}|�d�}�jj|f|�|�}||_|Sr2r3r5rZrr r{�s

z2TestTimeTZ.test_subclass_timetz.<locals>.C.__new__cSs||j|jSrXr+r8rrr r:�sz2TestTimeTZ.test_subclass_timetz.<locals>.C.newmethNr;rrZrr r=�sr=rDr?rF��r�r�r"r�rArLrC)
r�rKr*r3r<r�r^r:r�rpr?rrZr �test_subclass_timetz�s

zTestTimeTZ.test_subclass_timetzN)r4rIrJrr�rVr]r^r/rrar.rrcrrrgrlrdrsrrrr rU
s W
"'

rUc@s�eZdZeZdd�Zdd�Zdd�Zdd�Zd	d
�Z	dd�Z
d
d�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Ze�d%�d&d'��Ze�d(�d)d*��Ze�d(�d+d,��Zd-d.�Zd/d0�Zd1d2�Zd3S)4�TestDateTimeTZc	Cs�|�ddddddd�}|�|jd�|�|jd�|�|jd�|�|jd�|�|jd�|�|jd�|�|jd�|�|j	d�dS)Nr"rBr>rDr?rFrA)
r�r*r�r�rHr�rqrpr�rr\rrr �test_trivial�szTestDateTimeTZ.test_trivialcsT|jdddtdd�d��|jtdddddd	td
d�d��|���k�|���k�|���k�|����|����|jdddddtdd�d��|jddddd
tdd�d��|����|jdddddtdd�d��|���k�|jdddddtdd�d��|���k�|jdddddtdd�dd��|���k�|jdddddtdd�dd��|���k�|jj�|����|����|�t����kW5QRXGdd�dt	�}|jddd|�d��|����|����|�ddd��|����Gdd�dt	�}|jddd|�d��|jdddtdd�d��|�t
��fdd��dS)Nr"r@r�rr�rr�r�r�r?rBr>rl��r)rrp)rr�c@seZdZdd�ZdS)z4TestDateTimeTZ.test_even_more_compare.<locals>.NaivecSsdSrXrr\rrr r^�r�z>TestDateTimeTZ.test_even_more_compare.<locals>.Naive.utcoffsetNrfrrrr �Naive�srwr?rFrAc@seZdZdd�ZdS)z4TestDateTimeTZ.test_even_more_compare.<locals>.BoguscSs
tdd�S)Nr�rNrr\rrr r^�sz>TestDateTimeTZ.test_even_more_compare.<locals>.Bogus.utcoffsetNrfrrrr r��sr�cs��kSrXrr�r$r%rr r��r�z7TestDateTimeTZ.test_even_more_compare.<locals>.<lambda>)r�rKrrtr*r�r�rlrmrr�)r+rwr�rrxr �test_even_more_compare�sN���z%TestDateTimeTZ.test_even_more_comparec	Cs
d}|j|�}tD],\}}}|�||�}|�|�}|�||�q|�|��|�d��tdd�}|j|d|i�}|jdddtddd�d	�}tD]`\}}}|�||�}|�|�}|�||�|�	|j
t�|�|��tdd
��|�|�
�d�q�|�|��|�d��dS)Nr�rBr�r�rr"rr�rrN)r�r~rr�r*rrrarKrvrr^rr_r_rrr r/�s$



zTestDateTimeTZ.test_picklingcCs�dddg}d}tdd�}|j|d|i�}|D]Z}tD]P}||dd	�}|�||�|�|jt�|�|��tdd
��|�|��d�q4q,dS)Ns�cdatetime
datetime
(S'\x07\xdf\x0b\x1b\x14;\x01\x01\xe2@'
ctest.datetimetester
PicklableFixedOffset
(tR(dS'_FixedOffset__offset'
cdatetime
timedelta
(I-1
I68400
I0
tRsS'_FixedOffset__dstoffset'
NsS'_FixedOffset__name'
S'cookie'
sbtR.s�cdatetime
datetime
(U
�;�@ctest.datetimetester
PicklableFixedOffset
)R}(U_FixedOffset__offsetcdatetime
timedelta
(J����J0KtRU_FixedOffset__dstoffsetNU_FixedOffset__nameUcookieubtR.s��cdatetime
datetime
U
�;�@ctest.datetimetester
PicklableFixedOffset
)R}(U_FixedOffset__offsetcdatetime
timedelta
J����J0K�RU_FixedOffset__dstoffsetNU_FixedOffset__nameUcookieub�R.)rrjrr�r�r"r�r�r�rrrrN)	rar�rr*rvrr^rr_)r+rer�r`rgrr�r�rrr r
s�
z#TestDateTimeTZ.test_compat_unpicklecCsr|jdddtdd�d�}t|�|jtdddddd	td
d�d�}t|�|jdddtdd�d�}|�tt|�dS)
Nr"r@r�rr�rr�r�r�r?r?r>)r�rKr(rrlr�r�rrr �test_extreme_hashes2s�z"TestDateTimeTZ.test_extreme_hashescCs�tdd�}tdd�}tdd�}tddd	d
d|d�}tddd	d
d|d�}tddd	dd|d�}|�|j|�|�|j|�|�|j|�|�|��tdd��|�|��tdd��|�|��tdd��|�|��d�|�|��d�|�|��d�|�t|�t|��|�t|�t|��|�t|�t|��|�||�|�||�|�||�|�t|�d�|�t|�d�|�t|�d�d}|�t	|�|d�|�t	|�|d�|�t	|�|d�dS)Nr�r�rr�r�rWr�r>rnrAr�rr�rlrNz2002-03-19 07:47:00-05:00z2002-03-19 12:47:00+00:00z2002-03-19 13:47:00+01:00zdatetime.datetime(2002, 3, 19, z7, 47, tzinfo=est)z12, 47, tzinfo=utc)z13, 47, tzinfo=met))
rKrr*rr^rr_r(r�r�)r+r[r�r\r$r%rZr*rrr r]@s8


zTestDateTimeTZ.test_zonesc
CsXtdd�}tddd�}tdddd|d	�}t�||�}|�|tddddddd|d	��dS�
Nr�rWr�r>rDr�r�r�r)rKrrrrHr*)r+r\r*r�r]rrr r�^s
�zTestDateTimeTZ.test_combinec
Csxtdd�}|jddddddd|d	�}|�|��tddd��|�|��tdddd��|�|��tdddd|d	��dSr{)rKr�r*rrrA)r+r\r]rrr r�fs

zTestDateTimeTZ.test_extractc
st|j���tdd�}���j|d�}|j����|��|��j|�|�	��
�|�|�t��fdd��|�t��fdd��|�t��fdd��|�t��fdd��|�t�fd	d��|�	��t
d
��|�	��t
d
��t
ddd
d�����|��j|���}|�|j|�|�	�|���}|�|j|�|�	�|�|�t��fdd��|�	����tt�dd�d�}�j|d��|��j|���}�������}|�	||�|jdddtdd�d�}|jtddddddtdd�d�}	|	|}
|�	|
|jj|jjt
dd��ttd�}ttd�}|j|d�|	j|d��|�	�|jj|jj�dS)Ni����z	west 5:30rcs��SrXrr�rw�nowawarerr r�vr�z9TestDateTimeTZ.test_tz_aware_arithmetic.<locals>.<lambda>cs��SrXrrr|rr r�wr�cs��SrXrrr|rr r�zr�cs��SrXrrr|rr r�{r�cs��SrXrr)r}rr r�|r�rr"r�i.)r�rOr�cs��SrXrr)r��nowawareplusrr r��r�r?r�Zrandomtimezoner@r�rr�r�r�rpi>rNr�r�)r�rwrKrr�rHrr|rr*rArlrmrre�	randranger^rrpr�rr�)
r+Ztz55Z	timeawareZ
nowawareplus2r�Ztzrr-rgr�rpZmaxdiffZtzaZtzbr)r�rwr}r~r �test_tz_aware_arithmeticmsT

��

z'TestDateTimeTZ.test_tz_aware_arithmeticcCs.|jj}|�}tdd�}||�}||d�}|�|j|j�|�|��tdd��|�t	|d�|jt	|dd�|jt	||d�|�t	|||�tdd	d�}ttd
dd�d
d�t
td
dd�d
�fD]h}td�D]P}t�|�}	|�|	j|�t�
�j|d�}
|
�|�}t|	|�tdd�kr�q�q�|�d�q�dS)NrL�42r�rNr�r�r`rr�r�r5r��weirdtzr>rkr�z0utcnow(), now(tz), or astimezone() may be broken)r�rwrKr|rr*r^rrlrmrrrr�r�r�rZfail)r+�methr*�off42�another�againr�r�r�rwr�Znow2rrr �test_tzinfo_now�s.

�

zTestDateTimeTZ.test_tzinfo_nowcCs
ddl}|jj}|��}||�}tdd�}|||�}|||d�}|�|j|j�|�|��tdd��|�	t
||d�|j	t
||dd�|j	t
|||d�|�	t
||||�|�	t
|�d	}t�|�}	td
dd�}
t|
d
d�}|	|
}t�||�}
|�||
j
dd��dS)NrrLr�r�rNr�rr�rCi��'r�r�)rr�r�rKr|rr*r^rrlrmrr�r�)r+rr�r�r*r�r�r�rIZutcdatetimer^r�rgr-rrr �test_tzinfo_fromtimestamp�s*


z(TestDateTimeTZ.test_tzinfo_fromtimestampcCs:|jj}|�}tdd�}|�t||�|jt||d�dS)NrLr�r)r�r�rKrlrm)r+r�r*r�rrr �test_tzinfo_utcnow�s

z!TestDateTimeTZ.test_tzinfo_utcnowcCsPddl}|jj}|��}||�}tdd�}|�t|||�|jt|||d�dS)NrrLr�r)rr�r�rKrlrm)r+rr�r�r*r�rrr �test_tzinfo_utcfromtimestamps
z+TestDateTimeTZ.test_tzinfo_utcfromtimestampcCshGdd�dt�}|j}dD]�\}}|ddddddd||�d	�}|��}|�d|j�|�d|j�|�d|j�|�d|j�|�d|j�|�d|j	�|�d
|j
�|�d|j�|�||j�q|�
t|ddd|d�d	�j�|�|ddd|d�d	���jd�|�|ddd|d
�d	���jd�|�
t|ddd|d�d	�j�|�
t|ddd|d�d	�j�dS)Nc@seZdZdd�Zdd�ZdS)z1TestDateTimeTZ.test_tzinfo_timetuple.<locals>.DSTcSst|t�rt|d�}||_dSrM�rPrQr�dstvalue�r+r�rrr rWs

z:TestDateTimeTZ.test_tzinfo_timetuple.<locals>.DST.__init__cSs|jSrX�r�r\rrr r`sz5TestDateTimeTZ.test_tzinfo_timetuple.<locals>.DST.dstN�r4rIrJrWr`rrrr �DSTsr�))����r")r�r")rr)Nr�r"r#r�rkrXrrryr@r?r�r>)rr�r�r*rrrrrrrr	r
rlrmr�)r+r�r)r��flagr*r�rrr �test_tzinfo_timetuples&""z$TestDateTimeTZ.test_tzinfo_timetuplecs�Gdd�dt��|j}|�t|ddd�d�d�j�G�fdd�d��}dD]�}|dd	d
ddd
d|d|�d�}|��}|�|j|j�|�|j	|j
�|�|j|j�|�d|j
�|�d|j�|�|j|j�|�|��|j�|�|��tddd���d|j�|�d|j�qL|dd	d
ddd
d�}|��}|�|dd�|��dd��|�d|j�Gdd�d��}|dd	d
ddd
d|�d�}|��}|�|dd�|��dd��|�d|j�Gdd�d��}|dd	d
ddd
d|�d�}|�t|j�|ddddddd�}tjtjtjfD]>}|j|d�}	|�|	��dd�|	�tj���dd���q |tddddd|d�d�}
|�t |
j�|t!ddd d!dd"|d#�d�}|�t |j�|jjtt"�d�}
|�t |
j�|jjtt"�d�}|�t |j�dS)$Nc@seZdZddd�Zdd�ZdS)z-TestDateTimeTZ.test_utctimetuple.<locals>.DSTrcSst|t�rt|d�}||_dSrMr�r�rrr rW2s

z6TestDateTimeTZ.test_utctimetuple.<locals>.DST.__init__cSs|jSrXr�r\rrr r`6sz1TestDateTimeTZ.test_utctimetuple.<locals>.DST.dstN)rr�rrrr r�1s
r�r"rrcs"eZdZd�fdd�	Zdd�ZdS)z.TestDateTimeTZ.test_utctimetuple.<locals>.UOFSNcs��||�t|d�|_dSrM)rWr�uofs)r+r�Zdofs�r�rr rW?sz7TestDateTimeTZ.test_utctimetuple.<locals>.UOFS.__init__cSs|jSrX)r�r\rrr r^Bsz8TestDateTimeTZ.test_utctimetuple.<locals>.UOFS.utcoffset)Nr7rr�rr �UOFS>sr�)r�r�rNrBr>r#r�rkrXi���rjrlr�c@seZdZdd�ZdS)z.TestDateTimeTZ.test_utctimetuple.<locals>.NOFScSsdSrXrr\rrr r^\sz8TestDateTimeTZ.test_utctimetuple.<locals>.NOFS.utcoffsetNrfrrrr �NOFS[sr�c@seZdZdd�ZdS)z.TestDateTimeTZ.test_utctimetuple.<locals>.BOFScSsdS)Nr�rr\rrr r^dsz8TestDateTimeTZ.test_utctimetuple.<locals>.BOFS.utcoffsetNrfrrrr �BOFScsr�r�r�r�r�i+�r�r@r�rr�r�r�r?)#rr�rlrqr^Zutctimetupler*r�rr�rrHrrrrprr�rr�rr	r
r�rmrr�r�rpr�r�rrDrr�)r+r)r�r�r*r�r�r�r�ZdtzrGZhugerr�r �test_utctimetuple0s\��  �z TestDateTimeTZ.test_utctimetuplecCstdd�}tdd�}tdd�}tdd�}|j}d}d||||fD]�}d	D]�}|d
ddd
dd||d�}	d|rndppd}
|dk	r�|	��p�d}|
|}|	��}
|�|
|d|�|�|
|	�d��|�|	�d�|d|�|�|	�d�|d|�|�t|	�|d|�qHq@dS)Nrr���z+03:40i���z-03:51r�z
0001-02-03)riyr"rBr>rDr?r�rz04:05:59z.987001rU�kuሴr�)rKr�r_r�r*r�)r+rZplusZminus�unknownr)ZdatestrZofsr	r*ZtimestrZofsstrZtailstrZisorrr �test_tzinfo_isoformat�s$



z$TestDateTimeTZ.test_tzinfo_isoformatc	Cs2|j}tdd�}ttdd�d�}dddd	d
dd|g}||�}|�||���d
}dddddddd|ffD]H\}}|dd�}	||	|<||	�}
|jf||i�}|�|
|�|d7}qh|�|��d�|jdd�}|�|j�|�|���|j|d�}
|�||
�|�|j|
j�|ddd�}|j	t
|jdd�dS)Nr rbrcrNrdr"rBr>rDr?rFrArr#r$r%r�r�r�r�rrr�r�r�r&rerfrrr r.�s>
�
zTestDateTimeTZ.test_replacecCsDtdd�}tdd�}ttdd�d�}|jj|d�}|�|j|�|�t|j|�|�|j�}|�|j|�|�	|�
�|�
��|�	|��|���|�|�}|�|j|�|�	|��tdd��||��}||�|�7}|j
|d	�}|�	|�
�|�
��|�	|��|���|�	|��|���|�|j|j�|�	||�dS)
N�Noner�Z44r?r�Zm300r�r�r)rKrr�rwr|rrlr�r�r*rrr^r�rA)r+ZfnoneZf44mZfm5hr]ryr-rgrrr �test_more_astimezone�s*


z#TestDateTimeTZ.test_more_astimezoner�cCs4|j�tj�}|�|�d�|�|�|��|�dSrX)r�rwrr�r*r�r\rrr �test_astimezone_default_utc�sz*TestDateTimeTZ.test_astimezone_default_utcr�cCs�|jdddddtjd�}|��}|�||�|�|�d�d�|jdddd	dtjd�}|��}|�||�|�|�d�d
�dS)Nr/rjrDrFrkrr�z	-0500 ESTr?z	-0400 EDT)r�rr�r�r*r�)r+r]r�rrr �test_astimezone_default_eastern�sz.TestDateTimeTZ.test_astimezone_default_easterncCs8tddddtjd�}|��}|��}|�|j|j�dS)Nrrjr"r?r)rrr�r�r*r)r+r�r�r?rrr �!test_astimezone_default_near_fold�sz0TestDateTimeTZ.test_astimezone_default_near_foldc
Cs�|j}Gdd�dt�}|ddddddd	|�d
�}|jdd�}|jdd�}|jdd�}|||fD]:}|||fD]*}||}	t|j|jd
�}
|�|	|
�qlq^|ddddddd	�}|jd|�d�}|jd|�d�}|jd|�d�}|||fD]�}|||fD]�}||}	||k�s||k�r4||k�s*||k�r4td�}
nT||k�rL|k�rZnn
td�}
n.||k�rptdd
�}
n||k�s~t�tdd
�}
|�|	|
�q�q�dS)Nc@seZdZdd�ZdS)zBTestDateTimeTZ.test_aware_subtract.<locals>.OperandDependentOffsetcSs$|jdkrt|jd�Stdd�SdSrNrOr�rrr r^�s
zLTestDateTimeTZ.test_aware_subtract.<locals>.OperandDependentOffset.utcoffsetNrfrrrr rP�srPrtr>r#rjr�rlr�rr>r)rNrQri���r�)r�rr�rrqr*r�)r+r)rPr*rRrdr�ryr�r-rgrrr �test_aware_subtract�s6	(



z"TestDateTimeTZ.test_aware_subtractcCstddddddd�}tddddddd�}|�||�|jdd�}|�||�|jtdd	�d�}|�||�|jtd
d	�d�}|�||�Gdd�dt�}|�}|j|d�}|j|d�}|�|��td
d��|�|��tdd��|�||�|j|�d�}|�||k�dS)Nr"rBr>rDr?rFrArr�rc@seZdZdd�Zdd�ZdS)z1TestDateTimeTZ.test_mixed_compare.<locals>.VariescSstdd�|_dSrgr<rZrrr rW-sz:TestDateTimeTZ.test_mixed_compare.<locals>.Varies.__init__cSs|jtdd�7_|jSrhrir�rrr r^/sz;TestDateTimeTZ.test_mixed_compare.<locals>.Varies.utcoffsetNr7rrrr rj,srjr�rNr�)	rr*r�rKr�rr^rrtrkrrr r s$z!TestDateTimeTZ.test_mixed_comparecs�G�fdd�d�j�}ddddddd	td
dd�f}�j|�}||d
di�}��|j|���|jd���|jd���|��|�����|�d�|j|j	d�dS)Ncs$eZdZdZ�fdd�Zdd�ZdS)z2TestDateTimeTZ.test_subclass_datetimetz.<locals>.CrLcs0|��}|�d�}�jj|f|�|�}||_|Sr2r3r5rZrr r{Cs

z:TestDateTimeTZ.test_subclass_datetimetz.<locals>.C.__new__cSs||j|jSrX)r�r�r8rrr r:Jsz:TestDateTimeTZ.test_subclass_datetimetz.<locals>.C.newmethNr;rrZrr r=@sr=r�r�rrDr?rFrrr�r�r"r�rArLrC)
r�rKr*r3r<r�r^r:r�r�r?rrZr �test_subclass_datetimetz>s

z'TestDateTimeTZ.test_subclass_datetimetzN)r4rIrJrr�ruryr/rrzr]r�r�r�r�r�r�r�r�r�r�r.r�rrr�r�r�r�rr�rrrr rt�s8E%A%#
$P'



,rtcCs d|��}|r|t|�7}|S)NrF)r�r)r]Z
days_to_gorrr �first_sunday_on_or_afterZsr�rNr�r�rDrBr�c@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�
USTimeZonecCs"t|d�|_||_||_||_dS�Nr��r�	stdoffset�reprname�stdname�dstname�r+r�r�r�r�rrr rWnszUSTimeZone.__init__cCs|jSrX�r�rZrrr r[tszUSTimeZone.__repr__cCs|�|�r|jS|jSdSrX�r`r�r�r\rrr r_ws
zUSTimeZone.tznamecCs|j|�|�SrX�r�r`r\rrr r^}szUSTimeZone.utcoffsetcCs�|dks|jdkrtS|j|ks$t�ttj|jd��}|��dkrV|jdkrV|j	dksZt�tt
j|jd��}|��dkr�|jdkr�|j	dks�t�||jdd�kr�|kr�nntStSdS�Nr&rFrDrAr#r�r)rr�r�r��DSTSTARTr�r�r�r�rH�DSTENDr��r+r]r9�endrrr r`�s$$ zUSTimeZone.dstN�r4rIrJrWr[r_r^r`rrrr r�ls
r�r�r�r�r�rG�CentralZCSTZCDTrC�MountainZMSTZMDTi�����PacificZPSTZPDTr�i0���ZUTCfakec@sdeZdZedddd�Zedddd�ZeZdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dS)�TestTimezoneConversionsr�rDrArBr#rr"c
Cs|�|��t�|�|�|�|�|�|�}|�|�}|��|��kr�|jdkr�|�|t|�|�|��t�|�|�|�|�|��n|�||�|t}|�|�}	|��|��kr�|jdkr�|�|	|jdd��|t7}|�|�}	|�|	|jdd��n|�|	|t�dS)NrBrr"r()r*r`r�r�rr�r�r�)
r+r]r�r��dston�dstoff�asutc�there_and_backZnexthour_utcZnexthour_tzrrr �checkinside�s&


�


z#TestTimezoneConversions.checkinsidecCsF|�|��t�|�|�|�|�|�|�}|�|�}|�||�dSrX)r*r`r�r�)r+r]r�r�r�r�rrr �checkoutside�s


z$TestTimezoneConversions.checkoutsidec	Cs�|jj|d�}|jj|d�}tdd�tttdd�tdd�fD]p}|�|||||�||||fD]}|�|||||�qb|�|||�||||fD]}|�|||�q�q<dS)Nrrlr�r"rNr�)r�r�r�r�DAYr�r�r�)r+r�r�r�r�r�ZduringZoutsiderrr �convert_between_tz_and_utc�s�z2TestTimezoneConversions.convert_between_tz_and_utccCsL|�tt�|�tt�|�tt�|�tt�|�tt�|�tt�dSrX)r�r��utc_realr��utc_fakerZrrr �	test_easy�sz!TestTimezoneConversions.test_easyc	CsH|jtdd�}tddd�}|j|d�}|jjdd�}|�t�jdd�}|�||�|jjd	td
�}|jjdd�}|�t�jdd�}|�||�ttfD]�}tt	fD]�}|j
tdd�}||�d�8}||�d�}	|	j|d�}
d
D]Z}|j
j|d�}dD]:}
|j|
d�}|
j|
d�}	|	�|�}|�|jdd�|�q�|
t7}
q�q�q�dS)NrDr�i��z-0900rrr>r(rF�r�rr"rB)rr"r"rB�rrkr�r))
r�rrKr�r�r�r*r�r�r�r�r^r�)r+ZfourbackZninewestrgr-Zsixutcr�r�Zfirst_std_hourr�Z	asutcbaseZtzhourZexpectedbaserqZastzrrr �test_trickys0
z#TestTimezoneConversions.test_trickycCs�Gdd�dt�}|j��jtd�}|�|��Gdd�d|�}|�t|j|��Gdd�d|�}|�dd	d	�jtd�}|�t|j|��dS)
Nc@seZdZdd�Zdd�ZdS)z2TestTimezoneConversions.test_bogus_dst.<locals>.okcSstSrX�r�r\rrr r^Ir�z<TestTimezoneConversions.test_bogus_dst.<locals>.ok.utcoffsetcSstSrXr�r\rrr r`Jr�z6TestTimezoneConversions.test_bogus_dst.<locals>.ok.dstNr�rrrr �okHsr�rc@seZdZdd�ZdS)z5TestTimezoneConversions.test_bogus_dst.<locals>.notokcSsdSrXrr\rrr r`Rr�z9TestTimezoneConversions.test_bogus_dst.<locals>.notok.dstN�r4rIrJr`rrrr �notokQsr�c@seZdZdd�ZdS)z<TestTimezoneConversions.test_bogus_dst.<locals>.tricky_notokcSs|jdkrdSdtSdS)Nr�r#)r�r�r\rrr r`Zs
z@TestTimezoneConversions.test_bogus_dst.<locals>.tricky_notok.dstNr�rrrr �tricky_notokYsr�r�r")rr�rwr�r�r�rlr�)r+r�rwr�r�r]rrr �test_bogus_dstGsz&TestTimezoneConversions.test_bogus_dstc
Cs�|�ttj�t��jtd�}|�ttj|�|jtd�}t�|�}|�	|j
t�|�ttj||�|�ttjt���Gdd�dt
�}|dddd�}|jjdtd	�}|j|d�}d
D]�}|j|d�}|dkr�|td
d�8}t�|�}	|�	||	�||j}|�|�}	|�	||	�|jtd��|�}	|�	||	�|t7}|t7}q�|jjdtd	�}|j|d�}dD]v}|j|d�}t�|�}	|�	||	�||j}|�|�}	|�	||	�|jtd��|�}	|�	||	�|t7}|t7}�qbdS)Nrc@seZdZdd�ZdS)z<TestTimezoneConversions.test_fromutc.<locals>.FauxUSTimeZonecSs
||jSrX)r�r\rrr r�nszDTestTimezoneConversions.test_fromutc.<locals>.FauxUSTimeZone.fromutcN�r4rIrJr�rrrr �FauxUSTimeZonemsr�r��FEasternZFESTZFEDTrDr�)r�rr"r>rDr?r(r�r"r�)rr"r"rBr>rD)rlrmr�r�rr�r�r�r�r*rrr�r�r�rr�r�r�r�)
r+rwZenowr�r�r9ZfstartZwallrgr-rrr r�bsL







z$TestTimezoneConversions.test_fromutcN)r4rIrJrr�r�r�r�r�r�r�r�r�r�rrrr r��s43r�c@s$eZdZdd�Zdd�Zdd�ZdS)�Oddballscs�t���t��t���|���k�|���k�|���k�|���k�|�t��fdd��|�t��fdd��|�t��fdd��|�t��fdd��|�t��fdd��|�t��fdd��|�t��fdd��|�t��fd	d��|�	��
��d
��jddd}�j|d
�}|�	��
|�d�t
�j�j�j�}|�	�|�|�	|��t�j�j�jddd�}|�	�|�|�	|��dS)Ncs��kSrXrr�Zas_dateZas_datetimerr r��r�z+Oddballs.test_bug_1028306.<locals>.<lambda>cs��kSrXrrr�rr r��r�cs��kSrXrrr�rr r��r�cs��kSrXrrr�rr r��r�cs��kSrXrrr�rr r��r�cs��kSrXrrr�rr r��r�cs��kSrXrrr�rr r��r�cs��kSrXrrr�rr r��r�Tr"r�)rHFr)rr�rrHrrtr�rlrmr*�__eq__rHr�r�r�r�r})r+Z
different_dayZas_differentZdate_scZdatetime_scrr�r �test_bug_1028306�s:
�zOddballs.test_bug_1028306c
CsJt��t�t��t�t�tt��fD] }|�t	��d|_
W5QRXq$dSrJ)rr�rrr�rrrrl�AttributeErrorr$)r+ryrrr �test_extra_attributes�s�zOddballs.test_extra_attributesc
CsGdd�d�}t�d�t�d�|d�fD]F}|�t��2|�tddddddd�t|||||||��W5QRXq(|�td��tddd�W5QRX|d�}|�td��tdd|�W5QRXGd	d
�d
t�}|d�}|�td��tdd|�W5QRX|�	t��tddd�W5QRX|�	t��tddd�W5QRX|�	t��tddd�W5QRX|�	t��tdddd�W5QRX|�	t��tddddd�W5QRX|�	t��tdddddd�W5QRX|�	t��tddddddd�W5QRXdS)
Nc@seZdZdd�Zdd�ZdS)z-Oddballs.test_check_arg_types.<locals>.NumbercSs
||_dSrX��value)r+r�rrr rW�sz6Oddballs.test_check_arg_types.<locals>.Number.__init__cSs|jSrXr�rZrrr �__int__�sz5Oddballs.test_check_arg_types.<locals>.Number.__int__N)r4rIrJrWr�rrrr �Number�sr�r#z10.9z)^an integer is required \(got type str\)$Z10g������%@z)^__int__ returned non-int \(type float\)$c@seZdZdS)z,Oddballs.test_check_arg_types.<locals>.FloatNr]rrrr �Float�sr�z&^integer argument expected, got float$g$@)
�decimalZDecimalZassertWarns�DeprecationWarningr*rr�rmr~rl)r+r�ZxxZf10r�Zs10rrr �test_check_arg_types�s@��zOddballs.test_check_arg_typesN)r4rIrJr�r�r�rrrr r��s%
r�c@seZdZdd�ZdS)�tzinfo2cCs�t|t�std��|j|k	r$td��|jdd���}|jdd���}|dks`|dks`|��dkrdt�||kr�||}|��}||kr�|S||fD]@}||}|��|kr�|S|jdd�}|��|kr�|Sq�td��dS)�*datetime in UTC -> datetime in local time.�&fromutc() requires a datetime argument�dt.tzinfo is not selfrr�r"NzNo suitable local time found)rPrrmrr�r�r^r`)r+r]Zoff0Zoff1�ldtZoffrrr r�s*


ztzinfo2.fromutcNr�rrrr r�sr�c@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�USTimeZone2cCs"t|d�|_||_||_||_dSr�r�r�rrr rW)szUSTimeZone2.__init__cCs|jSrXr�rZrrr r[/szUSTimeZone2.__repr__cCs|�|�r|jS|jSdSrXr�r\rrr r_2s
zUSTimeZone2.tznamecCs|j|�|�SrXr�r\rrr r^8szUSTimeZone2.utcoffsetcCs|dks|jdkrtS|j|ks$t�ttj|jd��}|��dkrV|jdkrV|j	dksZt�tt
j|jd��}|��dkr�|jdkr�|j	dks�t�|jdd�}|t|kr�|kr�nntS||kr�|tkr�nn|jr�tStS||k�r|tk�rnn|j�rtStStSdSr�)
rr�r�r�r�r�r�r�r�rHr�r�r�r�rrr r`;s$$ zUSTimeZone2.dstNr�rrrr r�'s
r��Eastern2�Central2�	Mountain2�Pacific2c@s<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)�Europe_Vilnius_1941cCs$tdddd|d�tdddd|d�gS)N�rFr�rirr��rrZrrr �	_utc_foldls�zEurope_Vilnius_1941._utc_foldcCs$tdddd|d�tdddd|d�gS)Nr�rFr�rr�rr�rZrrr �	_loc_foldps�zEurope_Vilnius_1941._loc_foldcCs>|��\}}||krdtS||kr6|jr.dndtSdtS)Nr>rB�r�r�r��r+r]Z
fold_startZ	fold_stoprrr r^tszEurope_Vilnius_1941.utcoffsetcCs>|��\}}||krdtS||kr6|jr.dndtSdtS)Nrr"r�r�rrr r`}szEurope_Vilnius_1941.dstcCs.|��\}}||krdS||kr*d|jSdS)N�MSK)r��CESTr�)r�r�r�rrr r_�s
zEurope_Vilnius_1941.tznamecCsr|jdkst�|j|kst�|jdkr*t�|��\}}||krJ|dtS||krf|dtjdd�S|dtS)Nrr�r>rBr"r�)r�r�rr�rqr�r�r�r�rrr r��s
zEurope_Vilnius_1941.fromutcN)	r4rIrJr�r�r^r`r_r�rrrr r�ks			r�c@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	e
�d�dd��Ze
�d�dd��Z
dd�Ze
�d�dd��Ze
�d�dd��Ze
�d�dd��Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/S)0�TestLocalTimeDisambiguationc	Cs�t�}tddddddtjd�}|�|�}|�|�d�d�|�|jd	�|�|�	��tdddd
tjd�}|�|�}|�|�d�d�|�|jd�|�
|�	��tdddd
tjd�}|�|�}|�|�d�d�|�|jd	�|�
|�	��dS)Nr�rFr�r�r�rz%c %Z%zz!Mon Jun 23 23:59:59 1941 MSK+0300rriz"Mon Jun 23 23:00:00 1941 CEST+0200r"r�z"Tue Jun 24 00:00:00 1941 CEST+0200)r�rrr�r�r*r�r�r�r`rt)r+�Vilnius�gdtr�rrr �test_vilnius_1941_fromutc�s,
�
�
�z5TestLocalTimeDisambiguation.test_vilnius_1941_fromutcc
Cs�t�}tdddddd|d�}|�tj�}|�|�d�d�tdddddd|d�}|�tj�}|�|�d�d	�tdddddd|d
d�}|�tj�}|�|�d�d�tddd
d|d�}|�tj�}|�|�d�d�dS)Nr�rFr�r�r�rz%c %ZzMon Jun 23 19:59:59 1941 UTCzMon Jun 23 20:59:59 1941 UTCr")rr�zMon Jun 23 21:59:59 1941 UTCr�rzMon Jun 23 22:00:00 1941 UTC)r�rr�rr�r*r�)r+r�r�r�rrr �test_vilnius_1941_toutc�s*����z3TestLocalTimeDisambiguation.test_vilnius_1941_toutcc	Csdtddd�}tddddd�}|�|jd�|�|jd�|�t��tdddddd�W5QRXdS�Nrr"r�)rrr*r�rlrm�r+r�r]rrr �test_constructors�sz-TestLocalTimeDisambiguation.test_constructorscCs@tddddd�}|��}|�|jd�|��}|�|jd�dS)Nr"r�)rrr*r�rA)r+r]r�rrr �test_member�s
z'TestLocalTimeDisambiguation.test_membercCsTtd�}tddd�}|�|jdd�jd�|�|jdd�jd�|�|jdd�jd�|�|jdd�jd�|jdtd�}|jdtd�}|�|jdd�jd�|�|jdd�jd�|�t��|jdd�W5QRX|�t��|jdd�W5QRX|�t��|�ddddd�W5QRX|�t�� |�ddddddddd�	W5QRXdS)Nrr"r�)r�rrrB)	rrr*r�r�r�rlr�rmr�rrr r.�s$z(TestLocalTimeDisambiguation.test_replacecCs@td�}tddd�}|�||jdd��|�||jdd��dSr�)rrr*r�r�rrr r��sz+TestLocalTimeDisambiguation.test_comparisoncCsPtd�}tddd�}|�t|�t|jdd���|�t|�t|jdd���dSr�)rrr*r(r�r�rrr �	test_hash�sz%TestLocalTimeDisambiguation.test_hashr�cCs<d}t�|�}t�|d�}|�|jd�|�|jd�dS)NiX�UTr�rr")rr�r*r�)r+r?�dt0rnrrr r�s

z.TestLocalTimeDisambiguation.test_fromtimestampzAustralia/Lord_HowecCslt�d�}t�d|�dkr$|�d�d}t�|�}t�|d�}|�||�|�|jd�|�|jd�dS)	N�����A�%Z%z�	LHST+1030�>Australia/Lord_Howe timezone is not supported on this platformi�U�rr")r�r�r�r5rr�r*r�)r+�tmr?r�r$rrr �test_fromtimestamp_lord_howes


z8TestLocalTimeDisambiguation.test_fromtimestamp_lord_howecCs|�t�d�jd�dSr�)r*rr�r�rZrrr �%test_fromtimestamp_low_fold_detectionszATestLocalTimeDisambiguation.test_fromtimestamp_low_fold_detectioncCs8tddddd�}|jdd�}|�|��d|���dS)NrhrjrBr"rkr�r�)rr�r*rI)r+r�rnrrr �test_timestamps
�z*TestLocalTimeDisambiguation.test_timestampcCsht�d�}t�d|�dkr$|�d�tddddd	�}|jd
d���}|jdd���}|�|d|�dS)
NrrrrrrDr?r"r�rr�r)r�r�r�r5rr�rIr*)r+rr��s0�s1rrr �test_timestamp_lord_howe$s

z4TestLocalTimeDisambiguation.test_timestamp_lord_howecCs|tddddd�}|jdd�}|��}|��}|�|��d�|�|��d�|�|t|�|�|jd	�|�|jd	�dS)
NrhrjrBr"rkr�r�r�r)rr�r�r*r_r�r�)r+r�rnZadt0Zadt1rrr r�.sz+TestLocalTimeDisambiguation.test_astimezonec	Csztdd�}tddddd�}tD]V\}}}||fD]B}|�||�}|�|�}|�||�|�|dkrfdn|j|j�q0qdS)Nr"r�rDr)rrr~rr�r*r�)	r+r�r]r�r�rryr?r�rrr �test_pickle_fold=s

z,TestLocalTimeDisambiguation.test_pickle_foldcCs>tdd�}tddddd�}|�t|�d�|�t|�d�dS)Nr"r�zdatetime.time(0, 0, fold=1)z(datetime.datetime(1, 1, 1, 0, 0, fold=1))rrr*r�r�rrr r�Gs

�z%TestLocalTimeDisambiguation.test_reprc	Cs
tddddtd�tj}tddddtd�}|�|��t�|�|��t�|�|jdd���t�|�|jdd���t�dD]@}tdddd|td�}|�|��t�|�|jdd���t�q~dD]@}tdd	d
d|td�}|�|��t�|�|jdd���t�q�dS)Nr�r#rr"rrBr�r�rDrA)	rr�rrAr*r`r�r�r�)r+�	dt_summer�	dt_winterrqr]rrr r�Nsz$TestLocalTimeDisambiguation.test_dstcCs�tddddtd�tj}tddddtd�}|�|��dt�|�|��dt�|�|jdd	���dt�|�|jdd	���dt�dS)
Nr�r#rr"rrBrEr�r�)rr�rrAr*r^r�r�)r+r
rrrr r�isz*TestLocalTimeDisambiguation.test_utcoffsetc	Csttddddtd�tj}tddddtd�}t�|�}t�|�}|�||dt�|�||dt�|�|jd	�|�|jd	�tddddd
td�}t�|�}|t7}t�|�}|�||�|�|jd	�|�|jd�tddddd
td�}t�|�}|�|j|j	fd�tddddd
td�}t�|�}|�|j|j	fd
�tddddd	td�}t�|�}|�|j|j	fd�dS)Nr�r#rrFrrArDr?rrkr")r�ri)rr"rB)rFri)
rr�rrAr�r*r�r�rHr�)	r+Zu_summerZu_winterZt_summerZt_winterr�r�r$r�rrr r�ss0






z(TestLocalTimeDisambiguation.test_fromutccCsLtdddtd�}|�||�tj��tdddtd�}|�||�tj��dS)Nr�r"rrF)rr�r*r�rr�r�rrr �test_mixed_compare_regular�sz6TestLocalTimeDisambiguation.test_mixed_compare_regularcCs<tdddddtd�}|�tj�}|�||�|�||�dS)Nr�r#rr"r�r�rr�r�rr�r�)r+�t_foldZ
t_fold_utcrrr �test_mixed_compare_fold�sz3TestLocalTimeDisambiguation.test_mixed_compare_foldcCs<tdddddtd�}|�tj�}|�||�|�||�dS)Nr�rDrArBr�rr)r+�t_gapZ	t_gap_utcrrr �test_mixed_compare_gap�sz2TestLocalTimeDisambiguation.test_mixed_compare_gapcCs�tdddtd�}|�t|�t|jdd���tdddddtd�}tdd	d
ddtd�}|�t|�t|jdd���|�t|�t|jdd���dS)Nr�r"rr�r�r#rr�rDrArB)rr�r*r(r�)r+r�rrrrr �test_hash_aware�sz+TestLocalTimeDisambiguation.test_hash_awareN)r4rIrJr�r�r�r�r.r�r�rrr�rrrrr�rr�r�r�r�rrrrrrrr r��s6



	


!r�cCs"t�|�\}}t|d�t||�SrX)rm�tee�nextr�)�iterablerrrrr �pairs�s
rc@s�eZdZdZdd�Zedd��Zedd��Zedd	��Z	e
d
dd���Zdd
�Z
dd�Zdd�Zdd�Zdd�Zed(dd��Zed)dd��Zdd�Zdd�Zed*d d!��Zd"d#�Zd$d%�Zd&d'�ZdS)+�ZoneInfoz/usr/share/zoneinfocCs||_||_|�||�|_dS)z�

        :param ut: array
            Array of transition point timestamps
        :param ti: list
            A list of (offset, isdst, abbr) tuples
        :return: None
        N)�ut�ti�invertr)r+rrrrr rW�s	zZoneInfo.__init__cCs�td|�td|�f}|r�|ddt}|dd|7<|dd|7<tdt|��D]H}|d|||ddt7<|d|||dt7<q^|S)Nrxrr")r�SECrr))rrrrVr
rrr r�s$"zZoneInfo.invertc	CsH|�d���dkrtd��|�d�td�}|�|d�tjdkrJ|��td�}|�||d�tjdkrt|��td	�}|�||d�g}t	|d
�D]}|�
t�d|�d���q�|�|d
�}t
|�D]:\}\}}	}
||
|�d|
����}td|�|	|f||<q�dgt|�}t
|�D]\}}
||
||<�q"|||�}|S)NrDZTZifznot a zoneinfo filerkr
r>r�rr�r"z>lbbrFrB)�read�decoder��seekr�fromfiler2�	byteorder�byteswaprr��struct�unpackr
�findrr))r)�fileobjZcountsrZtype_indicesZttisr
ZabbrsZgmtoff�isdstZabbrind�abbrr�idxr+rrr r"�s2



zZoneInfo.fromfilec
Cs<tj�|j|�}t|d��}|�|�W5QR�SQRXdS)N�rb)�os�path�join�zoneroot�openr")r)r0r.r�rrr �fromname�szZoneInfo.fromnamer r"cCst|t�std��|j|k	r$td��|��|jd|jd|jd|j	}||j
dkrn|jd}d}n�t�
|j
|�}|j
|d|ks�t�|t|j
�ks�||j
|ks�t�|j|d|�\}}|d|d}|td||j
|d�k}||d7}|�r|jdd	�S|Sd
S)r�r�r�r�r�r�r"rrBr�N)rPrrmrr�r��EPOCHORDINALr�rqrprr�bisect�bisect_rightr�r)rr�)r+r]rIZttir�r+Ztti_prev�shiftrrr r��s0

���
 zZoneInfo.fromutccCs\|��|jd|jd|jd|j}|j|j}t�||�}|j	t
d|d�|S)Nr�r�r�rr")r�r3r�rqrprr�r4r5rrp)r+r]r
rIrr+rrr �_find_tis���zZoneInfo._find_ticCs|�|d�Sr��r7r\rrr r^%szZoneInfo.utcoffsetcCs|�|d�}|rtStSrJ)r7r�r�)r+r]r)rrr r`(szZoneInfo.dstcCs|�|d�S)NrBr8r\rrr r_0szZoneInfo.tznameNc	cs�|dkr|j}tj�|d�}zt|�}Wntk
r>YdSX|�4|D](}|��}|rJ|�d�sJ|��dVqJW5QRXdS)Nzzone.tab�#rB)	r0r-r.r/r1r��stripr.r�)r)ZzonedirZzone_tabr��linerrr �	zonenames3szZoneInfo.zonenamescCs�d}}}}tj}}t}}	tj}
}d}}
tj}}d}}t|dd�}|��D]�}|d7}|�|�}|��D]�\}}||kr�qx|tkr�|d7}||f||fkr�|}|}
|}|tj|f|tj|
fkr�|}|}|}
qx|tk�rB|d7}|}||f|	|fk�r|}	|}|}|tj|f|tj|fk�rJ|}|}|}qx|d7}qxqZ|||f}td|�tdt	|�f|�td||
|f�td|||
f�td|||f�td|	||f�dS)	Nrr"zNumber of zones:       %5dz@Number of transitions: %5d = %d (gaps) + %d (folds) + %d (zeros)z!Min gap:         %16s at %s in %sz!Max gap:         %16s at %s in %sz!Min fold:        %16s at %s in %sz!Max fold:        %16s at %s in %s)
rrpr�rr�r<r2�transitions�printrW)r)�
start_year�countZ	gap_countZ
fold_countZzeros_countZmin_gapZmin_foldZmax_gapZmax_foldZmin_gap_datetimeZmax_gap_datetimeZmin_gap_zoneZmax_gap_zoneZmin_fold_datetimeZmax_fold_datetimeZ
min_fold_zoneZ
max_fold_zoneZstats_since�zonenamer�r]r6Ztrans_countsrrr �statsBsZ





�zZoneInfo.statsccsHtt|j|j��D]0\\}}\}}|d|d}t�|�|fVqdSr�)rr�rrrr��r+�_Zprev_tir�rr6rrr r=ss"zZoneInfo.transitionsccsntt|j|j��D]V\\}}\}}|d|d}|tkr|d|dkrt�|�||d|dfVqdS)zLFind all folds with the same value of isdst on both sides of the transition.rr"rBN)rr�rrr�rr�rCrrr �nondst_foldsxs"zZoneInfo.nondst_foldsFc

Csnd}|��D]\}|�|�}|��D]D\}}}}	|j|ks"|rF||	krFq"|d7}td||||||	f�q"qdS)Nrr"z%3d) %-30s %s %10s %5s -> %s)r<r2rEr�r>)
r)Z	same_abbrr?r@rAr�r]r6Z	prev_abbrr*rrr �print_all_nondst_foldss
�zZoneInfo.print_all_nondst_foldsccs*|��D]\}}|tkr||fVqdSrX�r=r��r+r�r6rrr �folds�szZoneInfo.foldsccs(|��D]\}}|tkr||fVqdSrXrGrHrrr �gaps�sz
ZoneInfo.gapsccs |��D]\}}|s|VqdSrX)r=rHrrr �zeros�szZoneInfo.zeros)N)r")Fr")r4rIrJr0rWrYr�classmethodr"r2rr�r3r�r7r^r`r_r<rBr=rErFrIrJrKrrrr r�s2


$

0rc@s8eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�ZdS)
�ZoneInfoTestzAmerica/New_Yorkc
Csbtjdkr|�d�zt�|j�|_Wn6tk
r\}z|�d|j|f�W5d}~XYnXdS)Nr�z"Skipping zoneinfo tests on WindowszSkipping %s: %s)r2rr5rr2rAr��FileNotFoundError)r+�errrrr r��s

zZoneInfoTest.setUpcCs<|�|jdd�|jt|j�f|jdd�|jt|j�f�dS)Nr)r*r�r��idr)r+rrrrr �assertEquivDatetimes�s�z!ZoneInfoTest.assertEquivDatetimesc	Cs�|j}|��D]�\}}d|d||tjfD]�}||}|�|j|d��}|�|jd�|jtj	d��
|�}|�||�|��}|�|jdd�||�|�|�
tj	�|jtj	d��q.tj|fD]0}||}|j|d�}|�|�}|�|jd�q�qdS)Nrr�rr")
r�rIrrAr�r�r*r�rr�r�rQr^�	r+r�r]r6ry�udtr�Zadtr^rrr �
test_folds�s$�
zZoneInfoTest.test_foldsc	Cs.|j}|��D�]\}}d|d||tjfD]�}||}|j|d�}|�|�}|�|jd�|jtj	d��
|�}|�||�|��}|�|jdd�|jdd�|�|�|j|d��||}|�
|jdd���|jdd���d|�q0tj|fD],}||}|�|j|d��}|�|jd�q�qdS)Nrr�rr"r�zAt %s.)r�rJrrAr�r�r*r�rr�r�rQr^Z
assertLessrRrrr �	test_gaps�s(
 �zZoneInfoTest.test_gapsc	Cs�d|jks|j�d�r&|�d|j�|j}tj�d�}|jtjd<�zt��|�	�D]�\}}|j
dkrp�qR|tddd�t}|t}dd	d
d|d|d|d
fD]J}||}t�
|�}	t�
||�jdd�}
|�|	|
�|	��}|�||�q�|dkrXt�
|�|d}|��}
|jdd���}|�|
||d�|�|||d�qXW5|dk�rjtjd=n
|tjd<t��XdS)NZRiyadh8zright/zSkipping %s�TZi�r r"i���i��r�ri@i�2rrBr�)rAr.r5r�r-�environ�getr��tzsetr=r�rrr�r�rQrIr*)r+r�rVrSr6r	roryr?ZsdtZtzdtr
r]Zts0Zts1rrr �test_system_transitions�sF

�
�



z$ZoneInfoTest.test_system_transitionsN)	r4rIrJrAr�rQrTrUrZrrrr rM�srMcseZdZ�fdd�Z�ZS)�ZoneInfoCompleteTestcshg}td�rXt��D]B}td|tfi�}||_t|�D]}|�d�r8|�||��q8qt	��
|�dS)NZtzdatazZoneInfoTest[%s]Ztest_)r
rr<r}rMrAr7r.r��superrW)r+rer0ZTest�method�r3rr rWs
zZoneInfoCompleteTest.__init__)r4rIrJrW�
__classcell__rrr^r r[sr[c@seZdZdZdS)�IranTestzAsia/TehranN)r4rIrJrArrrr r`sr`c@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#S)$�CapiTestcCs$|jj�d�r|�d�t��dS)NZPurezNot relevant in pure Python)r3r4r/r5�	_testcapiZtest_datetime_capirZrrr r�s
zCapiTest.setUpc
Cs>dD]4}t�|�}|j|d��|�|tj�W5QRXqdS)N�TF)�	use_macro)rbZget_timezone_utc_capir�r|rr�)r+rdZcapi_utcrrr �
test_utc_capis
zCapiTest.test_utc_capic

Cs�t��\}}}ttdd�d�}ttdd��}d||fd||fd||fg}|D]�\}}}	|j|d��z|�||	�tdd	d
|d�}
tdd	d
|	d�}|�|
|�|�|
��|���tdd	d
dtjd�}|�|
�	tj�|�W5QRXqLdS)
Nr�r�r��est_capi�	est_macro�est_macro_nn)r0r�rBrDrr?)
rbZmake_timezones_capirrr�r*rr_r�r�)
r+rfrgrhZ	exp_namedZexp_unnamed�casesr0Ztz_actZtz_exprnr�r�rrr �test_timezones_capi&s �zCapiTest.test_timezones_capic	Cs�t��\}}}|jdd��|�|tj�W5QRX|jdd��|�|tj�W5QRX|jdd��p|�|tj�ttdd�d�}|�||�t	dd	d
|d�}t	dd	d
|d�}|�||�|�|�
�|�
��W5QRXdS)N�utc0)Ztestname�utc1�non_utcrr�r�r�rBrDr)rbZget_timezones_offset_zeror�r|rr�r�rr*rr_)r+rkrlrmZnon_utc_exprnr�rrr �test_timezones_offset_zero@sz#CapiTest.test_timezones_offset_zeroc	Cs�Gdd�dt�}tddd�}|ddd�}tddd�}tj}|�||��|�||��|�||��|�||d��|�||d��|�||d��t�t�ddtd�t	j
tdd�g}|D]8}d	D].}|j||d
��|�|||��W5QRXq�q�dS)Nc@seZdZdS)z.CapiTest.test_check_date.<locals>.DateSubclassNr]rrrr r^Wsr^��r"T�
2011-01-01r�rrc��arg�exact)
rrrbZdatetime_check_datertr�r{rzrrr�rr�)	r+r^r*Zdsr]Zis_dater�rrrsrrr �test_check_dateVs(�zCapiTest.test_check_datecCs�Gdd�dt�}tdd�}|dd�}tj}|�||��|�||��|�||d��|�||d��t�t�ddtd�tj	t
ddd�g}|D]8}d	D].}|j||d
��|�|||��W5QRXq�q�dS)Nc@seZdZdS)z.CapiTest.test_check_time.<locals>.TimeSubclassNr]rrrr r*ssr*r�rkTr"rprorcrq)rrbZdatetime_check_timertr�r{rzrrr�rr�)r+r*r�r�Zis_timer�rrrsrrr �test_check_timers"


�zCapiTest.test_check_timecCs�Gdd�dt�}tddddd�}|ddddd�}tj}|�||��|�||��|�||d��|�||d��t�t�ddtd�tj	t
ddd�g}|D]8}d	D].}|j||d
��|�|||��W5QRXq�q�dS)Nc@seZdZdS)z6CapiTest.test_check_datetime.<locals>.DateTimeSubclassNr]rrrr rj�srjror"r�rkTrprcrq)rrbZdatetime_check_datetimertr�r{rzrrr�rr�)r+rjr]r�Zis_datetimer�rrrsrrr �test_check_datetime�s"
�zCapiTest.test_check_datetimecCs�Gdd�dt�}td�}|d�}tj}|�||��|�||��|�||d��|�||d��t�t�ddtjt	ddd�t
ddd�g}|D]8}dD].}|j||d��|�|||��W5QRXq�q�dS)	Nc@seZdZdS)z4CapiTest.test_check_delta.<locals>.TimeDeltaSubclassNr]rrrr �TimeDeltaSubclass�srwr"Trprorcrq)rrbZdatetime_check_deltartr�r{rzrr�rrr�)r+rwr�ZtdsZis_timedeltar�rrrsrrr �test_check_delta�s"

�zCapiTest.test_check_deltac	Cs�Gdd�dt�}t�}|�}ttdd��}tj}|�||��|�||��|�||��|�||d��|�||d��|�||d��t�t�ddt	ddd�t
ddd�g}|D]8}d	D].}|j||d
��|�|||��W5QRXq�q�dS)Nc@seZdZdS)z2CapiTest.test_check_tzinfo.<locals>.TZInfoSubclassNr]rrrr �TZInfoSubclass�sryr�r�Tr"rprorcrq)rrrrbZdatetime_check_tzinfortr�r{rzrrr�)	r+ryr�Ztzisr�Z	is_tzinfor�rrrsrrr �test_check_tzinfo�s&

�zCapiTest.test_check_tzinfoc
CsTtddd�}dD]>}|j|d��(t�||j|j|j�}|�||�W5QRXqdS)N��rtr��rr"��macro)rr�rbZget_date_fromdater�r�rHr*�r+�exp_dater~�
c_api_daterrr �test_date_from_date�s�zCapiTest.test_date_from_datecCsltddddddd�}dD]N}|j|d	��8t�||j|j|j|j|j|j	|j
�}|�||�W5QRXqdS)
Nr{rtr�r�r��7韆r|r})rr�rbZget_datetime_fromdateandtimer�r�rHr�rqrpr�r*rrrr �test_datetime_from_dateandtime�s�
z'CapiTest.test_datetime_from_dateandtimecCs�tddddddd�}dD]n}dD]d}|j||d	��Lt�||j|j|j|j|j|j	|j
|j�	}|�||�|�|j|j�W5QRXq qdS)
Nr{rtr�r�r�r�r�r|�r~r�)
rr�rbZ#get_datetime_fromdateandtimeandfoldr�r�rHr�rqrpr�r�r*)r+r�r�r~r�rrr �%test_datetime_from_dateandtimeandfold�s"�z.CapiTest.test_datetime_from_dateandtimeandfoldc
CsZtdddd�}dD]B}|j|d��,t�||j|j|j|j�}|�||�W5QRXqdS)Nr�r�r�r�r|r})	rr�rbZget_time_fromtimer�rqrpr�r*)r+�exp_timer~�
c_api_timerrr �test_time_from_times�zCapiTest.test_time_from_timecCsztdddd�}dD]b}dD]X}|j||d��@t�||j|j|j|j|j�}|�	||�|�	|j|j�W5QRXqqdS)Nr�r�r�r�r|r�)
rr�rbZget_time_fromtimeandfoldr�rqrpr�r�r*)r+r�r�r~r�rrr �test_time_from_timeandfolds�z#CapiTest.test_time_from_timeandfoldc
CsTtddd�}dD]>}|j|d��(t�||j|j|j�}|�||�W5QRXqdS)Nr�r�r�r|r})rr�rbZget_delta_fromdsur�r�r�r*)r+Z	exp_deltar~Zc_api_deltarrr �test_delta_from_dsu.s�zCapiTest.test_delta_from_dsuc
CsZtddd���}dD]@}|j|d��*t�t|�|�}|�|tddd��W5QRXqdS)N��rDr�r|r})rrIr�rbZget_date_fromtimestamprQr*r)r+r�r~r*rrr �test_date_from_timestamp;s
z!CapiTest.test_date_from_timestampcCs�dddttdd��dfddd	ttdd��dfg}tj}|D]f}d
D]\}|j||d��D|\}}}t|d|i�}t|���}	||	|||�}
|�||
�W5QRXqBq:dS)
N)�r�rDr�NF)r�NTr�r"r�T)�r�rDr�r�rkNF)r�NTr�r|)�caser~r)	rrrbZget_datetime_fromtimestampr�rrQrIr*)r+rir�r�r~ZdtuprZusetzZdt_origr�rbrrr �test_datetime_from_timestampDs �	
z%CapiTest.test_datetime_from_timestampN)r4rIrJr�rerjrnrtrurvrxrzr�r�r�r�r�r�r�r�rrrr ras"	

	racCs|�t��|SrX)ZaddTestr[)�loaderZstandard_tests�patternrrr �
load_tests[sr��__main__)mr�rmr4r�r�r2r-rrerr%rr�operatorrrrrrrr	r
r�testrZtest.supportr
rrrrr)rrrrrrrr�rbr�r��_loadsrrr�r~r)r�r2r~rKrZTestCaser'rKrardrgr�r�r�r�r�r�r}r~rrrr0rUrtr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrMZ	TestSuiter[r`rar�r4�mainrrrr �<module>s�,�2_A3=!K\"<


*c"32
gi
H


Zerion Mini Shell 1.0