HEX
Server: Apache
System: Linux zacp120.webway.host 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
User: govancoz (1003)
PHP: 8.3.26
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: //usr/local/lib/python3.10/test/test_zoneinfo/__pycache__/test_zoneinfo.cpython-310.pyc
o

�i%�@s�ddlmZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlZddlZddlmZmZmZmZmZddlmZddlmZddlmZmZmZddlmZed	�Z e�!�\Z"Z#z
ej$�$d
�dZ%Wn
ej$j&y�dZ%Ynwda'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�tempfile�mkdtemp�TEMP_DIR�ZoneInfoData�
ZONEINFO_JSON�
ZONEINFO_DATA�ZONEINFO_DATA_V1�rr�=/usr/local/lib/python3.10/test/test_zoneinfo/test_zoneinfo.py�setUpModule,sr cCst�t�dS�N)�shutil�rmtreerrrrr�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�tzpathD�zTzPathUserMixin.tzpathcC�dS)NTrr&rrr�block_tzdataHr)zTzPathUserMixin.block_tzdatacs`t���}|�|j|j|jtd��|�|��j	�Wd�n1s$wYt
���dS)N)r+�lock)�
contextlib�	ExitStack�
enter_context�tzpath_contextr(r+r�
addCleanup�pop_all�close�super�setUp�r'�stack��	__class__rrr5Ls
���
zTzPathUserMixin.setUp)	�__name__�
__module__�__qualname__�__doc__�propertyr(r+r5�
__classcell__rrr8rr%: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�microsecondrArB)�cls�dtrrr�
from_datetime`s�z4DatetimeSubclassMixin.DatetimeSubclass.from_datetimeN)r:r;r<�classmethodrLrrrr�DatetimeSubclass_srNc#sB�t��|�}|D]}|j}|j�|�}tj||d�}|Vq	dS)N)�
transition)r4�load_transition_examplesrOrNrL�dataclasses�replace)r'�keyZtransition_examples�ztrKZnew_dtZnew_ztr8rrrPns��z.DatetimeSubclassMixin.load_transition_examples)r:r;r<r=rrNrPr?rrr8rr@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!)r4r5�klass�clear_cacher&r8rrr5{s
zZoneInfoTest.setUpcC�tSr!�rr&rrr�
zoneinfo_data�r)zZoneInfoTest.zoneinfo_datacC�
|jjgSr!�r[r(r&rrrr(��
zZoneInfoTest.tzpathcCs
|�|�Sr!�rW�r'rSrrr�
zone_from_key��
zZoneInfoTest.zone_from_keycC�t��Sr!)�ZoneDumpData�transition_keysr&rrr�zones��zZoneInfoTest.zonescCrcr!)rd�fixed_offset_zonesr&rrrrh�rgzZoneInfoTest.fixed_offset_zonescCs
t�|�Sr!)rdrPr`rrrrP�rbz%ZoneInfoTest.load_transition_examplesc	Cs�|��D]$}|�|��|�|�}|�t|�|�Wd�n1s#wYq|jjd}|j�|�}t|d��8}|jd|d��|j	�
|�}|�t|�t|��Wd�n1s]wYWd�dSWd�dS1suwYdS)Nr�rbz	Repr test)�	test_name�path)rf�subTestra�assertEqual�strr[�keys�
path_from_key�openrW�	from_file�repr)r'rS�zi�file_key�	file_path�f�zi_ffrrr�test_str�s 
����"�zZoneInfoTest.test_strc	Csbtt|����}|�|�}|j}|jdd��|�t|�|�Wd�n1s)wY|jj	d}|j�
|�}t|d��}|jj||d�}Wd�n1sRwY|jdd��|�t|�|�Wd�n1spwYt|d��}|j�|�}Wd�n1s�wY|jdd��|�t|�|�Wd�dS1s�wYdS)Nzfrom key)�namerri�rSzfrom file with keyzfrom file without key)
�next�iterrfrW�
class_namerlZassertRegexrsr[rorprqrr)	r'rSrtr~rurvrwrxZzi_ff_nkrrr�	test_repr�s(
����"�zZoneInfoTest.test_reprc
s�tt�����}�fdd�}d�j|fd�jj|fd|dff}|D]U\}}}||�}��|����|j|�Wd�n1sAwY��|�d��� ��t	��d|_Wd�n1sbwYWd�n1sqwYq!dS)NcsBt�j�|�d��}�j�|�Wd�S1swYdS)Nri)rqr[rprWrr)rSrwr&rr�from_file_nokey�s
$�z8ZoneInfoTest.test_key_attribute.<locals>.from_file_nokeyzPrimary constructor�no_cacherrz
: readonlyz
Some/Value)
r|r}rfrWr�rlrmrS�assertRaises�AttributeError)r'rSr�Zconstructors�msg�constructor�expectedrtrr&r�test_key_attribute�s&
�������zZoneInfoTest.test_key_attributec	CsNgd�}|D]}|�|jj��
|�|�Wd�n1swYqdS)N)zEurasia/BadzoneZBZQzAmerica.Los_Angelesu🇨🇦uAmerica/New�York)r��moduleZZoneInfoNotFoundErrorrW�r'Zbad_keysZbad_keyrrr�
test_bad_keys�s���zZoneInfoTest.test_bad_keysc	CsJgd�}|D]}|�t��
|�|�Wd�n1swYqdS)N)z/America/Los_AngeleszAmerica/Los_Angeles/z../zoneinfo/America/Los_AngeleszAmerica/../America/Los_AngeleszAmerica/./Los_Angeles)r��
ValueErrorrWr�rrr�test_bad_keys_paths�s���z ZoneInfoTest.test_bad_keys_pathsc	CsVddg}|D]"}t�|�}|�t��|j�|�Wd�n1s#wYqdS)N�sAAAA3               )�io�BytesIOr�r�rWrr)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]4\}}|j|d��"|�|��
|�
|�Wd�n1sTwYWd�n1scwYq4dS)N��r	�rArz
2019-01-01)�val)r|r}rfrarr�utcr�r�	TypeErrorrrlr��fromutc)r'rS�zone�
bad_valuesr��exc_typerrr�test_fromutc_errors�s$

�	�����z ZoneInfoTest.test_fromutc_errorscCsN|�d�}tddd|d�}|�|��t�|�|��t�|�|��d�dS)N�UTC��r	r�)rWrrm�	utcoffset�ZERO�dst�tzname)r'rtrKrrr�test_utcs

zZoneInfoTest.test_utcc	Cs�g}|��D](}|�|�D] }|�||jtdd�|jf�|�||jtdd�|jf�q
q|D]F\}}}|j|||d��1|�|�}|j	|d�}|�
|��|j|�|�
|��|j|�|�
|�
�|j
|�Wd�n1srwYq1dS)N�)Zdays)rSrK�offsetr�)rfrP�appendrOr�
offset_before�offset_afterrlrarRrmr�r�r�)r'�
test_casesrSZzone_transitionrKr��tzirrr�test_unambiguouss4�����
���zZoneInfoTest.test_unambiguousc	CsDg}|��D]�}ggd�}|�|�D]�}|jr|d}n|jr$|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]P\\}}}|j||d��:|�|�}	|D]*\}}
}|j
|
|	d�}|�|��|j|�|�|��|j|�|�|��|j|�q�Wd�n	1�swYq�dS)	N)�folds�gapsr�r�r	��secondsr)rS�grp�rBrA)rfrPrB�gap�
anomaly_startrr�r�r��anomaly_end�itemsrlrarRrmr�r�r�)r'r�rSZtestsrTZ
test_groupZno_peephole_optrKr�r�rBr�rrr�test_folds_and_gaps4sV


�
����z ZoneInfoTest.test_folds_and_gapsc		Cs�|��D]X}|�|�}|j|d��C|�|�D]5}|jsq|j}|tdd�}|tdd�}|�|�}|�|jd||f�|�|�}|�|jd||f�qWd�n1sWwYqdS)Nr{r	r�r)	rfrarlrPrB�transition_utcr�
astimezonerm)	r'rSrtrT�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�n1s=wYqdS�N��r	i��r�r{)rfrarrl�assertIsr�r�r�)r'rSrt�trrr�test_time_variable_offset}s
���z&ZoneInfoTest.test_time_variable_offsetc	Cs�|��D]C\}}|�|�}tdddd|d�}|j|d��#|�|��|j�|�|��|j�|�|��|j�Wd�n1sBwYqdSr�)rhrarrlrmr�r�r�)r'rSr�rtr�rrr�test_time_fixed_offset�s
���z#ZoneInfoTest.test_time_fixed_offset)r:r;r<�py_zoneinfor�r~r5r>r[r(rarfrhrPryrr�r�r�r�r�r�r�r�r�r�r�r?rrr8rrUws2



7rUc@seZdZeZdd�ZdS)�
CZoneInfoTestc		Cs�dd�}ddg}d}|�|�}|�|�D]}|jr(|jjtkr(|jj|d�}nqdD]4}|r4||�}n|}|j|d��|�	|�}|�
|jd	�|�
|jd
�Wd�n1sZwYq+dS)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)rr4�__add__)r'�otherr8rrr��szTCZoneInfoTest.test_fold_mutate.<locals>.to_subclass.<locals>.SameAddSubclass.__add__)r:r;r<r�r?rrr8r�SameAddSubclass�sr�r�)
�typerCrDrErFrGrHrIrBrA)rKr�rrr�to_subclass�s�z3CZoneInfoTest.test_fold_mutate.<locals>.to_subclassFT�
Europe/Londonr�)FT)�subclassr	rN)rarPrBr�r�r�r�rRrlr�rm)	r'r�r�rSrtrTZexamplerKZ
dt_fromutcrrr�test_fold_mutate�s(	
�

���zCZoneInfoTest.test_fold_mutateN)r:r;r<�
c_zoneinfor�r�rrrrr��sr�c@�eZdZdS)�ZoneInfoDatetimeSubclassTestN�r:r;r<rrrrr���r�c@r�)�CZoneInfoDatetimeSubclassTestNr�rrrrr��r�r�cs(eZdZe�fdd��Zdd�Z�ZS)�ZoneInfoSubclassTestcs4t���Gdd�d|j�}d|_|j|_||_dS)Nc@r�)z3ZoneInfoSubclassTest.setUpClass.<locals>.ZISubclassNr�rrrr�
ZISubclass�r�r�)r4�
setUpClassrWr~�parent_klass)rJr�r8rrr��s


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


z,ZoneInfoSubclassTest.test_subclass_own_cache)r:r;r<rMr�r�r?rrr8rr��s
r�c@�eZdZeZdS)�CZoneInfoSubclassTestN�r:r;r<r�r�rrrrr���r�c@s eZdZedd��Zdd�ZdS)�ZoneInfoV1TestcCrYr!)rr&rrrr[�r)zZoneInfoV1Test.zoneinfo_dataccs\�tddd�}tdd�}||}||}t�|�D]}||jkr&|kr+nq|VqdS)N�r	�r�)rrrdrPrO)r'rSZepochZ
max_offset_32Zmin_dtZmax_dtrTrrrrP�s�
��z'ZoneInfoV1Test.load_transition_examplesN)r:r;r<r>r[rPrrrrr��s
r�c@r�)�CZoneInfoV1TestNr�rrrrr��r�r�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(
r)zTZDataTests.tzpathcCr*)NFrr&rrrr+r)zTZDataTests.block_tzdatacCs|j|d�S)Nr{r_r`rrrraszTZDataTests.zone_from_keyN)r:r;r<r=r>r(r+rarrrrr�s

r�c@r�)�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]6\}	}
|jd|	d��#|�|	�	�|
j	�|�|	�
�|
j
�|�|	��|
j�Wd�n1sywYqHtddd	d|d
�tddd	dddtj
d
�ftdddd|d
�tddddtj
d
�fg}|D]2\}}
|jd|d��|
�|�}|�||�|�tj
�}|�||
�Wd�n1s�wYq�dS)N�LMT��r�)rZminutesr��STDr�[�	�ZSTD6r	r��
�local)rzrK������r�)�
ZoneOffsetr�ZoneTransitionr�construct_zonerWrrrlrmr�r�r�rr�r�)r'r�r��transitions�after�zfrtZdt0Zdt1rKr��dtsZdt_localr�Z	dt_actualZ
dt_utc_actualrrr�test_one_transition#s@������
���z!WeirdZoneTest.test_one_transitionc	Cs�tdtt�}ttddd�||�g}d}|�||�}|j�|�}tddd�tddd	�tddd�td
dd�tddd�g}|D]9}|j|d
�}|j|d��#|�	|�
�|j
�|�	|��|j�|�	|��|j�Wd�n1spwYq<dS)N�DSTr�r	zSTD0DST-1,0/0,J365/25�l�i�r�r�r�r��r��rK)
r��ONE_Hr�rr�rWrrrRrlrmr�r�r�)r'r�r�r�r�rtr�rKrrr�test_one_zone_dstLs*�




