U
    j                     @   s  d Z ddlZddlZzddlmZ W n$ ek
rH   G dd deZY nX ddlmZmZm	Z	m
Z
 ddlZddlmZmZmZmZmZmZmZmZmZmZmZmZ dd	 Zd
d Zdd Zdd Zdd Zdd Zdd Zdd Z dd Z!dd Z"dd Z#dd Z$ej%&d eed!d"d#d$d"ed!d"d#d$d$feed!d"d#ed!d$d%fee
d&d"d#e
d'd$d%feed!d"d#d$d"e
d&d"d#fed!d"d#d$d"e
d'd$d%ffeed!d"d#d$d#e
d&d"d#fed!d"d#d$d"e
d&d"d#ffeed!d"d#d$d#ed!d"d#d$d&fed!d"d#d$d#ed!d"d#d$d(ffee	d$d$d$e	d$d$d"fgej%&d)d*d+gej%&d,dd#gej%&d-dd#gej%&d.d/d0 e'gd1d2 Z(d3d4 Z)eg eed!d"d#d$d#geed!d"d#d$d#ed!d"d#ggZ*ej%&d5e*ej%&d6e*d7d8 Z+dS )9z/Test the equality and inequality of components.    N)UnknownTimeZoneErrorc                   @   s   e Zd ZdS )r   N)__name__
__module____qualname__ r   r   A/tmp/pip-unpacked-wheel-g40nyxg1/icalendar/tests/test_equality.pyr   
   s   r   )datedatetimetime	timedelta)vBinaryvBoolean	vCategoryvDate	vDatetime	vDDDLists	vDDDTypes	vDurationvGeovPeriodvTextvTimec                 C   s   | |kst || kst dS )zMake sure both values are equalNAssertionErrorZactual_valueZexpected_valuer   r   r   assert_equal"   s    r   c                 C   s   | |kst || kst dS )z#Make sure both values are not equalNr   r   r   r   r   assert_not_equal(   s    r   c                 C   s   | j |  }t||  dS )zbEnsure that a calendar equals the same calendar.

    ics -> calendar -> ics -> same calendar
    N)	__class__	from_icalZto_icalr   )ics_filetzpZcopy_of_calendarr   r   r   /test_parsed_calendars_are_equal_if_parsed_again.   s    r!   c                 C   s*   | j | j}| j | j}t|| dS )zcEnsure that a calendar equals the same calendar.

    ics -> calendar
    ics -> same calendar
    N)r   r   Zraw_icsr   )r   r    Zcal1Zcal2r   r   r   3test_parsed_calendars_are_equal_if_from_same_source7   s    r"   c                 C   sJ   |   }| j|_|   }| jdd |_t|| t||  t||  dS )zEnsure that copies are equal.N)copysubcomponentsr   )r   r    Zcopy1copy2r   r   r   test_copies_are_equalB   s    

r&   c                 C   s    | j jst| j  jrtdS )zGIf we copy the subcomponents, assumptions around copies will be broken.N)Z	timezonedr$   r   r#   )Z	calendarsr    r   r   r   %test_copy_does_not_copy_subcomponentsM   s    r'   c              	   C   sr   | j dkr| rtd tt tt	| t	|  W 5 Q R X tt tt	| |  W 5 Q R X dS )zEnsure that deep copies are equal.

    Ignore errors when a custom time zone is used.
    This is still covered by the parsing test.
    z+issue_722_timezone_transition_ambiguity.icszThis test fails for now.N)
Zsource_fileZuses_zoneinfopytestskip
contextlibsuppressr   r   r#   deepcopy)r   r    r   r   r   test_deep_copies_are_equalS   s    
 r-   c                   C   s:   t tdtd ttdtd ttdtd dS )zCheck the equality of vGeo.)10012.33)z100.00z12.330)r.   z12.331)10r/   N)r   r   r   r   r   r   r   	test_vGeod   s    r1   c                   C   s(   t tdtd ttdtd d S )NasdZasdf)r   r   r   r   r   r   r   test_vBinaryk   s    r3   c                   C   sF   t tdtd t tdtd ttdtd d S )NTRUEFALSE)r   r   r   r   r   r   r   r   test_vBooleanp   s    r6   c                   C   sL   t tdtd t tddgtddg ttddgtdddg d S )NHELLOabc)r   r   r   r   r   r   r   test_vCategoryv   s    r;   c                   C   s(   t tdtd ttdtd d S )Nr7   ZHELLO1)r   r   r   r   r   r   r   
test_vText|   s    r<   )vTypev1v2i        
               eq==z!=cls1cls2hashc                 C   s   | S )Nr   )xr   r   r   <lambda>       rM   c           	      C   s   | t f| }| t f| }|dkrn||||ks4t||||||ksPt||||||kstn0||||kst||||||kstdS )zCheck equality and inequality.rH   N)r   r   )	r=   r>   r?   rI   rJ   rG   rK   t1t2r   r   r   test_vDDDTypes_and_others   s    rQ   c                   C   s    dt ttdddkstd S )Nr   rD   r@   rA   )reprr   r   r   r   r   r   r   test_repr_vDDDTypes   s    rS   l1l2c                 C   s6   | |k}t |}|| |kks"t|| |kks2tdS )z*Check the equality functions of vDDDLists.N)r#   r,   r   )rT   rU   equalr   r   r   test_vDDDLists   s    
rW   ),__doc__r*   r#   Zpytzr   ImportError	Exceptionr	   r   r
   r   r(   Zicalendar.propr   r   r   r   r   r   r   r   r   r   r   r   r   r   r!   r"   r&   r'   r-   r1   r3   r6   r;   r<   markZparametrizerK   rQ   rS   ZvDDDLists_examplesrW   r   r   r   r   <module>   sl   8	 