Your IP : 216.73.216.213


Current Path : /opt/alt/python39/lib64/python3.9/test/test_zoneinfo/__pycache__/
Upload File :
Current File : //opt/alt/python39/lib64/python3.9/test/test_zoneinfo/__pycache__/test_zoneinfo.cpython-39.pyc

a

XC?h�#�@s�ddlmZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlZddlZddlmZmZmZmZmZddlmZddlmZddlmZmZmZddlmZed	�Z e�!�\Z"Z#zej$�$d
�dZ%Wnej$j&�ydZ%Yn0da'da(da)e
�*e+�j,d
Z-e-dZ.ed�Z/edd�Z0dd�Z1dd�Z2Gdd�d�Z3Gdd�d�Z4Gdd�de3e�Z5Gdd�de5�Z6Gdd�de4e5�Z7Gdd�de4e6�Z8Gd d!�d!e5�Z9Gd"d#�d#e9�Z:Gd$d%�d%e5�Z;Gd&d'�d'e;�Z<e�=e%d(�Gd)d*�d*e5��Z>e�=e%d(�Gd+d,�d,e>��Z?Gd-d.�d.e�Z@Gd/d0�d0e@�ZAGd1d2�d2e�ZBGd3d4�d4eB�ZCGd5d6�d6e3e�ZDGd7d8�d8eD�ZEGd9d:�d:e3e�ZFGd;d<�d<eF�ZGGd=d>�d>e�ZHGd?d@�d@eH�ZIGdAdB�dBe3e�ZJGdCdD�dDeJ�ZKGdEdF�dFe�ZLGdGdH�dHeL�ZMGdIdJ�dJejN�ZOejPddK�GdLdM�dM��ZQejPddK�GdNdO�dO��ZRGdPdQ�dQ�ZSGdRdS�dS�ZTdS)T�)�annotationsN)�date�datetime�time�	timedelta�timezone)�cached_property�)�_support)�OS_ENV_LOCK�TZPATH_TEST_LOCK�ZoneInfoTestBase)�
import_module�lzmaZtzdataTF�datazzoneinfo_data.json��hourscCs6t�tjdd��atttd�atttddd�adS)NZzoneinfo)�prefixZv2�v1T)r)	�pathlib�Path�tempfileZmkdtemp�TEMP_DIR�ZoneInfoData�
ZONEINFO_JSON�
ZONEINFO_DATA�ZONEINFO_DATA_V1�rr�E/opt/alt/python39/lib64/python3.9/test/test_zoneinfo/test_zoneinfo.py�setUpModule,srcCst�t�dS�N)�shutilZrmtreerrrrr�tearDownModule6sr"cs8eZdZdZedd��Zedd��Z�fdd�Z�ZS)�TzPathUserMixinaH
    Adds a setUp() and tearDown() to make TZPATH manipulations thread-safe.

    Any tests that require manipulation of the TZPATH global are necessarily
    thread unsafe, so we will acquire a lock and reset the TZPATH variable
    to the default state before each test and release the lock after the test
    is through.
    cCsdSr r��selfrrr�tzpathDszTzPathUserMixin.tzpathcCsdS)NTrr$rrr�block_tzdataHszTzPathUserMixin.block_tzdatacs`t���:}|�|j|j|jtd��|�|��j	�Wd�n1sH0Yt
���dS)N)r'�lock)�
contextlib�	ExitStack�
enter_context�tzpath_contextr&r'r�
addCleanup�pop_all�close�super�setUp�r%�stack��	__class__rrr1Ls
��.zTzPathUserMixin.setUp)	�__name__�
__module__�__qualname__�__doc__�propertyr&r'r1�
__classcell__rrr4rr#:s	

r#cs0eZdZdZGdd�de�Z�fdd�Z�ZS)�DatetimeSubclassMixinzP
    Replaces all ZoneTransition transition dates with a datetime subclass.
    c@seZdZedd��ZdS)z&DatetimeSubclassMixin.DatetimeSubclasscCs,||j|j|j|j|j|j|j|j|jd�	S)N)�tzinfo�fold)	�year�month�day�hour�minute�second�microsecondr=r>)�cls�dtrrr�
from_datetime`s�z4DatetimeSubclassMixin.DatetimeSubclass.from_datetimeN)r6r7r8�classmethodrHrrrr�DatetimeSubclass_srJc#s@t��|�}|D]*}|j}|j�|�}tj||d�}|VqdS)N)�
transition)r0�load_transition_examplesrKrJrH�dataclasses�replace)r%�keyZtransition_examples�ztrGZnew_dtZnew_ztr4rrrLnsz.DatetimeSubclassMixin.load_transition_examples)r6r7r8r9rrJrLr;rrr4rr<Zsr<cs�eZdZeZdZ�fdd�Zedd��Zedd��Z	dd	�Z
d
d�Zdd
�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Z�ZS)*�ZoneInfoTest�ZoneInfocst���|j��dSr )r0r1�klass�clear_cacher$r4rrr1{s
zZoneInfoTest.setUpcCstSr �rr$rrr�
zoneinfo_data�szZoneInfoTest.zoneinfo_datacCs
|jjgSr �rVr&r$rrrr&�szZoneInfoTest.tzpathcCs
|�|�Sr �rS�r%rOrrr�
zone_from_key�szZoneInfoTest.zone_from_keycCst��Sr )�ZoneDumpData�transition_keysr$rrr�zones�szZoneInfoTest.zonescCst��Sr )r[�fixed_offset_zonesr$rrrr^�szZoneInfoTest.fixed_offset_zonescCs
t�|�Sr )r[rLrYrrrrL�sz%ZoneInfoTest.load_transition_examplesc	Cs�|��D]H}|�|��*|�|�}|�t|�|�Wd�q1sF0Yq|jjd}|j�|�}t|d��^}|jd|d��0|j	�
|�}|�t|�t|��Wd�n1s�0YWd�n1s�0YdS)Nr�rbz	Repr test)�	test_name�path)r]�subTestrZ�assertEqual�strrV�keys�
path_from_key�openrS�	from_file�repr)r%rO�zi�file_key�	file_path�f�zi_ffrrr�test_str�s
0zZoneInfoTest.test_strc	Csdtt|����}|�|�}|j}|jdd�� |�t|�|�Wd�n1sR0Y|jj	d}|j�
|�}t|d�� }|jj||d�}Wd�n1s�0Y|jdd�� |�t|�|�Wd�n1s�0Yt|d��}|j�|�}Wd�n1�s0Y|jdd�� |�t|�|�Wd�n1�sV0YdS)Nzfrom key)�namerr_�rOzfrom file with keyzfrom file without key)
�next�iterr]rS�
class_namerbZassertRegexrirVrerfrgrh)	r%rOrjrtrkrlrmrnZzi_ff_nkrrr�	test_repr�s
...,zZoneInfoTest.test_reprc
s�tt�����}�fdd�}d�j|fd�jj|fd|dff}|D]�\}}}||�}��|����|j|�Wd�n1s�0Y��|�d���@��t	��d|_Wd�n1s�0YWd�qB1s�0YqBdS)NcsBt�j�|�d��}�j�|�Wd�S1s40YdS)Nr_)rgrVrfrSrh)rOrmr$rr�from_file_nokey�sz8ZoneInfoTest.test_key_attribute.<locals>.from_file_nokeyzPrimary constructor�no_cacherhz
: readonlyz
Some/Value)
rrrsr]rSrwrbrcrO�assertRaises�AttributeError)r%rOrvZconstructors�msg�constructor�expectedrjrr$r�test_key_attribute�s
�,zZoneInfoTest.test_key_attributec	CsNgd�}|D]<}|�|jj��|�|�Wd�q1s>0YqdS)N)zEurasia/BadzoneZBZQzAmerica.Los_Angelesu🇨🇦uAmerica/New�York)rx�moduleZZoneInfoNotFoundErrorrS�r%Zbad_keysZbad_keyrrr�
test_bad_keys�szZoneInfoTest.test_bad_keysc	CsJgd�}|D]8}|�t��|�|�Wd�q1s:0YqdS)N)z/America/Los_AngeleszAmerica/Los_Angeles/z../zoneinfo/America/Los_AngeleszAmerica/../America/Los_AngeleszAmerica/./Los_Angeles)rx�
ValueErrorrSrrrr�test_bad_keys_paths�sz ZoneInfoTest.test_bad_keys_pathsc	CsVddg}|D]D}t�|�}|�t��|j�|�Wd�q1sF0YqdS)N�sAAAA3               )�io�BytesIOrxr�rSrh)r%Z	bad_zonesZbad_zone�fobjrrr�test_bad_zones�s�
zZoneInfoTest.test_bad_zonesc
Cs�tt|����}|�|�}tdddtjd�tftddd�tftddd�t	ft
d�t	fdt	fdt	fg}|D]h\}}|j|d��D|�|��|�
|�Wd�n1s�0YWd�qh1s�0YqhdS)N��r	�r=rz
2019-01-01)�val)rrrsr]rZrr�utcr�r�	TypeErrorrrbrx�fromutc)r%rOZzone�
bad_valuesr��exc_typerrr�test_fromutc_errors�s