����zWeirdZoneTest.test_one_zone_dstc	Cs�tdtt�}tddtt�}g}tdd�D]}|�tt|ddd�||��|�tt|ddd�||��qd	}|�||�}|j�	|�}td
dd�|ftddd�|ftddd�|ftddd�|fg}|D];\}	}
|	j
|d
�}	|j|	d��#|�|	�
�|
j
�|�|	��|
j�|�|	��|
j�Wd�n1s�wYqbtd|d
�}|�d��!|�|�
�d�|�|��d�|�|��d�Wd�dS1s�wYdS)Nr�r�r�����r�r	r��i�r�i�r�r�rzTesting datetime.time)r�r�r��ranger�r�rr�rWrrrRrlrmr�r�r�rr�)r'r�r�r�rCr�r�rt�casesrKr�r�rrr�test_no_tz_strfs@�����"�zWeirdZoneTest.test_no_tz_strc	
Cs�tdtt�tdtt�g}|D]e}td||�g}d}|�||�}|j�|�}tddd�tddd�tddd�g}|D]:}|j|d�}|j	||d	��#|�
|��|j�|�
|��|j�|�
|�
�|j
�Wd�n1smwYq8qdS)
Nr�r�rr�r	r�rr�)r�rK)r�r�r�r�r�rWrrrrRrlrmr�r�r�)	r'�offsetsr�r�r�r�rtr�rKrrr�test_tz_before_only�s.

