o
    >h8                     @  s   d Z ddlmZ ddlmZ zddlmZ W n ey!   dZY nw eZddl	m	Z	m
Z
 ddlmZ ddlmZ dd	lmZmZ dddZdddZdddZG dd deZdS )z(
Tests for L{twisted.python._tzhelper}.
    )annotations)environ)tzsetN)datetime	timedelta)mktime)FixedOffsetTimeZone)SkipTestTestCaset92tuple[int, int, int, int, int, int, int, int, int]returnfloatc                 C  s(   zt | W S  ty   td| w )z
    Call L{mktime_real}, and if it raises L{OverflowError}, catch it and raise
    SkipTest instead.

    @param t9: A time as a 9-item tuple.
    @type t9: L{tuple}

    @return: A timestamp.
    @rtype: L{float}
    z(Platform cannot construct time zone for )mktime_realOverflowErrorr	   )r    r   /var/www/vedio/testing/chatpythonscript.ninositsolution.com/env/lib/python3.10/site-packages/twisted/python/test/test_tzhelper.pyr      s
   
r   name
str | NoneNonec                 C  sD   t du rdS | du rztd= W n ty   Y nw | td< t   dS )zR
    Set time zone.

    @param name: a time zone name
    @type name: L{str}
    NTZ)r   r   KeyError)r   r   r   r   setTZ0   s   

r   testCaser
   c                   s$   t dd | jd fdd}dS )z
    Add cleanup hooks to a test case to reset timezone to original value.

    @param testCase: the test case to add the cleanup to.
    @type testCase: L{unittest.TestCase}
    r   Nr   r   c                     s   t   d S )N)r   r   tzInr   r   resetTZM   s   zaddTZCleanup.<locals>.resetTZr   r   )r   get
addCleanup)r   r   r   r   r   addTZCleanupD   s   r    c                   @  s   e Zd ZdZdddZdS )FixedOffsetTimeZoneTestsz+
    Tests for L{FixedOffsetTimeZone}.
    r   r   c                   sZ   t du rtdd fd	d
}t  |ddd |ddd |ddd |ddd dS )z
        Test that timezone attributes respect the timezone as set by the
        standard C{TZ} environment variable and L{tzset} API.
        Nz:Platform cannot change timezone; unable to verify offsets.r   strexpectedOffsetDSTexpectedOffsetSTDr   r   c           
        s   t |  td}t|}td}t|}t|}t|} ||d|   ||d|   ||t	d  ||t	d dd	d
}	 |
||	|  |
||	| d S )N)	i        r   r   r            )	i  r)      r   r   r      r*   r   UTCr   offsetr"   r   r   c                 S  sf   t | dksJ | d }t| dd }t| dd }|dkr'| }| }n|dks-J t||dS )N   r   r)      -+)hoursminutes)lenintr   )r-   signr2   r3   r   r   r   timeDeltaFromOffsetr   s   zZFixedOffsetTimeZoneTests.test_tzinfo.<locals>.testForTimeZone.<locals>.timeDeltaFromOffset)r-   r"   r   r   )r   r   r   fromtimestampr   fromLocalTimeStampassertEqualtznamedstr   	utcoffset)
r   r#   r$   localDST
localDSTdtlocalSTD
localSTDdttzDSTtzSTDr7   selfr   r   testForTimeZone_   s$   




z=FixedOffsetTimeZoneTests.test_tzinfo.<locals>.testForTimeZonezUTC+00z+0000zEST+05EDT,M4.1.0,M10.5.0z-0400z-0500zCEST-01CEDT,M4.1.0,M10.5.0z+0200z+0100zCST+06z-0600)r   r"   r#   r"   r$   r"   r   r   )r   r	   r    )rE   rF   r   rD   r   test_tzinfoW   s   )z$FixedOffsetTimeZoneTests.test_tzinfoNr   )__name__
__module____qualname____doc__rG   r   r   r   r   r!   R   s    r!   )r   r   r   r   )r   r   r   r   )r   r
   r   r   )rK   
__future__r   osr   timer   _tzsetImportErrorr   r   r   r   twisted.python._tzhelperr   twisted.trial.unittestr	   r
   r   r    r!   r   r   r   r   <module>   s"   