�	z ZoneInfoTest.test_fromutc_errorscCsN|�d�}tddd|d�}|�|��t�|�|��t�|�|��d�dS)N�UTC��r	r�)rSrrc�	utcoffset�ZERO�dst�tzname)r%rjrGrrr�test_utcs

zZoneInfoTest.test_utcc	Cs�g}|��D]P}|�|�D]@}|�||jtdd�|jf�|�||jtdd�|jf�qq|D]�\}}}|j|||d��b|�|�}|j	|d�}|�
|��|j|�|�
|��|j|�|�
|�
�|j
|�Wd�qb1s�0YqbdS)N�)Zdays)rOrG�offsetr�)r]rL�appendrKr�
offset_before�offset_afterrbrZrNrcr�r�r�)r%�
test_casesrOZzone_transitionrGr��tzirrr�test_unambiguouss,����
zZoneInfoTest.test_unambiguousc	CsNg}|��D�]�}ggd�}|�|�D�]N}|jr<|d}n|jrL|d}nd}q&|jtdd�}|�|d|jf�|�|d|jf�|j}|�|d|jf�|�|d|jf�|jtdd�}|�|d|jf�|�|d|jf�|j	tdd�}|�|d|jf�|�|d|jf�|j	}|�|d|jf�|�|d|jf�|j	tdd�}|�|d|jf�|�|d|jf�q&|�
�D]\}}|�||f|f��q�q|D]�\\}}}|j||d��v|�|�}	|D]V\}}
}|j
|
|	d�}|�|��|j|�|�|��|j|�|�|��|j|��q�Wd�n1�s<0Y�q�dS)	N)�folds�gapsr�r�r	��secondsr)rO�grp�r>r=)r]rLr>�gap�
anomaly_startrr�r�r��anomaly_end�itemsrbrZrNrcr�r�r�)r%r�rOZtestsrPZ
test_groupZno_peephole_optrGr�r�r>r�rrr�test_folds_and_gaps4sL



z ZoneInfoTest.test_folds_and_gapsc		Cs�|��D]�}|�|�}|j|d���|�|�D]j}|js:q.|j}|tdd�}|tdd�}|�|�}|�|jd||f�|�|�}|�|jd||f�q.Wd�q1s�0YqdS)Nrqr	r�r)	r]rZrbrLr>�transition_utcr�
astimezonerc)	r%rOrjrP�dt_utcZ
dt_before_utcZdt_after_utcZ	dt_beforeZdt_afterrrr�test_folds_from_utcks


z ZoneInfoTest.test_folds_from_utcc	Cs�|��D]|}|�|�}tdddd|d�}|j|d��@|�|��d�|�|��d�|�|��d�Wd�q1sz0YqdS�N��r	i��r�rq)r]rZrrb�assertIsr�r�r�)r%rOrj�trrr�test_time_variable_offset}s
z&ZoneInfoTest.test_time_variable_offsetc	Cs�|��D]�\}}|�|�}tdddd|d�}|j|d��F|�|��|j�|�|��|j�|�|��|j�Wd�q1s�0YqdSr�)r^rZrrbrcr�r�r�)r%rOr�rjr�rrr�test_time_fixed_offset�s
z#ZoneInfoTest.test_time_fixed_offset)r6r7r8�py_zoneinfor~rtr1r:rVr&rZr]r^rLrorur}r�r�r�r�r�r�r�r�r�r�r;rrr4rrQws0



7rQc@seZdZeZdd�ZdS)�
CZoneInfoTestc		Cs�dd�}ddg}d}|�|�}|�|�D](}|jr(|jjtkr(|jj|d�}qRq(dD]h}|rh||�}n|}|j|d��6|�	|�}|�
|jd	�|�
|jd
�Wd�qV1s�0YqVdS)a:Test that fold isn't mutated when no change is necessary.

        The underlying C API is capable of mutating datetime objects, and
        may rely on the fact that addition of a datetime object returns a
        new datetime; this test ensures that the input datetime to fromutc
        is not mutated.
        cSs@Gdd�dt|��}||j|j|j|j|j|j|j|j|j	d�	S)NcseZdZ�fdd�Z�ZS)zLCZoneInfoTest.test_fold_mutate.<locals>.to_subclass.<locals>.SameAddSubclasscs|td�kr|St��|�S�Nr)rr0�__add__)r%�otherr4rrr��szTCZoneInfoTest.test_fold_mutate.<locals>.to_subclass.<locals>.SameAddSubclass.__add__)r6r7r8r�r;rrr4r�SameAddSubclass�sr�r�)
�typer?r@rArBrCrDrEr>r=)rGr�rrr�to_subclass�s�z3CZoneInfoTest.test_fold_mutate.<locals>.to_subclassFT�
Europe/Londonr�)FT)�subclassr	rN)rZrLr>r�r�r�r�rNrbr�rc)	r%r�r�rOrjrPZexamplerGZ
dt_fromutcrrr�test_fold_mutate�s 	


zCZoneInfoTest.test_fold_mutateN)r6r7r8�
c_zoneinfor~r�rrrrr��sr�c@seZdZdS)�ZoneInfoDatetimeSubclassTestN�r6r7r8rrrrr��sr�c@seZdZdS)�CZoneInfoDatetimeSubclassTestNr�rrrrr��sr�cs(eZdZe�fdd��Zdd�Z�ZS)�ZoneInfoSubclassTestcs4t���Gdd�d|j�}d|_|j|_||_dS)Nc@seZdZdS)z3ZoneInfoSubclassTest.setUpClass.<locals>.ZISubclassNr�rrrr�
ZISubclass�sr�)r0�
setUpClassrSrt�parent_klass)rFr�r4rrr��s