�
�


�����z!WeirdZoneTest.test_tz_before_onlycCsH|�gd�}|�t��|j�|�Wd�dS1swYdS)Nr)r�r�r�rWrr)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��#|�|
�
�|	j
�|�|
��|	j�|�|
��|	j�Wd�n1s�wYqJtjtjtdd�ftdd
dddd�tddd�ftdd
ddddd�tddddddd�ftdddddd�tdddddd�ftd dd�td dd�ftj	tj	fg}|D] \}}
|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/Abidjanr{iwr�r�r�r�r�)rzrKr�Ni�ij��+�4ik�;�?Br�r��r�)r�rr�r�rr�rWrr�min�maxrRrlrmr�r�r�rr�r�)r'r�r
r�r�r�rtZoffset_cases�dt_naiver�rKZ	utc_casesZnaive_dtZnaive_dt_utcr�rrr�test_zone_very_large_timestamp�sJ
�����"
��z,WeirdZoneTest.test_zone_very_large_timestampcCs$tdtt�}ttddd�||�g}d}|�||�}|jj|dd�}tddd|d�}|�d��#|�|�	�|j	�|�|�
�|j
�|�|��|j�Wd�n1sTwYtd	|d�}|�d
��$|�|�	�|j	�|�|�
�|j
�|�|��|j�Wd�dS1s�wYdS)Nr�r�r	ZUTC0r{r�r�zdatetime.datetimerz
datetime.time)
r�r�r�rr�rWrrrlrmr�r�r�r)r'r�r�r�r�rtrKr�rrr�$test_fixed_offset_phantom_transition�s"�"�z2WeirdZoneTest.test_fixed_offset_phantom_transitionNr�c(Csg}g}g}ggg}ggg}ggg}	d}
d}|
|g}dd�}
tt|
|�dd�d�}|D]Q}|\}}}t|�D]E\}\}}||}||}|	|}|durX||krV|ksXnq6||vra|�|�||vrj|�|�|dur{|�|�|�|�|��q6q+t|�}t|�}t|�}t��}d}tt	|d	f��D]�}||}||}|	|}||}t
�}g}|D]$} t| j�
��}!t| j�}"t|�}#|�|!|"|#f�|| j�d
�d7}q�t|�}t|�}$t|�}%t|�}&|�d�|�d
|�|�d�|�t�d||||%|$|&��|�tjd|%�|��g|�R��|�tjd|%�d�g|�R��|D]}'|�tjdg|'�R���q'|�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|jrt|j���}nd}||j|jfSr!)�
isinstance�tuplerO�intr�Z	timestampr�r�)rT�
trans_timerrr�zt_as_tuples
z1WeirdZoneTest.construct_zone.<locals>.zt_as_tuplecSs|dSr�r)�xrrr�<lambda>+sz.WeirdZoneTest.construct_zone.<locals>.<lambda>r{)�l�qr��ascii��TZifs%d�               �>6l�>�Bz>lbb�br r�
)�sorted�map�	enumerater��index�lenr�r�rr�	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_rangeZrangesrrTrr�r��vZdt_minZdt_maxrZtrans_timesZ	trans_idx�isutcnt�isstdcnt�leapcnt�zonefileZ
time_typesZ	time_typeZabbrstrZttinfosr�ZutcoffZisdstZabbrind�typecnt�timecnt�charcntZttinforrrr�
s�



��


��"  


�
zWeirdZoneTest.construct_zone)Nr�)
r:r;r<r�r�r�r�rrrrrr�rrrrr� s)+$=r�c@r�)�CWeirdZoneTestNr�rrrrrA�r�rAcsheZdZeZdZdZdZe�fdd��Z	edd��Z
dd	�Zd
d�Zdd
�Z
dd�Zedd��Z�ZS)�	TZStrTestrr	r�cst���|��|��dSr!)r4r��_populate_test_cases�populate_tzstr_header�rJr8rrr��s
zTZStrTest.setUpClasscCsTt�}td�D]}|d7}|d7}|d7}|t�ddddddd�7}qt|�|_dS)Nr�r$�3r%r&r)r0rr5r6r3�_tzif_header)rJ�out�_rrrrD�szTZStrTest.populate_tzstr_headercCsVt�|j�}|�dd�|�d�|�|�d��|�d�|�d�|jj||d�S)z/Creates a zoneinfo file following a POSIX rule.rr�r*r"r{)r�r�rGr7r4r2rWrr)r'�tzstrr=rrr�zone_from_tzstr�s


zTZStrTest.zone_from_tzstrc
Cs�|j��D]`\}}|j|d��
|�|�}Wd�n1swY|D]>\}}}|j|d�}|j|||d��#|�|��|j�|�|��|j�|�|��|j�Wd�n1s_wYq&qdS)N�rJr�)rJrKr�)	r�r�rlrKrRrmr�r�r�)r'rJrrtrr�rIrKrrr�test_tzstr_localized�s�����zTZStrTest.test_tzstr_localizedc
	Cs�|j��D]j\}}|j|d��
|�|�}Wd�n1swY|D]H\}}}||jkr1q&||jjtjd�}|�	|�}|j|d�}	|�
||	�||jkr[|�
|j|j|�n|�
|jd�|	�	tj�}|�
||�q&qdS)NrLr�r)
r�r�rlrK�GAPr�rRrr�r�rm�FOLDrB)
r'rJrrtrr�Zdt_typer�Zdt_actZdt_exprrr�test_tzstr_from_utc�s(�

�

��zTZStrTest.test_tzstr_from_utcc
Cs�gd�}|D]8}|j|d��(t�|�}|�t|��
|�|�Wd�n1s*wYWd�n1s9wYqdS)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/2rL)rl�re�escapeZassertRaisesRegexr�rK)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��|ksJd��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/)rwZprev_len)rrr�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�rBr	r�r�r�r�r�rr�r�r)rJrVrX�rOrN�NORMALrrr�_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	rZr����r�r�r�r)rJr
r_r\rrr^Gs �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	rrZr�rr��r[)rJrfrgr\rrr^_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�r`r�rrr�r�rarbr	rZr�rcrdre)rJr
ri)rOr]rrrr^xs"�cs,d}tddd�tdtdd���ff�|<dS)Nz<+11>-11r�r	rQr�r)rr�rrL�r]rrrr^�s
��csRd}tdtdd��}tdtdd�t�}tddd	�|�ftdd
d	�|�ff�|<dS)Nz<-04>4<-03>,M9.1.6/24,M4.1.6/24�-04rYr�-03���r�rhr	r��r�rr�r)rJZM04ZM03rjrrr^�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/25rXrYrr�r	r�r�r�r
rrr�r�i`	rn)rJrXrjrrr^�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�AAArmr�BBB���r�r	r��r�r�rr�rrZ�
r�r�r
rr�rcrn�rJrorpr\rrr^�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/-1rlrmrz-02rqr�r�rbrr�r�rrZr	r
r��rn)rJ�N03ZN02r\rrr^�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:45rormrrprq��r�r�r	rr`rZr�r�r��,r�-rnrtr\rrr^�s�)r]rOrNr�)rJrUr^rr\rrC
s4
 