zZoneInfoSubclassTest.setUpClasscCs@|�d�}|�d�}|�||�|�||j�|�||j�dS)Nr�)r�rS�assertIsNotZassertIsInstance)r%Zbase_objZsub_objrrr�test_subclass_own_cache�s


z,ZoneInfoSubclassTest.test_subclass_own_cache)r6r7r8rIr�r�r;rrr4rr��s
r�c@seZdZeZdS)�CZoneInfoSubclassTestN�r6r7r8r�r~rrrrr��sr�c@s eZdZedd��Zdd�ZdS)�ZoneInfoV1TestcCstSr )rr$rrrrV�szZoneInfoV1Test.zoneinfo_dataccsZtddd�}tdd�}||}||}t�|�D]$}||jkrJ|kr0nq0|Vq0dS)N�r	�r�)rrr[rLrK)r%rOZepochZ
max_offset_32Zmin_dtZmax_dtrPrrrrL�s
z'ZoneInfoV1Test.load_transition_examplesN)r6r7r8r:rVrLrrrrr��s
r�c@seZdZeZdS)�CZoneInfoV1TestNr�rrrrr��sr�z4Skipping tzdata-specific tests: tzdata not installedc@s0eZdZdZedd��Zedd��Zdd�ZdS)	�TZDataTestsa5
    Runs all the ZoneInfoTest tests, but against the tzdata package

    NOTE: The ZoneDumpData has frozen test data, but tzdata will update, so
    some of the tests (particularly those related to the far future) may break
    in the event that the time zone policies in the relevant time zones change.
    cCsgSr rr$rrrr&
szTZDataTests.tzpathcCsdS)NFrr$rrrr'szTZDataTests.block_tzdatacCs|j|d�S)NrqrXrYrrrrZszTZDataTests.zone_from_keyN)r6r7r8r9r:r&r'rZrrrrr�s

r�c@seZdZeZdS)�CTZDataTestsNr�rrrrr�sr�c@sReZdZeZdd�Zdd�Zdd�Zdd�Zd	d
�Z	dd�Z
d
d�Zddd�ZdS)�
WeirdZoneTestc
Cs�tdtdddd��}tdtdd��}ttddd	d
�||�g}d}|�||�}|j�|�}tddd	d|d
�}tdddd|d
�}||f||ffD]l\}	}
|jd|	d��F|�|	�	�|
j	�|�|	�
�|
j
�|�|	��|
j�Wd�q�1s�0Yq�tddd	d|d
�tddd	dddtj
d
�ftdddd|d
�tddddtj
d
�fg}|D]h\}}
|jd|d��>|
�|�}|�||�|�tj
�}|�||
�Wd�n1�s�0Y�qRdS)N�LMT��r�)rZminutesr��STDr�[�	�ZSTD6r	r��
Zlocal)rprG������r�)�
ZoneOffsetr�ZoneTransitionr�construct_zonerSrhrbrcr�r�r�rr�r�)r%r�r��transitions�after�zfrjZdt0Zdt1rGr��dtsZdt_localr�Z	dt_actualZ
dt_utc_actualrrr�test_one_transition#s6�2���
z!WeirdZoneTest.test_one_transitionc	Cs�tdtt�}ttddd�||�g}d}|�||�}|j�|�}tddd�tddd	�tddd�td
dd�tddd�g}|D]r}|j|d
�}|j|d��F|�	|�
�|j
�|�	|��|j�|�	|��|j�Wd�qx1s�0YqxdS)N�DSTr�r	zSTD0DST-1,0/0,J365/25�l�i�r�r�r�r��r��rG)
r��ONE_Hr�rr�rSrhrNrbrcr�r�r�)r%r�r�r�r�rjr�rGrrr�test_one_zone_dstLs$�




�zWeirdZoneTest.test_one_zone_dstc	Cs�tdtt�}tddtt�}g}tdd�D]<}|�tt|ddd�||��|�tt|ddd�||��q*d	}|�||�}|j�	|�}td
dd�|ftddd�|ftddd�|ftddd�|fg}|D]x\}	}
|	j
|d
�}	|j|	d��F|�|	�
�|
j
�|�|	��|
j�|�|	��|
j�Wd�q�1�s20Yq�td|d
�}|�d��@|�|�
�d�|�|��d�|�|��d�Wd�n1�s�0YdS)Nr�r�r�����r�r	r��i�r�i�r�r�rzTesting datetime.time)r�r�r��ranger�r�rr�rSrhrNrbrcr�r�r�rr�)r%r�r�r�r?r�r�rj�casesrGr�r�rrr�test_no_tz_strfs:���4zWeirdZoneTest.test_no_tz_strc	
Cs�tdtt�tdtt�g}|D]�}td||�g}d}|�||�}|j�|�}tddd�tddd�tddd�g}|D]t}|j|d�}|j	||d	��F|�
|��|j�|�
|��|j�|�
|�
�|j
�Wd�qp1s�0YqpqdS)
Nr�r�r�r�r	r�r�r�)r�rG)r�r�r�r�r�rSrhrrNrbrcr�r�r�)	r%�offsetsr�r�r�r�rjr�rGrrr�test_tz_before_only�s&

�
�


�z!WeirdZoneTest.test_tz_before_onlycCsF|�gd�}|�t��|j�|�Wd�n1s80YdS)Nr�)r�rxr�rSrh)r%r�rrr�test_empty_zone�szWeirdZoneTest.test_empty_zonecCs�tdtdd��}tdt�}d||fttddd�||�d||fg}d	}|�||�}|jj|d
d�}tj|ftj	|ftdd
d�|ftddd�|fg}|D]|\}}	|j
|d�}
|jd|
|	d��F|�|
�
�|	j
�|�|
��|	j�|�|
��|	j�Wd�q�1�s0Yq�tjtjtdd�ftdd
dddd�tddd�ftdd
ddddd�tddddddd�ftdddddd�tdddddd�ftd dd�td dd�ftj	tj	fg}|D]B\}}
|j
|d�}
|
j
tjd�}|�|�|�|
�|�|
|��q�dS)!a�Test when a transition is in the far past or future.

        Particularly, this is a concern if something:

            1. Attempts to call ``datetime.timestamp`` for a datetime outside
               of ``[datetime.min, datetime.max]``.
            2. Attempts to construct a timedelta outside of
               ``[timedelta.min, timedelta.max]``.

        This actually occurs "in the wild", as some time zones on Ubuntu (at
        least as of 2020) have an initial transition added at ``-2**58``.
        r��8���r��GMTl�����xr	lZGMT0�Africa/Abidjanrqiwr�r�r�r�r�)rprGr�Ni�ij��+�4ik�;�?Br�r��r�)r�rr�r�rr�rSrh�min�maxrNrbrcr�r�r�rr�r�)r%r�r�r�r�r�rjZoffset_cases�dt_naiver�rGZ	utc_casesZnaive_dtZnaive_dt_utcr�rrr�test_zone_very_large_timestamp�sD
��4�"
�z,WeirdZoneTest.test_zone_very_large_timestampcCs$tdtt�}ttddd�||�g}d}|�||�}|jj|dd�}tddd|d�}|�d��F|�|�	�|j	�|�|�
�|j
�|�|��|j�Wd�n1s�0Ytd	|d�}|�d
��F|�|�	�|j	�|�|�
�|j
�|�|��|j�Wd�n1�s0YdS)Nr�r�r	ZUTC0rqr�r�zdatetime.datetimerz
datetime.time)
r�r�r�rr�rSrhrbrcr�r�r�r)r%r�r�r�r�rjrGr�rrr�$test_fixed_offset_phantom_transition�s0z2WeirdZoneTest.test_fixed_offset_phantom_transitionNr�c(Csg}g}g}ggg}ggg}ggg}	d}
d}|
|g}dd�}
tt|
|�dd�d�}|D]�}|\}}}t|�D]�\}\}}||}||}|	|}|dur�||kr�|ks�qlql||vr�|�|�||vr�|�|�|durl|�|�|�|�|��qlqVt|�}t|�}t|�}t��}d}tt	|d	f��D�]�}||}||}|	|}||}t
�}g}|D]J} t| j�
��}!t| j�}"t|�}#|�|!|"|#f�|| j�d
�d7}�qbt|�}t|�}$t|�}%t|�}&|�d�|�d
|�|�d�|�t�d||||%|$|&��|�tjd|%�|��g|�R��|�tjd|%�d�g|�R��|D]}'|�tjdg|'�R���qR|�t|��|�tj|�d�g|�R��|�tj|�d�g|�R��|�tjd|�d�g|�R��|dk�r.|�d�|�|�d
��|�d��q.|�d�|S)N)i�r�)l����lcSs6t|t�r|S|jr$t|j���}nd}||j|jfSr )�
isinstance�tuplerK�intr�Z	timestampr�r�)rP�
trans_timerrr�zt_as_tuples
z1WeirdZoneTest.construct_zone.<locals>.zt_as_tuplecSs|dSr�r)�xrrr�<lambda>+r�z.WeirdZoneTest.construct_zone.<locals>.<lambda>rq)�l�qr��ascii��TZifs%d�               �>6l�>�Bz>lbb�brr�
)�sorted�map�	enumerater��index�lenr�r�r�r�	bytearrayrr�Z
total_seconds�boolr�r��encode�bytes�write�struct�pack�seek)(r%r�r��versionZisutcZisstdZleap_secondsZoffset_listsZtrans_times_listsZtrans_idx_listsZv1_rangeZv2_rangeZrangesr
rPrr�r��vZdt_minZdt_maxr�Ztrans_timesZ	trans_idx�isutcnt�isstdcnt�leapcnt�zonefileZ
time_typesZ	time_typeZabbrstrZttinfosr�ZutcoffZisdstZabbrind�typecnt�timecnt�charcntZttinforrrr�
s�
��





��"  


zWeirdZoneTest.construct_zone)Nr�)
r6r7r8r�r~r�r�r�r�r�rrr�rrrrr� s)+$=r�c@seZdZeZdS)�CWeirdZoneTestNr�rrrrr1�sr1csheZdZeZdZdZdZe�fdd��Z	edd��Z
dd	�Zd
d�Zdd
�Z
dd�Zedd��Z�ZS)�	TZStrTestrr	r�cst���|��|��dSr )r0r��_populate_test_cases�populate_tzstr_header�rFr4rrr��s
zTZStrTest.setUpClasscCsTt�}td�D]6}|d7}|d7}|d7}|t�ddddddd�7}qt|�|_dS)Nr�r�3rrr)r r�r%r&r#�_tzif_header)rF�out�_rrrr4�szTZStrTest.populate_tzstr_headercCsVt�|j�}|�dd�|�d�|�|�d��|�d�|�d�|jj||d�S)z/Creates a zoneinfo file following a POSIX rule.rr�rrrq)r�r�r7r'r$r"rSrh)r%�tzstrr-rrr�zone_from_tzstr�s


zTZStrTest.zone_from_tzstrc
Cs�|j��D]�\}}|j|d��|�|�}Wd�n1s>0Y|D]|\}}}|j|d�}|j|||d��F|�|��|j�|�|��|j�|�|��|j�Wd�qL1s�0YqLq
dS)N�r:r�)r:rGr�)	r�r�rbr;rNrcr�r�r�)r%r:r�rjrr�r9rGrrr�test_tzstr_localized�s(zTZStrTest.test_tzstr_localizedc
	Cs�|j��D]�\}}|j|d��|�|�}Wd�n1s>0Y|D]�\}}}||jkrbqL||jjtjd�}|�	|�}|j|d�}	|�
||	�||jkr�|�
|j|j|�n|�
|jd�|	�	tj�}|�
||�qLq
dS)Nr<r�r)
r�r�rbr;�GAPr�rNrr�r�rc�FOLDr>)
r%r:r�rjrr�Zdt_typer�Zdt_actZdt_exprrr�test_tzstr_from_utc�s"(

�

zTZStrTest.test_tzstr_from_utcc
Cs�gd�}|D]p}|j|d��Pt�|�}|�t|��|�|�Wd�n1sT0YWd�q1sr0YqdS)N)ZPST8PDT�+11zGMT,M3.2.0/2,M11.1.0/3zGMT0+11,M3.2.0/2,M11.1.0/3zPST8PDT,M3.2.0/2zSTD+25zSTD-25zSTD+374zSTD+374DST,M3.2.0/2,M11.1.0/3zSTD+23DST+25,M3.2.0/2,M11.1.0/3zSTD-23DST-25,M3.2.0/2,M11.1.0/3zAAA4BBB,M1443339,M11.1.0/3zAAA4BBB,M3.2.0/2,0349309483959czAAA4BBB,M13.1.1/2,M1.1.1/2zAAA4BBB,M1.1.1/2,M13.1.1/2zAAA4BBB,M0.1.1/2,M1.1.1/2zAAA4BBB,M1.1.1/2,M0.1.1/2zAAA4BBB,M1.6.1/2,M1.1.1/2zAAA4BBB,M1.1.1/2,M1.6.1/2zAAA4BBB,M1.1.7/2,M2.1.1/2zAAA4BBB,M1.1.1/2,M2.1.7/2zAAA4BBB,-1/2,20/2zAAA4BBB,1/2,-1/2zAAA4BBB,367,20/2zAAA4BBB,1/2,367/2zAAA4BBB,J0/2,J20/2zAAA4BBB,J20/2,J366/2r<)rb�re�escapeZassertRaisesRegexr�r;)r%Zinvalid_tzstrsZ
invalid_tzstrZtzstr_regexrrr�test_invalid_tzstr�s%
zTZStrTest.test_invalid_tzstrcs��fdd�}|j�|j�|j�i�|����fdd��}|����fdd��}|����fdd��}|���fdd��}|��fdd��}|��fd	d��}|��fd
d��}|����fdd��}|����fdd��}|����fd
d��}�|_dS)Ncs&t��}|�t��|ks"Jd��dS)z�Decorator to call the addition methods.

            This will call a function which adds at least one new entry into
            the `cases` dictionary. The decorator will also assert that
            something was added to the dictionary.
            z!Function did not add a test case!N)r)rmZprev_len)r�rr�callsz,TZStrTest._populate_test_cases.<locals>.callcs�d}tdtdd�t�}tdtdd�t�}tddd	�|�ftddd