zTZStrTest._populate_test_cases)r:r;r<r�r�r]rOrNrMr�rDrKrMrPrTrCr?rrr8rrB�s

.rBc@r�)�
CTZStrTestNr�rrrrr|
r�r|cspeZdZeZ�fdd�Zedd��Zedd��Zdd�Z	d	d
�Z
dd�Zd
d�Zdd�Z
dd�Zdd�Z�ZS)�ZoneInfoCacheTestcs|j��t���dSr!)rWrXr4r5r&r8rrr5s
zZoneInfoCacheTest.setUpcCrYr!rZr&rrrr[r)zZoneInfoCacheTest.zoneinfo_datacCr\r!r]r&rrrr(r^zZoneInfoCacheTest.tzpathcCs|�|�d�|�d��dS)N�America/Los_Angeles)r�rWr&rrr�test_ephemeral_zones s�z&ZoneInfoCacheTest.test_ephemeral_zonescCs$|�d�}|�d�}|�||�dS)N�Australia/Sydney)rWr��r'Ztz0Ztz1rrr�test_strong_refs%s

z"ZoneInfoCacheTest.test_strong_refscCs&|�d�}|j�d�}|�||�dS)N�
Europe/Lisbon)rWr�r�r�rrr�
test_no_cache+s
zZoneInfoCacheTest.test_no_cachecCsN|�d�}|�g��
|�d�}Wd�n1swY|�||�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.
        r~N)rWr0r�)r'Zzi0Zzi1rrr�test_cache_reset_tzpath2s

�z)ZoneInfoCacheTest.test_cache_reset_tzpathcCs2|�d�}|jjdd�|�d�}|�||�dS)Nr~�Z	only_keys)rWrXr�)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.r~�
Europe/Dublinr�N�rWrXr�r�)r'r��dub0r��dub1rrr�test_clear_cache_one_keyFs



z*ZoneInfoCacheTest.test_clear_cache_one_keycCsv|�d�}|�d�}|�d�}|jjddgd�|�d�}|�d�}|�d�}|�||�|�||�|�||�dS)Nr~r��
Asia/Tokyor�r�)r'r�r�Ztok0r�r�Ztok1rrr�test_clear_cache_two_keysSs


�


z+ZoneInfoCacheTest.test_clear_cache_two_keys)r:r;r<r�r�r5r>r[r(rr�r�r�r�r�r�r?rrr8rr}s



r}c@r�)�CZoneInfoCacheTestNr�rrrrr�er�r�cs`eZdZeZ�fdd�Zedd��Zedd��Zdd�Z	d	d
�Z
dd�Zd
d�Zdd�Z
�ZS)�ZoneInfoPickleTestcsb|j��t���}|�t�|j��|�|�	�j
�Wd�n1s%wYt���dSr!)
rWrXr-r.r/�test_supportZset_zoneinfo_moduler�r1r2r3r4r5r6r8rrr5ls

�zZoneInfoPickleTest.setUpcCrYr!rZr&rrrr[ur)z ZoneInfoPickleTest.zoneinfo_datacCr\r!r]r&rrrr(yr^zZoneInfoPickleTest.tzpathc
Cs�ttjd�D]f}|j|d��V|�d�}tj||d�}t�|�}|jdd��|�||�Wd�n1s8wYt�|�}|jdd��|�||�Wd�n1sYwYWd�n1shwYqdS)Nr	��protor���protocolzIs non-pickled ZoneInfo��testzIs unpickled ZoneInfo)r�pickle�HIGHEST_PROTOCOLrlrW�dumps�loadsr��r'r�Zzi_in�pkl�zi_rt�zi_rt2rrr�test_cache_hit}s 

�
�����z!ZoneInfoPickleTest.test_cache_hitc	Cs�ttjd�D]:}|j|d��*|�d�}tj||d�}~|j��t�|�}t�|�}|�||�Wd�n1s<wYqdS)Nr	r�r�r�)	rr�r�rlrWr�rXr�r�r�rrr�test_cache_miss�s



���z"ZoneInfoPickleTest.test_cache_missc
Cs$ttjd�D]�}|j|d��x|j�d�}tj||d�}t�|�}|jdd��|�||�Wd�n1s9wYt�|�}|jdd��|�||�Wd�n1sZwY|�d�}|jdd��|�||�Wd�n1s{wYWd�n1s�wYqdS)	Nr	r�r�r�zNot the pickled objectr�zNot a second unpickled objectzNot a cached object)	rr�r�rlrWr�r�r�r�)r'r�Zzi_no_cacher�r�r�Zzi_cacherrrr��s(
�
�
�����z ZoneInfoPickleTest.test_no_cachec	Cs�d}t|j�|�d��}|j�|�}|�d�|jj||d�}Wd�n1s)wY|df|dfg}|D]B\}}ttjd�D]6}|j	||d��%|�
tj��tj||d	�Wd�n1sewYWd�n1stwYqCq8dS)
Nr�rirr{zZoneInfo with keyzZoneInfo without keyr	)rjr�r�)
rqr[rprWrrr7rr�r�rlr��
PicklingErrorr�)	r'rSrwZzi_nokeyZzi_keyr�rtrjr�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�n1sEwYtj||d�}t�|�}	|�||	�|�tj
��tj||d�Wd�n1stwYtj||d�}
t�|
�}|�||�Wd�n1s�wYqdS)Nr	r�r�r�rir{)rr�r�rlrWr�r�r�rqr[rprrr�r�)r'r�rSrtZpkl_0Zzi_rt_0rwrxZpkl_1Zzi_rt_1Zpkl_2Zzi_rt_2rrr�test_pickle_after_from_file�s,

�
�
���z.ZoneInfoPickleTest.test_pickle_after_from_file)r:r;r<r�r�r5r>r[r(r�r�r�r�r�r?rrr8rr�is	


r�c@r�)�CZoneInfoPickleTestNr�rrrrr��r�r�c@s0eZdZdZeZedd��Zdd�Zdd�Z	dS)	�CallingConventionTestz8Tests for functions with restricted calling conventions.cCrYr!rZr&rrrr[�r)z#CallingConventionTest.zoneinfo_datac	Cs�t|j�d�d��-}|�t��|jj|d�Wd�n1s!wYWd�dSWd�dS1s9wYdS)Nr�ri)r�)rqr[rpr�r�rWrr)r'rwrrrr��s��"�z$CallingConventionTest.test_from_filecCs>|�t��|j�dg�Wd�dS1swYdS�Nr�)r�r�rWrXr&rrr�test_clear_cache�s"�z&CallingConventionTest.test_clear_cacheN)
r:r;r<r=r�r�r>r[r�r�rrrrr��s
r�c@r�)�CCallingConventionTestNr�rrrrr��r�r�c@sReZdZeZeejdd���Zdd�Z	dd�Z
dd�Zd	d
�Zdd�Z
d
d�ZdS)�
TzPathTestc	cs��d}t�}|}z9t�tj�|d�}|tj|<dVWd�n1s%wYW||ur1dS|dur;tj|=dS|tj|<dS||urH	w|durQtj|=w|tj|<w)NZPYTHONTZPATH)�objectr�os�environ�get)�value�path_varZunset_env_sentinelZold_envrrr�python_tzpath_context�s,�
����z TzPathTest.python_tzpath_contextc
Cs�dgfddgfdtj�d�ddgfg}|D]>\}}|�|��-|j|d��|j��|jj}|�||�Wd�n1s?wYWd�n1sNwYqdS)z<Tests that the environment variable works with reset_tzpath.rz
/etc/zoneinfo�/a/b/cz/d/e/f�r(N)r��pathsepr�rlr��reset_tzpath�TZPATH�assertSequenceEqual)r'Z	new_pathsZnew_path_varZexpected_resultr(rrr�test_env_variables�
�����zTzPathTest.test_env_variablecCsddgddgddgddgddgddgg}|D]s\}}tj�|�}|�|��\|jd	|d
��$|�|jj��
|j��Wd�n1sEwYWd�n1sTwY|jj	}|jd|d
��|�
||�Wd�n1suwYWd�n1s�wYqdS)N��path/to/somewherer��/usr/share/zoneinfor�)r���../relative/path�r�r��r�r��r�r�r��warning)r�Zfiltered)r�r��joinr�rlZassertWarnsr�ZInvalidTZPathWarningr�r�r�)r'r��input_pathsZexpected_pathsr�r(rrr� test_env_variable_relative_pathss<������������z+TzPathTest.test_env_variable_relative_pathscCs$|jjdgd�|�|jjd�dS)Nr���to)r�)r�r�r�r�r&rrr�test_reset_tzpath_kwargBsz"TzPathTest.test_reset_tzpath_kwargc
Cszgd�}|D]4}|j|d��$|�t��|jj|d�Wd�n1s&wYWd�n1s5wYqdS)N)r�r�r�r�r�r�)r�r�)rlr�r�r�r�)r'r�r�rrr� test_reset_tzpath_relative_pathsGs�����z+TzPathTest.test_reset_tzpath_relative_pathsc
Csxgd�}|D]3}|j|d��#|�t��|j�|�Wd�n1s%wYWd�n1s4wYqdS)N)z!/etc/zoneinfo:/usr/share/zoneinfos!/etc/zoneinfo:/usr/share/zoneinfor)r�)rlr�r�r�r�)r'r�Z	bad_valuerrr�test_tzpath_type_errorUs�����z!TzPathTest.test_tzpath_type_errorcCs�ddg}dg}|�|��|jj}Wd�n1swY|�|��|jj}Wd�n1s4wY|�||�|�||�dS)Nz/onez/twoz/three)r0r�r�r�)r'Ztzpath_0Ztzpath_1Zquery_0Zquery_1rrr�test_tzpath_attributeas
�
�z TzPathTest.test_tzpath_attributeN)r:r;r<r�r��staticmethodr-�contextmanagerr�r�r�r�r�r�r�rrrrr��s$r�c@r�)�CTzPathTestNr�rrrrr�or�r�c@sheZdZeZedd��Zedd��Zdd�Z	dd�Z
d	d
�Zdd�Zd
d�Z
dd�Zdd�Zdd�ZdS)�
TestModulecCrYr!rZr&rrrr[vr)zTestModule.zoneinfo_datacCsB|j�d�}t|d��}|��Wd�S1swYdS)Nr�ri)r[rprq�read)r'Z	zone_filerwrrr�
_UTC_byteszs$�zTestModule._UTC_bytescCs�tj�|�s
t|�d���|�dd�^}}|r#tjtj�||�dd�tj�||�}t|d��}|�|j	�Wd�dS1sAwYdS)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�rk�exists�FileNotFoundError�rsplit�makedirsr�rqr4r�)r'rS�tz_root�root_dir�tailZ
zonefile_pathrwrrr�
touch_zone�s"�zTestModule.touch_zonecCs8|�t��
|jjWd�dS1swYdSr!)r�r�r�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_uniquecCsn|�|jjg��%|�|jj�|j��}t|jj�}||@}|�||�Wd�dS1s0wYdSr!)	r0r[r(�
assertTrueror��available_timezonesr�rm)r'�available_keysZ
zoneinfo_keys�unionrrr�test_available_timezones�s
"�z#TestModule.test_available_timezonesc	Cs�t���8}|�d|�|�|g��|j��}|�d|�Wd�n1s'wYWd�dSWd�dS1s?wYdS)NzMars/Olympus_Mons)r�TemporaryDirectoryr�r0r�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]Q\}}tj�||�}	t�|	�|D]}
|�|
|	�qE|�|	g��(|�	|��|j
��}|�||�Wd�n1spwYWd�n1swYq3Wd�dS1s�wYdS)	N>r�r�zEurope/Parisr�zAmerica/Indiana/Indianapolis�America/Santiagor~r�cS�g|]}d|���qS)zposix/r��.0rrrr�
<listcomp>��z5TestModule.test_folder_exclusions.<locals>.<listcomp>cSr�)zright/rr�rrrr��r��	base_treeZbase_and_posixZbase_and_rightZ	all_trees)
�listrr�r�rkr��mkdirr�r0rlr�r�rm)r'r�r�Z
posix_treeZ
right_treerr�Z	case_name�treer�rS�actualrrr�test_folder_exclusions�s2

�


�����"�z!TestModule.test_folder_exclusionsc	Cs�ddh}t|�dg}t���=}|D]}|�||�q|�|g��|j��}|�||�Wd�n1s7wYWd�dSWd�dS1sOwYdS)NzAmerica/New_Yorkr�Z
posixrules)r�rr�r�r0r�r�rm)r'r�r�r�rSr�rrr�test_exclude_posixrules�s�

��"�z"TestModule.test_exclude_posixrulesN)r:r;r<r�r�r>r[rr�r�r�r�r�r�r�r�r�rrrrr�ss

		$r�c@r�)�CTestModuleNr�rrrrr��r�r�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�rVr�r�r&rrr�test_cache_location�sz&ExtensionBuiltTest.test_cache_locationcCs0ddl}|�|�tj��|�|�tj��dSr�)�gcr�Z
is_trackedr�rVr�r�)r'rrrr�test_gc_trackedsz"ExtensionBuiltTest.test_gc_trackedN)r:r;r<r=r�rrrrrr��sr�)�frozenc@s*eZdZUded<ded<eZded<dS)r�rnr�rr�r�N)r:r;r<�__annotations__r�r�rrrrr�
s
r�c@sneZdZUded<ded<ded<edd��Zedd	��Zed
d��Zedd
��Zedd��Z	edd��Z
dS)r�rrOr�r�r�cCs|j|jjjtjd�S)Nr�)rOr�r�rRrr�r&rrrr�s�zZoneTransition.transition_utccCs|jj|jjkS)zWhether this introduces a fold�r�r�r�r&rrrrB�zZoneTransition.foldcCs|jj|jjkS)zWhether this introduces a gaprr&rrrr�"rzZoneTransition.gapcCs|jj|jjSr!)r�r�r�r&rrr�delta'szZoneTransition.deltacCs|jr	|j|jS|jSr!�rBrOrr&rrrr�+�zZoneTransition.anomaly_startcCs|js	|j|jS|jSr!rr&rrrr�2rzZoneTransition.anomaly_endN)r:r;r<rr>r�rBr�rr�r�rrrrr�s 





r�c@s6eZdZd
dd�Zdd�Zdd�Zdd	�Zd
d�ZdS)rFcCs&t�|�|_g|_||_|�|�dSr!)rrr(ror�_populate_tzpath)r'�source_jsonr(rrrr�__init__;szZoneInfoData.__init__cCs
|j|Sr!r�r`rrrrpArbzZoneInfoData.path_from_keyc
	Cs�t|d��
}t�|�}Wd�n1swY|d}|��D]A\}}|j�|�|�|�}|jr:|�|�}n|}|�	|�}	|	j
jddd�t|	d��
}|�|�Wd�n1s^wYq"dS)NrirT)r��parentsr�)
rq�json�loadr�ror��_decode_textr�_convert_to_v1rp�parentr�r4)
r'r
rwZ
zoneinfo_dictr[rSr��raw_datarZdestinationrrrr	Ds"�

���zZoneInfoData._populate_tzpathcCs&d�ttj|��}t�|�}t�|�S)Nr�)r�r,rnr2�base64Z	b85decoder�
decompress)r'�contentsrZdecodedrrrrXs