dd�|�ftddd
dd
d
d�|�ftddd
dd
dd�|�ftddd
ddd
d�|�ftddd
dddd�|�ftddd�|�ftddddddd�|�ftddddd
d
d�|�ftddddd
dd�|�ftddddd�|�ftddddd
d
d�|�ftddddd
dd�|�ftddddddd�|�ftddddd
d
d�|�ftddddd
dd�|�ff�|<dS)Nz EST5EDT,M3.2.0/4:00,M11.1.0/3:00�EST���r�EDT���r�r�r�r�rr�r�r>r	r�r�r�r�r�rr�r�r)r:rFrH�r?r>�NORMALr�rr�_add+s(�z,TZStrTest._populate_test_cases.<locals>._addcs(d}tdtt�}tdtt�}tddd�|�ftddddd	�|�ftdddd
d�|�ftddd�|�ftddd
dd	dd�|�ftddd
dddd�|�ftddd
d
ddd�|�ftddddd	�|�ftdddd
d�|�ftddddd	dd�|�ftddddddd�|�ftdddd
ddd�|�ff�|<dS)Nz"GMT0BST-1,M3.5.0/1:00,M10.5.0/2:00r��BSTr�r��r�rrr�r���r	rJr����r�r�r�r)r:r�rOrLrrrNGs �csjd}tdtdd�t�}tdtdd�t�}tddd	�|�ftddd
dd�|�ftddd
dddd
�|�ftddd
dddd
�|�ftddd
dddd
�|�ftddd
dddd
�|�ftddd
dddd
�|�ftddd
dddd
�|�ftddd
dddd
�|�ftdddd�|�ftddd	dd�|�ftddd	dddd
�|�ftddd	dddd
�|�ftddd	dd�|�ff�|<dS)NzAEST-10AEDT,M10.1.0/2,M4.1.0/3�AESTr�r�AEDTr�r�r�r�r�r	rrJr�rr��rK)r:rVrWrLrrrN_s$�csBd}tdtt�}tdtt�}tddd�|�ftddddd	�|�ftdddd
d�|�ftddd�|�ftddd
dd	dd�|�ftddd
dddd�|�ftddd
dddd�|�ftddd
d
ddd�|�ftddddd	�|�ftdddd
d�|�ftddddd	dd�|�ftddddddd�|�ftdddd
ddd�|�ff
�|<dS)NzIST-1GMT0,M10.5.0,M3.5.0/1r��ISTr�r�rPr�rrr�r�rQrRr	rJr�rSrTrU)r:r�rY)r?rMr�rrrNxs"�cs,d}tddd�tdtdd���ff�|<dS)Nz<+11>-11r�r	rAr�r)rr�rr<�rMr�rrrN�s
��csRd}tdtdd��}tdtdd�t�}tddd	�|�ftdd
d	�|�ff�|<dS)Nz<-04>4<-03>,M9.1.6/24,M4.1.6/24�-04rIr�-03���r�rXr	r��r�rr�r)r:ZM04ZM03rZrrrN�s�cs�d}tdtdd�t�}tddd�|�ftddd�|�ftddd	d
ddd�|�ftd
dd�|�ftd
dd�|�ftd
dd�|�ftd
dd	d
ddd�|�ftddd�|�ftddd�|�ftddd	d
ddd�|�ff
�|<dS)NzEST5EDT,0/0,J365/25rHrIrr�r	r�r�r�r�rrr�r�i`	r^)r:rHrZrrrN�s�cs�d}tdtdd��}tdtdd�t�}tddd�|�ftdd	d
�|�ftddddd
�|�ftdddddd�|�ftdddddd�|�ftdddd�|�ftddddd
�|�ftdddddd�|�ftdddddd�|�ftdddd�|�ftddddd
d
d�|�ftddd�|�ftdd	d�|�ftddddd
�|�ftdddddd�|�ftdddddd�|�ftdddd�|�ftddddd
�|�ftdddddd�|�ftdddddd�|�ftdddd�|�ftddddd
d
d�|�ff�|<dS)NzAAA3BBB,J60/12,J305/12�AAAr]r�BBB���r�r	r��r�r�rr�rrJ�
r�r�r�rr�rSr^�r:r_r`rLrrrN�s4�cs�d}tdtdd��}tdtdd�t�}tddd	�|�ftddd
ddd�|�ftddd
d
dd�|�ftddd
d
dd�|�ftddd
d�|�ftdddd�|�ftdddd
dd�|�ftdddd
dd�|�ftdddd�|�ff	�|<dS)Nz <-03>3<-02>,M3.5.0/-2,M10.5.0/-1r\r]rz-02rar�r�rRrb�r�rrJr	r�r��r^)r:�N03ZN02rLrrrN�s�cs�d}tdtdd��}tdtdd�t�}tddd	d
d�|�ftddd	d
ddd
�|�ftddd	d
dd
d
�|�ftddd	dd�|�ftdd	dd
ddd�|�ftdd	dd
dddd
�|�ftdd	dd
ddd
d
�|�ftdd	dddd�|�ff�|<dS)Nz%AAA3BBB,M3.2.0/01:30,M11.1.0/02:15:45r_r]rr`ra��r�r�r	rrPrJr�r�r��,r�-r^rdrLrrrN�s�)rMr?r>r�)rFrErNrrLrr3
s4
 zTZStrTest._populate_test_cases)r6r7r8r�r~rMr?r>rIr�r4r;r=r@rDr3r;rrr4rr2�s

.r2c@seZdZeZdS)�
CTZStrTestNr�rrrrrl
srlcspeZdZeZ�fdd�Zedd��Zedd��Zdd�Z	d	d
�Z
dd�Zd
d�Zdd�Z
dd�Zdd�Z�ZS)�ZoneInfoCacheTestcs|j��t���dSr )rSrTr0r1r$r4rrr1s
zZoneInfoCacheTest.setUpcCstSr rUr$rrrrVszZoneInfoCacheTest.zoneinfo_datacCs
|jjgSr rWr$rrrr&szZoneInfoCacheTest.tzpathcCs|�|�d�|�d��dS)N�America/Los_Angeles)r�rSr$rrr�test_ephemeral_zones s�z&ZoneInfoCacheTest.test_ephemeral_zonescCs$|�d�}|�d�}|�||�dS)N�Australia/Sydney)rSr��r%Ztz0Ztz1rrr�test_strong_refs%s

z"ZoneInfoCacheTest.test_strong_refscCs&|�d�}|j�d�}|�||�dS)N�
Europe/Lisbon)rSrwr�rqrrr�
test_no_cache+s
zZoneInfoCacheTest.test_no_cachecCsN|�d�}|�g��|�d�}Wd�n1s40Y|�||�dS)z�Test that the cache persists when tzpath has been changed.

        The PEP specifies that as long as a reference exists to one zone
        with a given key, the primary constructor must continue to return
        the same object.
        rnN)rSr,r�)r%Zzi0Zzi1rrr�test_cache_reset_tzpath2s
(z)ZoneInfoCacheTest.test_cache_reset_tzpathcCs2|�d�}|jjdd�|�d�}|�||�dS)Nrn�Z	only_keys)rSrTr�)r%�la0�la1rrr�test_clear_cache_explicit_none?s

z0ZoneInfoCacheTest.test_clear_cache_explicit_nonecCsT|�d�}|�d�}|jjdgd�|�d�}|�d�}|�||�|�||�dS)z5Tests that you can clear a single key from the cache.rn�
Europe/DublinrvN�rSrTr�r�)r%rw�dub0rx�dub1rrr�test_clear_cache_one_keyFs



z*ZoneInfoCacheTest.test_clear_cache_one_keycCsv|�d�}|�d�}|�d�}|jjddgd�|�d�}|�d�}|�d�}|�||�|�||�|�||�dS)Nrnrz�
Asia/Tokyorvr{)r%rwr|Ztok0rxr}Ztok1rrr�test_clear_cache_two_keysSs


�


z+ZoneInfoCacheTest.test_clear_cache_two_keys)r6r7r8r�r~r1r:rVr&rorrrtruryr~r�r;rrr4rrms



rmc@seZdZeZdS)�CZoneInfoCacheTestNr�rrrrr�esr�cs`eZdZeZ�fdd�Zedd��Zedd��Zdd�Z	d	d
�Z
dd�Zd
d�Zdd�Z
�ZS)�ZoneInfoPickleTestcsb|j��t���2}|�t�|j��|�|�	�j
�Wd�n1sJ0Yt���dSr )
rSrTr)r*r+�test_supportZset_zoneinfo_moduler~r-r.r/r0r1r2r4rrr1ls


.zZoneInfoPickleTest.setUpcCstSr rUr$rrrrVusz ZoneInfoPickleTest.zoneinfo_datacCs
|jjgSr rWr$rrrr&yszZoneInfoPickleTest.tzpathc
Cs�ttjd�D]�}|j|d���|�d�}tj||d�}t�|�}|jdd��|�||�Wd�n1sp0Yt�|�}|jdd��|�||�Wd�n1s�0YWd�q1s�0YqdS)Nr	��protorz�ZprotocolzIs non-pickled ZoneInfo��testzIs unpickled ZoneInfo)r��pickle�HIGHEST_PROTOCOLrbrS�dumps�loadsr��r%r�Zzi_in�pkl�zi_rt�zi_rt2rrr�test_cache_hit}s

*
z!ZoneInfoPickleTest.test_cache_hitc	Cs�ttjd�D]t}|j|d��T|�d�}tj||d�}~|j��t�|�}t�|�}|�||�Wd�q1sx0YqdS)Nr	r�rzr�)	r�r�r�rbrSr�rTr�r�r�rrr�test_cache_miss�s



z"ZoneInfoPickleTest.test_cache_missc
Cs(ttjd�D�]}|j|d���|j�d�}tj||d�}t�|�}|jdd��|�||�Wd�n1st0Yt�|�}|jdd��|�||�Wd�n1s�0Y|�d�}|jdd��|�||�Wd�n1s�0YWd�q1�s0YqdS)	Nr	r�rzr�zNot the pickled objectr�zNot a second unpickled objectzNot a cached object)	r�r�r�rbrSrwr�r�r�)r%r�Zzi_no_cacher�r�r�Zzi_cacherrrrt�s
*
*
z ZoneInfoPickleTest.test_no_cachec	Cs�d}t|j�|�d��6}|j�|�}|�d�|jj||d�}Wd�n1sR0Y|df|dfg}|D]�\}}ttjd�D]l}|j	||d��J|�
tj��tj||d	�Wd�n1s�0YWd�q�1s�0Yq�qpdS)
Nrzr_rrqzZoneInfo with keyzZoneInfo without keyr	)r`r�r�)
rgrVrfrSrhr'r�r�r�rbrx�
PicklingErrorr�)	r%rOrmZzi_nokeyZzi_keyr�rjr`r�rrr�test_from_file�s
.�z!ZoneInfoPickleTest.test_from_filec
Cs@ttjd�D�]*}|j|d���d}|�|�}tj||d�}t�|�}|�||�t|j	�
|�d�� }|jj||d�}Wd�n1s�0Ytj||d�}t�|�}	|�||	�|�tj
��tj||d�Wd�n1s�0Ytj||d�}
t�|
�}|�||�Wd�q1�s00YqdS)Nr	r�rzr�r_rq)r�r�r�rbrSr�r�r�rgrVrfrhrxr�)r%r�rOrjZpkl_0Zzi_rt_0rmrnZpkl_1Zzi_rt_1Zpkl_2Zzi_rt_2rrr�test_pickle_after_from_file�s"

.
,
z.ZoneInfoPickleTest.test_pickle_after_from_file)r6r7r8r�r~r1r:rVr&r�r�rtr�r�r;rrr4rr�is	


r�c@seZdZeZdS)�CZoneInfoPickleTestNr�rrrrr��sr�c@s0eZdZdZeZedd��Zdd�Zdd�Z	dS)	�CallingConventionTestz8Tests for functions with restricted calling conventions.cCstSr rUr$rrrrV�sz#CallingConventionTest.zoneinfo_datac	Csnt|j�d�d��H}|�t��|jj|d�Wd�n1sB0YWd�n1s`0YdS)Nr�r_)r�)rgrVrfrxr�rSrh)r%rmrrrr��sz$CallingConventionTest.test_from_filecCs<|�t��|j�dg�Wd�n1s.0YdS�Nr�)rxr�rSrTr$rrr�test_clear_cache�sz&CallingConventionTest.test_clear_cacheN)
r6r7r8r9r�r~r:rVr�r�rrrrr��s
r�c@seZdZeZdS)�CCallingConventionTestNr�rrrrr��sr�c@sReZdZeZeejdd���Zdd�Z	dd�Z
dd�Zd	d
�Zdd�Z
d
d�ZdS)�
TzPathTestc	cs�d}zbt�.tj�|d�}|tj|<dVWd�n1s>0YW|dur\tj|=q�|tj|<n|durztj|=n
|tj|<0dS)NZPYTHONTZPATH)r�os�environ�get)�value�path_varZold_envrrr�python_tzpath_context�s
&
�
z TzPathTest.python_tzpath_contextc
Cs�dgfddgfdtj�d�ddgfg}|D]|\}}|�|��Z|j|d��.|j��|jj}|�||�Wd�n1s~0YWd�q*1s�0Yq*dS)z<Tests that the environment variable works with reset_tzpath.r�z
/etc/zoneinfo�/a/b/cz/d/e/f�r&N)r��pathsepr�rbr~�reset_tzpath�TZPATH�assertSequenceEqual)r%Z	new_pathsZnew_path_varZexpected_resultr&rrr�test_env_variables�
zTzPathTest.test_env_variablecCsddgddgddgddgddgddgg}|D]�\}}tj�|�}|�|���|jd	|d
��H|�|jj��|j��Wd�n1s�0YWd�n1s�0Y|jj	}|jd|d
��|�
||�Wd�n1s�0YWd�q,1�s
0Yq,dS)N��path/to/somewherer��/usr/share/zoneinfor�)r���../relative/path�r�r��r�r��r�r�r�Zwarning)r�Zfiltered)r�r��joinr�rbZassertWarnsr~ZInvalidTZPathWarningr�r�r�)r%r��input_pathsZexpected_pathsr�r&rrr� test_env_variable_relative_pathss,����Fz+TzPathTest.test_env_variable_relative_pathscCs$|jjdgd�|�|jjd�dS)Nr���to)r�)r~r�r�r�r$rrr�test_reset_tzpath_kwarg;sz"TzPathTest.test_reset_tzpath_kwargc
Cszgd�}|D]h}|j|d��H|�t��|jj|d�Wd�n1sL0YWd�q1sj0YqdS)N)r�r�r�r�r�r�)r�r�)rbrxr�r~r�)r%r�r�rrr� test_reset_tzpath_relative_paths@s
z+TzPathTest.test_reset_tzpath_relative_pathsc
Csxgd�}|D]f}|j|d��F|�t��|j�|�Wd�n1sJ0YWd�q1sh0YqdS)N)z!/etc/zoneinfo:/usr/share/zoneinfos!/etc/zoneinfo:/usr/share/zoneinfor)r�)rbrxr�r~r�)r%r�Z	bad_valuerrr�test_tzpath_type_errorNs
z!TzPathTest.test_tzpath_type_errorcCs�ddg}dg}|�|��|jj}Wd�n1s60Y|�|��|jj}Wd�n1sh0Y|�||�|�||�dS)Nz/onez/twoz/three)r,r~r�r�)r%Ztzpath_0Ztzpath_1Zquery_0Zquery_1rrr�test_tzpath_attributeZs&&z TzPathTest.test_tzpath_attributeN)r6r7r8r�r~�staticmethodr)�contextmanagerr�r�r�r�r�r�r�rrrrr��s
$r�c@seZdZeZdS)�CTzPathTestNr�rrrrr�hsr�c@sheZdZeZedd��Zedd��Zdd�Z	dd�Z
d	d
�Zdd�Zd
d�Z
dd�Zdd�Zdd�ZdS)�
TestModulecCstSr rUr$rrrrVoszTestModule.zoneinfo_datacCsB|j�d�}t|d��}|��Wd�S1s40YdS)Nr�r_)rVrfrg�read)r%Z	zone_filermrrr�
_UTC_bytessszTestModule._UTC_bytescCs�tj�|�st|�d���|�dd�^}}|rFtjtj�||�dd�tj�||�}t|d��}|�|j	�Wd�n1s�0YdS)z�Creates a valid TZif file at key under the zoneinfo root tz_root.

        tz_root must exist, but all folders below that will be created.
        z does not exist.�/r	T)�exist_ok�wbN)