zZoneInfoData._decode_textc
Cs�|dd�dksJd��t|dd��}d}|d}|dks"Jd	��t�d
|||��\}}}}}	}
|d|	d|
|d||}||7}d
|d|�}|||d�dks^Jd��|S)Nrr�r$zInvalid TZif data found!rh�rwr�z-Version 1 file found: no conversion necessaryr&r�rsTZifz0Version 2 file not truncated at Version 2 header)rr5�unpack)
r'rr8Zheader_startZ
header_endr:r;r<r?r>r@�	file_sizerHrrrr^s4��������zZoneInfoData._convert_to_v1N)F)r:r;r<rrpr	rrrrrrr:s
rc@s\eZdZedd��Zedd��Zedd��Zedd��Zed	d
��Zedd��Z	d
Z
d
Zd
S)rdcCs|����Sr!)�
_get_zonedumprorErrrre|�zZoneDumpData.transition_keyscCs|��|Sr!)r)rJrSrrrrP�rz%ZoneDumpData.load_transition_examplescCs|js|��|j��Sr!)�_FIXED_OFFSET_ZONES�_populate_fixed_offsetsr�rErrrrh�s
zZoneDumpData.fixed_offset_zonescCs|js|��|jSr!)�_ZONEDUMP_DATA�_populate_zonedump_datarErrrr�szZoneDumpData._get_zonedumpcCsdtdtt�i|_dSr�)r�r�rrErrrr�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
rr	�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�rdr�rhrsr��r�rrr�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�rbi�r�i�rr�rr`i�r	i�	rsr��r�rr�r�r�r)r�r#r$r%r&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����rki���rli���ibr	ivr��|r�i�r�r`r�r�r�rr�r�r')r�r)ZN05ZN04rxrrr�_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�rhr�r�r�r	i�r')r,r-rrr�_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�rfr.rgi��igr�r	�}rr�rdryr�r�r�r�r')r�rfrgrrr�_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���riir
r_iXrr�rr*rhrur�r	r�r0r�i�rbr`i�	rar')r�r2ZIST_0ZGMT_0r_ZGMT_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�rcr	r�rbr�i�rrrarr�r�)r�r�r�rr�r)r4r5r6r7rrr�_Europe_Lisbons�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
r_i7r�r	i�r�rbr�r`r�i�rcrdr')r�r
r_rrr�_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/Casablancar~r�r�r�r�r�r�zPacific/Kiritimati)r)rJr r"r(r+r/r1r3r8r9r:rrrr�s*

�z$ZoneDumpData._populate_zonedump_dataN)r:r;r<rMrerPrhrrrrrrrrrrd{s 





,rd)UZ
__future__rrr-rQ�importlib.metadata�	importlibr�r
r�rr�rRr"r5rZunittestrrrrr�	functoolsrrr
r�rrr
Ztest.support.import_helperrrZget_modulesr�r�ZmetadataZHAS_TZDATA_PKGZPackageNotFoundErrorrrrr�__file__rZDATA_DIRrr�r�r r$r%r@rUr�r�r�r�r�r�r�ZskipIfr�r�r�rArBr|r}r�r�r�r�r�r�r�r�r�ZTestCaser�Z	dataclassr�r�rrdrrrr�<module>s��

 6��fTry{

(A