r�ra�exists�FileNotFoundError�rsplit�makedirsr�rgr$r�)r%rO�tz_rootZroot_dir�tailZ
zonefile_pathrmrrr�
touch_zoneyszTestModule.touch_zonecCs6|�t��|jjWd�n1s(0YdSr )rxryr~ZNOATTRIBUTEr$rrr�test_getattr_error�szTestModule.test_getattr_errorcCs0t|jj�}tt|j��}||}|�|�dS)z?dir(self.module) should at least contain everything in __all__.N)�setr~�__all__�dir�assertFalse)r%Zmodule_all_setZmodule_dir_set�
differencerrr�test_dir_contains_all�sz TestModule.test_dir_contains_allcCs"t|j�}t|�}|�||�dS)z5Test that there are no duplicates in dir(self.module)N)r�r~r�ZassertCountEqual)r%Z
module_dirZ
module_uniquerrr�test_dir_unique�s
zTestModule.test_dir_uniquecCsl|�|jjg��H|�|jj�|j��}t|jj�}||@}|�||�Wd�n1s^0YdSr )	r,rVr&�
assertTruerer~�available_timezonesr�rc)r%�available_keysZ
zoneinfo_keys�unionrrr�test_available_timezones�s
z#TestModule.test_available_timezonesc	Cszt���^}|�d|�|�|g��&|j��}|�d|�Wd�n1sN0YWd�n1sl0YdS)NzMars/Olympus_Mons)r�TemporaryDirectoryr�r,r~r�ZassertIn)r%�tdr�rrr�"test_available_timezones_weirdzone�s


z-TestModule.test_available_timezones_weirdzonecCs.hd�}t|�}dd�|D�}dd�|D�}d|fd||fd||fd|||fg}t����}|D]�\}}tj�||�}	t�|	�|D]}
|�|
|	�q�|�|	g��P|�	|��&|j
��}|�||�Wd�n1s�0YWd�qf1s�0YqfWd�n1�s 0YdS)	N>rprr��America/Santiagor�zAmerica/Indiana/IndianapoliszEurope/ParisrncSsg|]}d|���qS)zposix/r��.0rrrr�
<listcomp>�r�z5TestModule.test_folder_exclusions.<locals>.<listcomp>cSsg|]}d|���qS)zright/rr�rrrr��r��	base_treeZbase_and_posixZbase_and_rightZ	all_trees)
�listrr�r�rar��mkdirr�r,rbr~r�rc)r%r|r�Z
posix_treeZ
right_treer�r�Z	case_name�treer�rO�actualrrr�test_folder_exclusions�s&

�


z!TestModule.test_folder_exclusionsc	Cs�ddh}t|�dg}t���h}|D]}|�||�q$|�|g��&|j��}|�||�Wd�n1sn0YWd�n1s�0YdS)NzAmerica/New_Yorkr�Z
posixrules)r�rr�r�r,r~r�rc)r%r|r�r�rOr�rrr�test_exclude_posixrules�s�

z"TestModule.test_exclude_posixrulesN)r6r7r8r�r~r:rVrr�r�r�r�r�r�r�r�r�rrrrr�ls

		$r�c@seZdZeZdS)�CTestModuleNr�rrrrr��sr�c@s eZdZdZdd�Zdd�ZdS)�ExtensionBuiltTesta�Smoke test to ensure that the C and Python extensions are both tested.

    Because the intention is for the Python and C versions of ZoneInfo to
    behave identically, these tests necessarily rely on implementation details,
    so the tests may need to be adjusted if the implementations change. Do not
    rely on these tests as an indication of stable properties of these classes.
    cCs(|�ttjd��|�ttjd��dS)NZ_weak_cache)r��hasattrr�rRr�r�r$rrr�test_cache_location�sz&ExtensionBuiltTest.test_cache_locationcCs0ddl}|�|�tj��|�|�tj��dSr�)�gcr�Z
is_trackedr�rRr�r�)r%r�rrr�test_gc_tracked�sz"ExtensionBuiltTest.test_gc_trackedN)r6r7r8r9r�r�rrrrr��sr�)�frozenc@s*eZdZUded<ded<eZded<dS)r�rdr�rr�r�N)r6r7r8�__annotations__r�r�rrrrr�s
r�c@sneZdZUded<ded<ded<edd��Zedd	��Zed
d��Zedd
��Zedd��Z	edd��Z
dS)r�rrKr�r�r�cCs|j|jjjtjd�S)Nr�)rKr�r�rNrr�r$rrrr�s�zZoneTransition.transition_utccCs|jj|jjkS)zWhether this introduces a fold�r�r�r�r$rrrr>szZoneTransition.foldcCs|jj|jjkS)zWhether this introduces a gapr�r$rrrr�szZoneTransition.gapcCs|jj|jjSr )r�r�r�r$rrr�delta szZoneTransition.deltacCs|jr|j|jS|jSdSr �r>rKr�r$rrrr�$szZoneTransition.anomaly_startcCs|js|j|jS|jSdSr r�r$rrrr�+szZoneTransition.anomaly_endN)r6r7r8r�r:r�r>r�r�r�r�rrrrr�
s





r�c@s6eZdZd
dd�Zdd�Zdd�Zdd	�Zd
d�ZdS)rFcCs&t�|�|_g|_||_|�|�dSr )rrr&rer�_populate_tzpath)r%�source_jsonr&rrrr�__init__4szZoneInfoData.__init__cCs
|j|Sr r�rYrrrrf:szZoneInfoData.path_from_keyc
	Cs�t|d��}t�|�}Wd�n1s*0Y|d}|��D]�\}}|j�|�|�|�}|jrt|�|�}n|}|�	|�}	|	j
jddd�t|	d��}|�|�Wd�qD1s�0YqDdS)Nr_rT)r��parentsr�)
rg�json�loadr�rer��_decode_textr�_convert_to_v1rf�parentr�r$)
r%r�rmZ
zoneinfo_dictrVrOr��raw_datarZdestinationrrrr�=s(

zZoneInfoData._populate_tzpathcCs&d�ttj|��}t�|�}t�|�S)Nr�)r�rrdr"�base64Z	b85decoder�
decompress)r%�contentsr�Zdecodedrrrr�Qs
zZoneInfoData._decode_textc
Cs�|dd�dksJd��t|dd��}d}|d}|dksDJd	��t�d
|||��\}}}}}	}
|d|	d|
|d||}||7}d
|d|�}|||d�dks�Jd��|S)Nrr�rzInvalid TZif data found!rX�rgr�z-Version 1 file found: no conversion necessaryrr�rsTZifz0Version 2 file not truncated at Version 2 header)rr%Zunpack)
r%r�r(Zheader_startZ
header_endr*r+r,r/r.r0�	file_sizer8rrrr�Ws6���������zZoneInfoData._convert_to_v1N)F)r6r7r8r�rfr�r�r�rrrrr3s

rc@s\eZdZedd��Zedd��Zedd��Zedd��Zed	d
��Zedd��Z	d
Z
d
Zd
S)r[cCs|����Sr )�
_get_zonedumprer5rrrr\uszZoneDumpData.transition_keyscCs|��|Sr )r)rFrOrrrrLysz%ZoneDumpData.load_transition_examplescCs|js|��|j��Sr )�_FIXED_OFFSET_ZONES�_populate_fixed_offsetsr�r5rrrr^}szZoneDumpData.fixed_offset_zonescCs|js|��|jSr )�_ZONEDUMP_DATA�_populate_zonedump_datar5rrrr�szZoneDumpData._get_zonedumpcCsdtdtt�i|_dSr�)r�r�rr5rrrr�s�z$ZoneDumpData._populate_fixed_offsetscCs�dd�}dd�}dd�}dd�}d	d
�}dd�}d
d�}dd�}dd�}	dd�}
|�|�|�|�|�|�|�|�|	�|
�d�
|_dS)NcSs0tdtdd��}tdt�}ttddd�||�gS)Nr�r�r�r�r�r	�r�rr�r�r)r�r�rrr�_Africa_Abidjan�s
�z=ZoneDumpData._populate_zonedump_data.<locals>._Africa_AbidjancSs�tdtt�}tdtt�}tdtt�}tdtt�}ttdddd�||�ttdddd�||�ttdd	d
d�||�ttdddd�||�ttd
ddd�||�ttd
d	dd�||�gS)Nz+00z+01i�r�rTr�rXrcr��r�rbr�r�)r�r�r�r�r)ZP00_sZP01_dZP00_dZP01_srrr�_Africa_Casablanca�s�z@ZoneDumpData._populate_zonedump_data.<locals>._Africa_CasablancacSs>tdtdd�t�}tdtdd�t�}tdtdd�t�}td	tdd�t�}td
tdd�t�}ttddd
ddd�||�ttdddd�||�ttdddd�||�ttdddd�||�ttdddd�||�ttdddd�||�ttdddd�||�ttdddd�||�ttdddd�||�ttddd d�||�ttddd!d�||�gS)"Nr�i&���r��PSTi����r�PDTi�����PWT�PPTr�r�r�r�r�r�i~r�r�r�rRi�r�i�rr�rrPi�r	i�	rcr��r�rr�r�r�r)r�r	r
rrrrr�_America_Los_Angeles�s"�zBZoneDumpData._populate_zonedump_data.<locals>._America_Los_AngelescSs�tdtdd�t�}tdtdd�t�}tdtdd�t�}tdtdd�t�}td	td
d�t�}ttddd�||�ttd
dd�||�ttddd�||�ttddd�||�ttddd�||�ttddd�||�ttddd�||�gS)Nr�i����r��SMTz-05i����r[i���r\i���ibr	ivr��|r�i�r�rPr�r�r�rr�r�r
)r�rZN05ZN04rhrrr�_America_Santiago�s�z?ZoneDumpData._populate_zonedump_data.<locals>._America_SantiagocSsbtdtdd�t�}tdtdd�t�}ttddd�||�ttdd	d
d�||�ttdd	d	d�||�gS)
N�JSTi�~r��JDT頌i�rXr�r�r�r	i�r
)rrrrr�_Asia_Tokyo�s�z9ZoneDumpData._populate_zonedump_data.<locals>._Asia_TokyocSs�tdtdd�t�}tdtdd�t�}tdtdd�t�}ttdd	d
�||�ttdd
d
dd
�||�ttdd
dd	�||�ttddd
d
�||�ttdddd	�||�ttddd
d
�||�ttdddd	�||�gS)Nr�ičr�rVrrWi��igr�r	�}rr�rTrir�r�r�r�r
)r�rVrWrrr�_Australia_Sydney�s�z?ZoneDumpData._populate_zonedump_data.<locals>._Australia_Sydneyc
Sstdtdd�t�}tdtdd�t�}tdtdd�t�}tdtt�}td	tt�}tdtt�}tdtt�}ttd
ddd
�||�ttdddd�||�ttdddd�||�ttdddd�||�ttdddd�||�ttdddd�||�ttdddd�||�ttdddd�||�gS)Nr�i$���r��DMTi���rYir�rOiXrr�rrrXrer�r	r�rr�i�rRrPi�	rQr
)r�rZIST_0ZGMT_0rOZGMT_1ZIST_1rrr�_Europe_Dublin�s �z<ZoneDumpData._populate_zonedump_data.<locals>._Europe_DublincSs�tdtt�}tdtt�}tdtt�}tdtdd�t�}ttddd	d
�||�ttdddd
�||�ttdddd
�||�ttdddd�||�ttdddd
�||�ttdddd
�||�gS)N�WET�WEST�CET�CESTi r�i�r�rSr	r�rRr�i�rbrQr�r�r�)r�r�r�rr�r)rrrrrrr�_Europe_Lisbons�z<ZoneDumpData._populate_zonedump_data.<locals>._Europe_Lisbonc
Ss�tdtdd�t�}tdtt�}tdtt�}ttddd�||�ttd	d
dd�||�ttd	dd
d�||�ttdd
dd�||�ttdddd�||�gS)Nr�i����r�r�rOi7r�r	i�r�rRr�rPr�i�rSrTr
)r�r�rOrrr�_Europe_Londons�z<ZoneDumpData._populate_zonedump_data.<locals>._Europe_LondoncSs�tdtdd�t�}tdtdd�t�}tdtdd�t�}tdtd	d�t�}ttd
dd�||�ttdd
d�||�ttddd�||�gS)Nr�i�l��r�z-1040ij��z-10i`s��z+14i��imr	i�r�i�r�r�r)r�ZN1040ZN10ZP14rrr�_Pacific_Kiritimati!s�zAZoneDumpData._populate_zonedump_data.<locals>._Pacific_Kiritimati)
r�zAfrica/Casablancarnr�rprrzrsr�zPacific/Kiritimati)r)rFrrrrrrrrrr rrrr�s*

�z$ZoneDumpData._populate_zonedump_dataN)r6r7r8rIr\rLr^rrrrrrrrrr[ts





,r[)UZ
__future__rr�r)rM�importlib.metadata�	importlibr�r�r�rr�rBr!r%rZunittestrrrrr�	functoolsrr�r
r�rrr
Ztest.supportrrZget_modulesr�r��metadataZHAS_TZDATA_PKGZPackageNotFoundErrorrrrr�__file__r�ZDATA_DIRrr�r�rr"r#r<rQr�r�r�r�r�r�r�ZskipIfr�r�r�r1r2rlrmr�r�r�r�r�r�r�r�r�ZTestCaser�Z	dataclassr�r�rr[rrrr�<module>s�


 6��fTrr{

(A