o
    OZh                    @   s   d dl Z d dlZd dlmZmZ d dlZd dlZd dlmZm	Z	 d dl
mZ de kZdZdZdd	 ZG d
d dejZG dd dejZedkrPe  dS dS )    N)
CollectionSequence)RectVector2)
test_utilsPyPyi   ic                   C   s   t ttS N)randomrandint_int_min_int_max r   r   E/var/www/auris/lib/python3.10/site-packages/pygame/tests/rect_test.py_random_int   s   r   c                   @   s  e Z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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d/d0 Zd1d2 Zd3d4 Zd5d6 Zd7d8 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+dSdT Z,dUdV Z-dWdX Z.dYdZ Z/d[d\ Z0d]d^ Z1d_d` Z2dadb Z3dcdd Z4dedf Z5dgdh Z6didj Z7dkdl Z8dmdn Z9dodp Z:dqdr Z;dsdt Z<dudv Z=dwdx Z>dydz Z?d{d| Z@d}d~ ZAdd ZBdd ZCdd ZDdd ZEdd ZFdd ZGdd ZHdd ZIdd ZJdd ZKdd ZLdd ZMdd ZNdd ZOdd ZPdd ZQdd ZRdd ZSdd ZTdd ZUdd ZVdd ZWdd ZXdd ZYdd ZZdd Z[dd Z\dd Z]dd Z^dd Z_dd Z`dd Zadd Zbdd ZcddĄ ZdddƄ ZeddȄ Zfddʄ Zgdd̄ Zhdd΄ ZiddЄ Zjdd҄ ZkddԄ Zlddք Zmdd؄ Znddڄ Zodd܄ Zpddބ Zqdd Zrdd Zsdd Ztdd Zudd Zvdd Zwdd Zxdd Zyez{e|ddd Z}dd Z~dd Zdd Zdd Zdd Zdd Zdd 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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d0d1 Zd2d3 Zd4d5 Zd6d7 Zd8d9 Zd:d; Zd<d= Zd>d? Zd@dA ZdBdC ZdDdE ZdFdG ZdHdI ZdJdK ZdLdM ZG dNdO dOZG dPdQ dQZG dRdS dSZG dTdU dUZdVdW ZdXdY ZdZd[ Zd\d] Zd^d_ Zd`da Zdbdc Zddde Zdfdg Zdhdi Zdjdk Zdldm Zdndo Zdpdq Zdrds Zdtdu Zdvdw ZdxS (y  RectTypeTestc                 O   s   | j |i | d S r   )assertCountEqual)selfargskwargsr   r   r   _assertCountEqual   s   zRectTypeTest._assertCountEqualc                 C   sJ   t dddd}| d|j | d|j | d|j | d|j d S N            r   assertEquallefttopwidthheightr   rr   r   r   testConstructionXYWidthHeight   s
   z*RectTypeTest.testConstructionXYWidthHeightc                 C   sF   t dd}| d|j | d|j | d|j | d|j d S )Nr   r   r   r   r   r   r   r   r   r!   r   r   r   testConstructionTopLeftSize    s
   
z(RectTypeTest.testConstructionTopLeftSizec                 C   sV  t dddd}| |j|j |j | |j|j |j | |j|jf|j | |j|jf|j	 | |j|jf|j
 | |j|jf|j | |j|jf|j |j|jd  }|j|jd  }| ||j | ||j | |j|jf|j | |j|jf|j | |j|jf|j | |j|jf|j | |j|jf|j d S r   )r   r   r   r   rightr   r    bottomsizetoplefttopright
bottomleftbottomrightcenterxcenterycentermidtop	midbottommidleftmidright)r   r"   ZmidxZmidyr   r   r   testCalculatedAttributes'   s"   z%RectTypeTest.testCalculatedAttributesc                 C   s<   t dddd}| }t|D ]\}}| || | qd S )N2   d         )r   __iter__	enumerater   )r   rectZrect_iteratorivalr   r   r   test_rect_iter=   s
   zRectTypeTest.test_rect_iterc                 C   sJ   t dd}|j|j |j|j f|j |j ff}|  | || dS )z@Ensures normalize works when width and height are both negative.r$   )Nr   xwyh	normalizer   r   	test_rectexpected_normalized_rectr   r   r   test_normalizeE   s   
zRectTypeTest.test_normalizec                 C   B   t dd}|j|j |jf|j |jff}|  | || dS )zDEnsures normalize works with a negative width and a positive height.r$   )r@      NrB   rH   r   r   r   test_normalize__positive_heightQ      
z,RectTypeTest.test_normalize__positive_heightc                 C   B   t dd}|j|j|j f|j|j ff}|  | || dS )zDEnsures normalize works with a positive width and a negative height.r$   )r   rA   Nr   rC   rE   rF   rD   rG   r   rH   r   r   r   test_normalize__positive_width]   rO   z+RectTypeTest.test_normalize__positive_widthc                 C   rL   )z@Ensures normalize works with a negative width and a zero height.r$   )r@   r   NrB   rH   r   r   r   test_normalize__zero_heighti   rO   z(RectTypeTest.test_normalize__zero_heightc                 C   rP   )z@Ensures normalize works with a zero width and a negative height.r$   )r   rA   NrQ   rH   r   r   r   test_normalize__zero_widthu   rO   z'RectTypeTest.test_normalize__zero_widthc                 C   s4   dD ]}t d|}t |}|  | || qdS )zEnsures normalize works when width and height are both non-negative.

        Tests combinations of positive and zero values for width and height.
        The normalize method has no impact when both width and height are
        non-negative.
        ))r   rM   )r   r   )r   rM   r   r   r$   N)r   rG   r   )r   r)   rI   rJ   r   r   r   test_normalize__non_negative   s   
z)RectTypeTest.test_normalize__non_negativec                 C   s^   d}d}d}t d|f|}||_| |j| | |j|j | |j| | |j| dS )zeEnsures changing the x attribute moves the rect and does not change
        the rect's size.
        
   r   r%   r   N)r   rC   r   r   rE   r)   r   Z
expected_xZ
expected_yZexpected_sizer"   r   r   r   test_x      zRectTypeTest.test_xc              	   C   Z   t dddd}dg ddg dfD ]}| t ||_W d   n1 s%w   Y  qdS )z9Ensures the x attribute handles invalid values correctly.r   r   N1r   r   r   r   )r   assertRaises	TypeErrorrC   r   r"   valuer   r   r   test_x__invalid_value      z"RectTypeTest.test_x__invalid_valuec                 C   B   t dddd}| t |`W d   dS 1 sw   Y  dS )z)Ensures the x attribute can't be deleted.r   r   N)r   r_   AttributeErrorrC   r!   r   r   r   test_x__del      "zRectTypeTest.test_x__delc                 C   s^   d}d}d}t |df|}||_| |j| | |j|j | |j| | |j| dS )zeEnsures changing the y attribute moves the rect and does not change
        the rect's size.
        r      r%   r   N)r   rE   r   r   rC   r)   rX   r   r   r   test_y   rZ   zRectTypeTest.test_yc              	   C   r[   )z9Ensures the y attribute handles invalid values correctly.r   r   Nr\   r]   r^   )r   r_   r`   rE   ra   r   r   r   test_y__invalid_value   rd   z"RectTypeTest.test_y__invalid_valuec                 C   re   )z)Ensures the y attribute can't be deleted.r   r   N)r   r_   rf   rE   r!   r   r   r   test_y__del   rh   zRectTypeTest.test_y__delc                 C   s@   t dddd}d}||_| ||j | t |ddd| dS )z`Changing the left attribute moves the rect and does not change
        the rect's width
        r   r   r   r   rW   N)r   r   r   )r   r"   Znew_leftr   r   r   	test_left   s
   zRectTypeTest.test_leftc              	   C   r[   )z<Ensures the left attribute handles invalid values correctly.r   r   Nr\   r]   r^   )r   r_   r`   r   ra   r   r   r   test_left__invalid_value   rd   z%RectTypeTest.test_left__invalid_valuec                 C   re   )z,Ensures the left attribute can't be deleted.r   r   N)r   r_   rf   r   r!   r   r   r   test_left__del   rh   zRectTypeTest.test_left__delc                 C   \   t dddd}|jd }|jd }|j}||_| ||j | ||j | ||j dS )zaChanging the right attribute moves the rect and does not change
        the rect's width
        r   r   r   r   ri   N)r   r'   r   r   r   )r   r"   Z	new_rightexpected_left	old_widthr   r   r   
test_right      

zRectTypeTest.test_rightc              	   C   r[   )z=Ensures the right attribute handles invalid values correctly.r   r   Nr\   r]   r^   )r   r_   r`   r'   ra   r   r   r   test_right__invalid_value   rd   z&RectTypeTest.test_right__invalid_valuec                 C   re   )z-Ensures the right attribute can't be deleted.r   r   N)r   r_   rf   r'   r!   r   r   r   test_right__del   rh   zRectTypeTest.test_right__delc                 C   s@   t dddd}d}||_| t d|dd| | ||j dS )z_Changing the top attribute moves the rect and does not change
        the rect's width
        r   r   r   r   rW   N)r   r   r   )r   r"   Znew_topr   r   r   test_top  s
   zRectTypeTest.test_topc              	   C   r[   )z;Ensures the top attribute handles invalid values correctly.r   r   Nr\   r]   r^   )r   r_   r`   r   ra   r   r   r   test_top__invalid_value  rd   z$RectTypeTest.test_top__invalid_valuec                 C   re   )z+Ensures the top attribute can't be deleted.r   r   N)r   r_   rf   r   r!   r   r   r   test_top__del  rh   zRectTypeTest.test_top__delc                 C   rp   )zcChanging the bottom attribute moves the rect and does not change
        the rect's height
        r   r   r   r   ri   N)r   r(   r   r    r   )r   r"   Z
new_bottomexpected_top
old_heightr   r   r   test_bottom  rt   zRectTypeTest.test_bottomc              	   C   r[   )z>Ensures the bottom attribute handles invalid values correctly.r   r   Nr\   r]   r^   )r   r_   r`   r(   ra   r   r   r   test_bottom__invalid_value-  rd   z'RectTypeTest.test_bottom__invalid_valuec                 C   re   )z.Ensures the bottom attribute can't be deleted.r   r   N)r   r_   rf   r(   r!   r   r   r   test_bottom__del5  rh   zRectTypeTest.test_bottom__delc                 C   rp   )zcChanging the centerx attribute moves the rect and does not change
        the rect's width
        r   r   r   r   ri   N)r   r.   r   r   r   )r   r"   Znew_centerxrq   rr   r   r   r   test_centerx<  rt   zRectTypeTest.test_centerxc              	   C   r[   )z?Ensures the centerx attribute handles invalid values correctly.r   r   Nr\   r]   r^   )r   r_   r`   r.   ra   r   r   r   test_centerx__invalid_valueJ  rd   z(RectTypeTest.test_centerx__invalid_valuec                 C   re   )z/Ensures the centerx attribute can't be deleted.r   r   N)r   r_   rf   r.   r!   r   r   r   test_centerx__delR  rh   zRectTypeTest.test_centerx__delc                 C   rp   )zcChanging the centery attribute moves the rect and does not change
        the rect's width
        r   r   r   r   ri   N)r   r/   r   r    r   )r   r"   Znew_centeryrz   r{   r   r   r   test_centeryY  rt   zRectTypeTest.test_centeryc              	   C   r[   )z?Ensures the centery attribute handles invalid values correctly.r   r   Nr\   r]   r^   )r   r_   r`   r/   ra   r   r   r   test_centery__invalid_valueg  rd   z(RectTypeTest.test_centery__invalid_valuec                 C   re   )z/Ensures the centery attribute can't be deleted.r   r   N)r   r_   rf   r/   r!   r   r   r   test_centery__delo  rh   zRectTypeTest.test_centery__delc                 C   sN   t dddd}|jd |jd f}|j}||_| ||j | ||j dS )zbChanging the topleft attribute moves the rect and does not change
        the rect's size
        r   r   r   r   ri      N)r   r   r   r)   r*   r   )r   r"   Znew_topleftold_sizer   r   r   test_topleftv  s   zRectTypeTest.test_topleftc              	   C   \   t dddd}dg dddg dfD ]}| t ||_W d   n1 s&w   Y  qdS )z?Ensures the topleft attribute handles invalid values correctly.r   r   Nr\   r]   r^   )r   r_   r`   r*   ra   r   r   r   test_topleft__invalid_value     z(RectTypeTest.test_topleft__invalid_valuec                 C   re   )z/Ensures the topleft attribute can't be deleted.r   r   N)r   r_   rf   r*   r!   r   r   r   test_topleft__del  rh   zRectTypeTest.test_topleft__delc                 C   p   t dddd}|jd |jd f}|jd |jd f}|j}||_| ||j | ||j | ||j dS )zeChanging the bottomleft attribute moves the rect and does not change
        the rect's size
        r   r   r   r   ri   r   N)r   r   r(   r   r)   r,   r   r*   )r   r"   Znew_bottomleftexpected_topleftr   r   r   r   test_bottomleft     zRectTypeTest.test_bottomleftc              	   C   r   )zBEnsures the bottomleft attribute handles invalid values correctly.r   r   Nr\   r]   r^   )r   r_   r`   r,   ra   r   r   r   test_bottomleft__invalid_value  r   z+RectTypeTest.test_bottomleft__invalid_valuec                 C   re   )z2Ensures the bottomleft attribute can't be deleted.r   r   N)r   r_   rf   r,   r!   r   r   r   test_bottomleft__del  rh   z!RectTypeTest.test_bottomleft__delc                 C   p   t dddd}|jd |jd f}|jd |jd f}|j}||_| ||j | ||j | ||j dS )zcChanging the topright attribute moves the rect and does not change
        the rect's size
        r   r   r   r   ri   r   N)r   r'   r   r   r)   r+   r   r*   )r   r"   Znew_toprightr   r   r   r   r   test_topright  r   zRectTypeTest.test_toprightc              	   C   r   )z@Ensures the topright attribute handles invalid values correctly.r   r   Nr\   r]   r^   )r   r_   r`   r+   ra   r   r   r   test_topright__invalid_value  r   z)RectTypeTest.test_topright__invalid_valuec                 C   re   )z0Ensures the topright attribute can't be deleted.r   r   N)r   r_   rf   r+   r!   r   r   r   test_topright__del  rh   zRectTypeTest.test_topright__delc                 C   p   t dddd}|jd |jd f}|jd |jd f}|j}||_| ||j | ||j | ||j dS )zfChanging the bottomright attribute moves the rect and does not change
        the rect's size
        r   r   r   r   ri   r   N)	r   r'   r(   r   r   r)   r-   r   r*   )r   r"   Znew_bottomrightr   r   r   r   r   test_bottomright  r   zRectTypeTest.test_bottomrightc              	   C   r   )zCEnsures the bottomright attribute handles invalid values correctly.r   r   Nr\   r]   r^   )r   r_   r`   r-   ra   r   r   r   test_bottomright__invalid_value  r   z,RectTypeTest.test_bottomright__invalid_valuec                 C   re   )z3Ensures the bottomright attribute can't be deleted.r   r   N)r   r_   rf   r-   r!   r   r   r   test_bottomright__del  rh   z"RectTypeTest.test_bottomright__delc                 C   r   )zaChanging the center attribute moves the rect and does not change
        the rect's size
        r   r   r   r   ri   r   N)	r   r.   r/   r   r   r)   r0   r   r*   )r   r"   Z
new_centerr   r   r   r   r   test_center  r   zRectTypeTest.test_centerc              	   C   r   )z>Ensures the center attribute handles invalid values correctly.r   r   Nr\   r]   r^   )r   r_   r`   r0   ra   r   r   r   test_center__invalid_value  r   z'RectTypeTest.test_center__invalid_valuec                 C   re   )z.Ensures the center attribute can't be deleted.r   r   N)r   r_   rf   r0   r!   r   r   r   test_center__del  rh   zRectTypeTest.test_center__delc                 C   r   )zbChanging the midleft attribute moves the rect and does not change
        the rect's size
        r   r   r   r   ri   r   N)r   r   r/   r   r)   r3   r   r*   )r   r"   Znew_midleftr   r   r   r   r   test_midleft  r   zRectTypeTest.test_midleftc              	   C   r   )z?Ensures the midleft attribute handles invalid values correctly.r   r   Nr\   r]   r^   )r   r_   r`   r3   ra   r   r   r   test_midleft__invalid_value  r   z(RectTypeTest.test_midleft__invalid_valuec                 C   re   )z/Ensures the midleft attribute can't be deleted.r   r   N)r   r_   rf   r3   r!   r   r   r   test_midleft__del  rh   zRectTypeTest.test_midleft__delc                 C   r   )zcChanging the midright attribute moves the rect and does not change
        the rect's size
        r   r   r   r   ri   r   N)	r   r'   r/   r   r   r)   r4   r   r*   )r   r"   Znew_midrightr   r   r   r   r   test_midright"  r   zRectTypeTest.test_midrightc              	   C   r   )z@Ensures the midright attribute handles invalid values correctly.r   r   Nr\   r]   r^   )r   r_   r`   r4   ra   r   r   r   test_midright__invalid_value0  r   z)RectTypeTest.test_midright__invalid_valuec                 C   re   )z0Ensures the midright attribute can't be deleted.r   r   N)r   r_   rf   r4   r!   r   r   r   test_midright__del8  rh   zRectTypeTest.test_midright__delc                 C   r   )zaChanging the midtop attribute moves the rect and does not change
        the rect's size
        r   r   r   r   ri   r   N)r   r.   r   r   r)   r1   r   r*   )r   r"   Z
new_midtopr   r   r   r   r   test_midtop?  r   zRectTypeTest.test_midtopc              	   C   r   )z>Ensures the midtop attribute handles invalid values correctly.r   r   Nr\   r]   r^   )r   r_   r`   r1   ra   r   r   r   test_midtop__invalid_valueM  r   z'RectTypeTest.test_midtop__invalid_valuec                 C   re   )z.Ensures the midtop attribute can't be deleted.r   r   N)r   r_   rf   r1   r!   r   r   r   test_midtop__delU  rh   zRectTypeTest.test_midtop__delc                 C   r   )zdChanging the midbottom attribute moves the rect and does not change
        the rect's size
        r   r   r   r   ri   r   N)	r   r.   r(   r   r   r)   r2   r   r*   )r   r"   Znew_midbottomr   r   r   r   r   test_midbottom\  r   zRectTypeTest.test_midbottomc              	   C   r   )zAEnsures the midbottom attribute handles invalid values correctly.r   r   Nr\   r]   r^   )r   r_   r`   r2   ra   r   r   r   test_midbottom__invalid_valuej  r   z*RectTypeTest.test_midbottom__invalid_valuec                 C   re   )z1Ensures the midbottom attribute can't be deleted.r   r   N)r   r_   rf   r2   r!   r   r   r   test_midbottom__delr  rh   z RectTypeTest.test_midbottom__delc                 C   R   t dddd}d}|j}|j}||_| ||j | ||j | ||j dS )z<Changing the width resizes the rect from the top-left cornerr   r   r   r   rW   N)r   r*   r    r   r   )r   r"   Z	new_widthold_topleftr{   r   r   r   
test_widthy     zRectTypeTest.test_widthc              	   C   r[   )z=Ensures the width attribute handles invalid values correctly.r   r   Nr\   r]   r^   )r   r_   r`   r   ra   r   r   r   test_width__invalid_value  rd   z&RectTypeTest.test_width__invalid_valuec                 C   re   )z-Ensures the width attribute can't be deleted.r   r   N)r   r_   rf   r   r!   r   r   r   test_width__del  rh   zRectTypeTest.test_width__delc                 C   r   )z=Changing the height resizes the rect from the top-left cornerr   r   r   r   rW   N)r   r*   r   r    r   )r   r"   Z
new_heightr   rr   r   r   r   test_height  r   zRectTypeTest.test_heightc              	   C   r[   )z>Ensures the height attribute handles invalid values correctly.r   r   Nr\   r]   r^   )r   r_   r`   r    ra   r   r   r   test_height__invalid_value  rd   z'RectTypeTest.test_height__invalid_valuec                 C   re   )z.Ensures the height attribute can't be deleted.r   r   N)r   r_   rf   r    r!   r   r   r   test_height__del  rh   zRectTypeTest.test_height__delc                 C   s>   t dddd}d}|j}||_| ||j | ||j dS )z;Changing the size resizes the rect from the top-left cornerr   r   r   r   rW   ri   N)r   r*   r)   r   )r   r"   new_sizer   r   r   r   	test_size  s   zRectTypeTest.test_sizec              	   C   r   )z<Ensures the size attribute handles invalid values correctly.r   r   Nr\   r]   r^   )r   r_   r`   r)   ra   r   r   r   test_size__invalid_value  r   z%RectTypeTest.test_size__invalid_valuec                 C   re   )z,Ensures the size attribute can't be deleted.r   r   N)r   r_   rf   r)   r!   r   r   r   test_size__del  rh   zRectTypeTest.test_size__delc              	   C   s  t dddd}| |t ddddd | t dddd|v d | |t |d | |t |v d | |t ddddd	 | t dddd|v d	 | |t ddddd
 | |t ddddd | |t ddddd | t dddd|v d
 | t dddd|v d | t dddd|v d | dt ddddv d | dt ddddv d | tdd  | tdd  d S )Nr   r   r   r   z#r does not contain Rect(2, 3, 1, 1)z%r does not contain Rect(2, 3, 1, 1) 2z*r does not contain the same rect as itselfr   z2r does not contain an empty rect within its boundszr contains Rect(0, 0, 1, 2)rM   zr contains Rect(4, 6, 1, 1)zr contains Rect(4, 6, 0, 0)zr does not contain 2zr contains 3c                   S      dt ddddv S )Nstringr   r   r   r   r   r   r   r   <lambda>      z,RectTypeTest.test_contains.<locals>.<lambda>c                   S   r   )Ny      @      @r   r   r   r   r   r   r   r   r     r   )r   
assertTruecontainsassertFalser_   r`   r!   r   r   r   test_contains  s6   zRectTypeTest.test_containsc                 C   s   t dddd}| ||j|jd | ||jd |jd | ||j|jd d | ||jd |jd d | ||jd |jd d	 | ||j|jd
 | ||jd |jd | ||j|jd d d S )Nr   r   r   r   z)r does not collide with point (left, top)z%r collides with point (left - 1, top)z%r collides with point (left, top - 1)z)r collides with point (left - 1, top - 1)z5r does not collide with point (right - 1, bottom - 1)z%r collides with point (right, bottom)z)r collides with point (right - 1, bottom)z)r collides with point (right, bottom - 1))r   r   Zcollidepointr   r   r   r'   r(   r!   r   r   r   test_collidepoint  s:   zRectTypeTest.test_collidepointc                 C   s   t dddd}|dd}| |j|j | |jd |j | |jd |j | |jd |j | |jd |j | |jd |j | |j	d |j	 dS )>The inflate method inflates around the center of the rectangler   r   rM      r   N
r   inflater   r0   r   r   r'   r(   r   r    r   r"   r2r   r   r   test_inflate__larger     z!RectTypeTest.test_inflate__largerc                 C   s   t dddd}|dd}| |j|j | |jd |j | |jd |j | |jd |j | |jd |j | |jd |j | |j	d |j	 dS 	r   r   r   rM   r   rA   r   Nr   r   r   r   r   test_inflate__smaller  r   z"RectTypeTest.test_inflate__smallerc                 C      t dddd}t |}|dd | |j|j | |jd |j | |jd |j | |jd |j | |jd |j | |jd |j | |j	d |j	 dS )	zAThe inflate_ip method inflates around the center of the rectangler   r   rM   r   r   rA   r   N
r   Z
inflate_ipr   r0   r   r   r'   r(   r   r    r   r   r   r   test_inflate_ip__larger"     z$RectTypeTest.test_inflate_ip__largerc                 C   r   r   r   r   r   r   r   test_inflate_ip__smaller0  r   z%RectTypeTest.test_inflate_ip__smallerc                 C   s   t dddd}|d}| |j|j | |jd |j | |jd |j | |jd |j | |jd |j | |jd |j | |j	d |j	 dS :The scale method scales around the center of the rectangler   r   rM   r   r   N
r   scale_byr   r0   r   r   r'   r(   r   r    r   r   r   r   %test_scale_by__larger_single_argument>     
z2RectTypeTest.test_scale_by__larger_single_argumentc                 C   s   t dddd}|jdd}| |j|j | |jd |j | |jd |j | |jd |j | |jd |j | |jd |j | |j	d |j	 dS )zfThe scale method scales around the center of the rectangle using
        keyword arguments 'x' and 'y'r   r   rM   r   )rC   r   Nr   r   r   r   r   +test_scale_by__larger_single_argument_kwargK  s   z8RectTypeTest.test_scale_by__larger_single_argument_kwargc                 C   s   t dddd}|d}| |j|j | |jd |j | |jd |j | |jd |j | |jd |j | |jd |j | |j	d |j	 dS r   r   r   r         ?Nr   r   r   r   r   &test_scale_by__smaller_single_argumentY  r   z3RectTypeTest.test_scale_by__smaller_single_argumentc                 C   s   t dddd}|dd}| |j|j | |jd |j | |j|jd d  |j | |jd |j | |j|jd d  |j	 | |j
d |j
 | |jd |j dS r   r   r   r   r0   r   r/   rF   r   r'   r(   r   r    r   r   r   r   test_scale_by__largerf     z"RectTypeTest.test_scale_by__largerc                 C   s   t dddd}|jdd}| |j|j | |jd |j | |j|jd d  |j | |jd |j | |j|jd d  |j	 | |j
d |j
 | |jd |j dS )	zk
        The scale method scales around the center of the rectangle
        Uses 'scale_by' kwarg.
        r   r   rM   r   )r   r   r   r   Nr   r   r   r   r   %test_scale_by__larger_kwargs_scale_byu  s   z2RectTypeTest.test_scale_by__larger_kwargs_scale_byc                 C   s   t dddd}|jddd}| |j|j | |jd |j | |j|jd d  |j | |jd |j | |j|jd d  |j	 | |j
d |j
 | |jd |j dS )zm
        The scale method scales around the center of the rectangle
        Uses 'x' and 'y' kwargs.
        r   r   rM   r   rC   rE   r   Nr   r   r   r   r   test_scale_by__larger_kwargs  s   z)RectTypeTest.test_scale_by__larger_kwargsc                 C   s   t dddd}|dd}| |j|j | |jd |j | |j|jd d  |j | |jd |j | |j|jd d  |j	 | |j
d |j
 | |jd |j dS )r   r   r   r   r   g      ?Nr   r   r   r   r   test_scale_by__smaller  r   z#RectTypeTest.test_scale_by__smallerc                 C   s  t dddd}|d |d |d |d |d	d
}| |j|jd	 d  |j | |j|j | |jd	 |j | |j|j |dd
}| |j|j | |j|j | |j|j | |j|j |d
d	}| |j|j | |j|jd	 d  |j | |j|j | |jd	 |j |d
d}| |j|j | |j|j | |j|j | |j|j |d	}| |j|jd	 d  |j | |j|jd	 d  |j | |jd	 |j | |jd	 |j dS )r   r   r   rM   r   r   ưh㈵>rW   r   N)	r   r   r   r.   rD   rC   rE   rF   r/   )r   r"   Zrx1Zrx2Zry1Zry2r1r   r   r   test_scale_by__subzero  s<   




z#RectTypeTest.test_scale_by__subzeroc                 C   ^   t dddd}|dd}| |j|j | |j|j | |j|j | |j|j dS r   r   r   rM   r   r   Nr   r   r   rC   rE   rD   rF   r   r"   actualr   r   r   test_scale_by_identity     z#RectTypeTest.test_scale_by_identityc                 C   r   r   r   r   rM   r   r   Nr   r   r   r   r   test_scale_by_negative_identity  r   z,RectTypeTest.test_scale_by_negative_identityc                 C   \   t dddd}|d}| |j|j | |j|j | |j|j | |j|j dS r   r   r   r   r   r   &test_scale_by_identity_single_argument     
z3RectTypeTest.test_scale_by_identity_single_argumentc                 C   r   r   r   r   r   r   r   .test_scale_by_negative_identity_single_argment  r   z;RectTypeTest.test_scale_by_negative_identity_single_argmentc                 C   s   t dddd}t |}|d | |j|j | |jd |j | |jd |j | |jd |j | |jd |j | |jd |j | |j	d |j	 dS r   
r   scale_by_ipr   r0   r   r   r'   r(   r   r    r   r   r   r   test_scale_by_ip__larger     
z%RectTypeTest.test_scale_by_ip__largerc                 C   s   t dddd}t |}|d | |j|j | |jd |j | |jd |j | |jd |j | |jd |j | |jd |j | |j	d |j	 dS r   r   r   r   r   r   test_scale_by_ip__smaller
  r   z&RectTypeTest.test_scale_by_ip__smallerc                 C   s:   t dddd}|d |d |d |d d	S )
r   r   r   rM   r   r   r   r   r   N)r   r   r!   r   r   r   test_scale_by_ip__subzero  s
   


z&RectTypeTest.test_scale_by_ip__subzeroc                 C   s   t dddd}t |}|jddd | |j|j | |jd |j | |j|jd d  |j | |jd |j | |j|jd d  |j	 | |j
d |j
 | |jd |j dS )r   r   r   rM   r   r   r   N)r   r   r   r0   r   r/   rF   r   r'   r(   r   r    r   r   r   r   test_scale_by_ip__kwargs   s   z%RectTypeTest.test_scale_by_ip__kwargsc                 C   s   t dddd}| t |jdd W d   n1 sw   Y  | t |jddd	 W d   dS 1 s:w   Y  dS )
zThe scale method scales around the center of the rectangle using
        keyword argument 'scale_by'. Tests for incorrect keyword argsr   r   rM   r   r   Nr$   r   )r   rE   )r   r_   r`   r   r!   r   r   r   "test_scale_by_ip__kwarg_exceptions/  s   "z/RectTypeTest.test_scale_by_ip__kwarg_exceptionsc                 C   s   t dddd}t dddd|}| |j|j | |jd t dddd|}| |j|j t dd	d
d|}| |j|j d S NrW            r   r   r   r   i     !   )r   clampr   r'   r   r*   r0   r   r"   cr   r   r   
test_clamp:  s   zRectTypeTest.test_clampc                 C   s   t dddd}t dddd}|| | |j|j | |jd t dddd}|| | |j|j t dd	d
d}|| | |j|j d S r   )r   Zclamp_ipr   r'   r   r*   r0   r  r   r   r   test_clamp_ipD  s   


zRectTypeTest.test_clamp_ipc              
   C   s   t dddd}| t dddd|t dddd | t dddd|t dddd | t dddd|t dddd | d|dd	d
dj | ||t |d d S )Nr   r   r   r   r   rW   ri   rU   r   r  rM   z,r1 does not clip an identical rect to itself)r   r   clipr)   r   r   r   r   r   	test_clipQ  s   &&&zRectTypeTest.test_clipc                 C   sV   t dd}d}d}d}d}||f||ff}|||||}| |t | || dS )zjEnsures clipline handles four int parameters.

        Tests the clipline(x1, y1, x2, y2) format.
        r$   #   (   r  rM      r   N)r   cliplineassertIsInstancetupleassertTupleEqualr   r<   x1y1x2y2expected_lineclipped_liner   r   r   test_clipline[  s   
zRectTypeTest.test_cliplinec           
      C   sn   t dd}d}d}tttf}||f}|D ] }||}|D ]}||||f}	| |	t | |	| qqdS )zEnsures clipline handles a sequence of two sequences.

        Tests the clipline((x1, y1), (x2, y2)) format.
        Tests the sequences as different types.
        r$   r  r  rM   r  r   Nr   listr  r   r  r  r  
r   r<   pt1pt2INNER_SEQUENCESr  
inner_seq1endpt1
inner_seq2r  r   r   r   test_clipline__two_sequencesl  s   

z)RectTypeTest.test_clipline__two_sequencesc           
      C   sn   t dd}d}d}tttf}||f}|D ] }||}|D ]}|j|||d}	| |	t | |	| qqdS )zEnsures clipline handles a sequence of two sequences using kwargs.

        Tests the clipline((x1, y1), (x2, y2)) format.
        Tests the sequences as different types.
        r$   r  r  r  first_coordinatesecond_coordinateNr  r   r   r   r   "test_clipline__two_sequences_kwarg  s   

z/RectTypeTest.test_clipline__two_sequences_kwargc                 C   sf   t dd}d}|d |d f|d |d ff}ttfD ]}|||}| |t | || qdS )	zEnsures clipline handles a sequence of four ints.

        Tests the clipline((x1, y1, x2, y2)) format.
        Tests the sequence as different types.
        r$   r  r  rM   r  r   r   r   r   r   Nr   r  r  r  r  r  r   r<   liner  	outer_seqr  r   r   r   $test_clipline__sequence_of_four_ints  s   
 z1RectTypeTest.test_clipline__sequence_of_four_intsc                 C   sh   t dd}d}|d |d f|d |d ff}ttfD ]}|j||d}| |t | || qd	S )
zEnsures clipline handles a sequence of four ints using kwargs.

        Tests the clipline((x1, y1, x2, y2)) format.
        Tests the sequence as different types.
        r$   r  r,  r   r   r   r   rect_argNr-  r.  r   r   r   +test_clipline__sequence_of_four_ints_kwargs  s   
 z8RectTypeTest.test_clipline__sequence_of_four_ints_kwargsc                 C   s   t dd}d}d}tttf}||f}|D ]+}||}|D ]"}||}	ttfD ]}
||
||	f}| |t | || q&qqdS )zEnsures clipline handles a sequence of two sequences.

        Tests the clipline(((x1, y1), (x2, y2))) format.
        Tests the sequences as different types.
        r$   r  r  r  Nr  r   r<   r!  r"  r#  r  r$  r%  r&  Zendpt2r0  r  r   r   r   (test_clipline__sequence_of_two_sequences  s    

z5RectTypeTest.test_clipline__sequence_of_two_sequencesc                 C   s   t dd}d}d}tttf}||f}|D ],}||}|D ]#}||}	ttfD ]}
|j|
||	fd}| |t | || q&qqdS )zEnsures clipline handles a sequence of two sequences using kwargs.

        Tests the clipline(((x1, y1), (x2, y2))) format.
        Tests the sequences as different types.
        r$   r  r  r  r  Nr  r5  r   r   r   /test_clipline__sequence_of_two_sequences_kwargs  s    

z<RectTypeTest.test_clipline__sequence_of_two_sequences_kwargsc                 C   sn   t dd}d}d}d}d}t|t|ft|t|ff}|||||}| |t | || dS )z*Ensures clipline handles float parameters.r$   r  皙@皙@'@fffff3@Nr   mathfloorr  r  r  r  r  r   r   r   test_clipline__floats  s   
z"RectTypeTest.test_clipline__floatsc                 C   sp   t dd}d}d}d}d}t|t|ft|t|ff}|j||||d}| |t | || dS )	zlEnsures clipline handles four float parameters.

        Tests the clipline(x1, y1, x2, y2) format.
        r$   r  r9  r:  r;  r<  )r  r  Zx3Zx4Nr=  r  r   r   r   test_clipline__floats_kwargs  s   
z)RectTypeTest.test_clipline__floats_kwargsc                 C   s*  t dddd}| t |jdd W d   n1 sw   Y  | t |jdd	d
 W d   n1 s9w   Y  | t |jdddd W d   n1 sVw   Y  | t |jdd W d   n1 sqw   Y  | t |jddd W d   dS 1 sw   Y  dS )z3Ensure clipline handles incorrect keyword argumentsr   r   rM   r   r   r7  N)r   r   r  r   r$   r(  )r   r   r   r   r   )r)  r*  r  )r   r   r  r2  )r3  r*  r   r_   r`   r  r!   r   r   r   test_clipline__kwarg_exceptions  s    "z,RectTypeTest.test_clipline__kwarg_exceptionsc                 C   sj   t dd}|dd}|j|jf|j|jf|j|jf|j|jff}d}|D ]}||}| || q%dS )z;Ensures lines that do not overlap the rect are not clipped.rW         ri   r   r   N)r   r   r,   r*   r+   r-   r  r  )r   r<   big_rectlinesr  r/  r  r   r   r   test_clipline__no_overlap(  s   





z&RectTypeTest.test_clipline__no_overlapc                 C   sJ  t dd}|dd}|j|jf|j|jd d |jd ff|j|jf|j|jd |jd d ff|j|jf|j|jd d |jd d ff|jd d |jd f|j	d |j	d d ff|jd d |jd f|j	d |j	d d ffi}|
 D ](\}}||}| || |d |d f}||d |d f}| || qzdS )zvEnsures lines that overlap the rect are clipped.

        Testing lines with both endpoints outside the rect.
        rU   ri   ri   r   r   r   N)r   r   r3   r4   r1   r2   r*   r-   r+   r,   itemsr  r  r   r<   rI  	line_dictr/  r  r  r   r   r   %test_clipline__both_endpoints_outside;  s8   




z2RectTypeTest.test_clipline__both_endpoints_outsidec                 C   s   t dd}|dd}|j|jf|j|jf|j|jf|j|j	ff}|D ](}|}|
|}| || |d |d f}|
|d |d f}| || q#dS )zuEnsures lines that overlap the rect are clipped.

        Testing lines with both endpoints inside the rect.
        )r   rL  r   r   N)r   r   r3   r4   r1   r2   r*   r-   r+   r,   r  r  )r   r<   Z
small_rectrJ  r/  r  r  r   r   r   $test_clipline__both_endpoints_insidej  s   





z1RectTypeTest.test_clipline__both_endpoints_insidec                 C   s  t dd}|dd}|j|jf|j|jf|j|jf|j|jf|j|jf|jd d |jd f|jf|j|jf|jd |jd d f|jf|j|jf|j|jf|j|jf|jd d |jd f|jf|j	|jf|j	d d |j	d d f|jf|j
d |j
d d f|jf|j
d |j
d d f|jfi}| D ](\}}||}| || |d |d f}||d |d f}| || qdS )zEnsures lines that overlap the rect are clipped.

        Testing lines with one endpoint outside the rect and the other is
        inside the rect.
        rU   )   rT  r   r   r   N)r   r   r3   r0   r1   r4   r2   r*   r+   r-   r,   rM  r  r  rN  r   r   r   +test_clipline__endpoints_inside_and_outside  sB   





z8RectTypeTest.test_clipline__endpoints_inside_and_outsidec                 C   s   t dd}|j|jf|jd |jd d f|jf|j|jf|j|jd d |jd ff|j|jfd|j|jfdi}| D ]*\}}||}| || |rV|d |d f}||d |d f}| || q=dS )zCEnsures clipline properly clips line that are along the rect edges.rE  rG  r   r   r   N)r   r,   r*   r+   r-   rM  r  r  )r   r<   Z	edge_dictedger  r  r   r   r   test_clipline__edges  s(   



z!RectTypeTest.test_clipline__edgesc                    sV   t dd  fddt j jD }|D ]}||f} ||f}| || qdS )zsEnsures clipline handles lines with both endpoints the same.

        Testing lines that overlap the rect.
        rE  rG  c                 3   s,    | ]}t  j jD ]}||fV  qqd S r   )ranger   r(   ).0rC   rE   r<   r   r   	<genexpr>  s    zKRectTypeTest.test_clipline__equal_endpoints_with_overlap.<locals>.<genexpr>N)r   rX  r   r'   r  r  )r   Zptsptr  r  r   rZ  r   +test_clipline__equal_endpoints_with_overlap  s   

z8RectTypeTest.test_clipline__equal_endpoints_with_overlapc                 C   sD   d}t dd}t|ddD ]}|||f}| || qdS )zzEnsures clipline handles lines with both endpoints the same.

        Testing lines that do not overlap the rect.
        r   rE  rG  r   N)r   r   Zrect_perimeter_ptsr   r  r  )r   r  r<   r\  r  r   r   r   )test_clipline__equal_endpoints_no_overlap  s   
z6RectTypeTest.test_clipline__equal_endpoints_no_overlapc                 C   s8   d}dD ]}t d|}||j|j}| || qdS )z4Ensures clipline handles zero sized rects correctly.r   ))r   rH  )rH  r   rU   rE  N)r   r  r*   r  )r   r  r)   r<   r  r   r   r   test_clipline__zero_size_rect  s   
z*RectTypeTest.test_clipline__zero_size_rectc           	      C   sb  d}dD ]}t d|}| }|  |dd}|j|jf|j|jd d |jd ff|j|jf|j|jd |jd d ff|j|jf|j|jf|j|jf|j|jf|j|jf|jd d |jd f|jf|j|jf|jd |jd d f|jfi}|	 D ].\}}|
|}| || | || |d |d f}|
|d |d f}| || qqdS )z8Ensures clipline handles negative sized rects correctly.r   ))ri   )rH  )r`  ra  rE  r   r   r   N)r   copyrG   r   r3   r4   r1   r2   r0   rM  r  assertNotEqualr  )	r   r  r)   r<   Z	norm_rectrI  rO  r/  r  r   r   r   !test_clipline__negative_size_rect  sP   







z.RectTypeTest.test_clipline__negative_size_rectc              	   C   s   t dd}d}|D ]6}| t ||}W d   n1 s w   Y  | t |j| }W d   n1 s:w   Y  q	dS )z1Ensures clipline handles invalid lines correctly.rU   r   )r   r]   r$   r^   )r   r   r   r   r  )r$   )r$   )r   )r$   r   ))r   r   r  r%   )r$   )r   r   r  )r$   r%   r  NrC  )r   r<   Zinvalid_linesr/  r  r   r   r   test_clipline__invalid_lineE  s   
z(RectTypeTest.test_clipline__invalid_linec                 C   sP   t dddd}d}d}|||}t |j| |j| |j|j}| || d S Nr   r   r   r   rW   ri   )r   mover   r   r   r    r   )r   r"   move_xmove_yr   expected_r2r   r   r   	test_move]  s   zRectTypeTest.test_movec                 C   sX   t dddd}t |}d}d}||| t |j| |j| |j|j}| || d S rf  )r   Zmove_ipr   r   r   r    r   )r   r"   r   rh  ri  rj  r   r   r   test_move_ipe  s   zRectTypeTest.test_move_ipz=fails on pypy (but only for: bottom, right, centerx, centery)c              
   C   sj  d}d}d}g |d|t  f|d|t  f|d|d t  f|d|d t  f|d	|d
 t  f|d|t  f|d|t  f|d|d t  f|d|d t  f|d|d
 t  f|d|d t  f|d|d t  f|d|d t  f|d|d t  f|d|t  f|d|t  f|d|d t  f|d|d t  f|d	|d
 t  f|d|t  f|d|t  f|d|t  f|d|d t  f|d|d
 t  f|d|d t  f|d|d t  f|d|d t  f|d|d t  f|d|t  f|d|t  f|d|t  f|d|d t  f|d	|d t  f|d|t  f|d|t  f|d|d t  f|d|d t  f|d|d
 t  f|d|d t  f|d|d t  f|d|d t  f|d|d t  f}g d}g d}|D ]}|\}}	}
}||	 }|D ]8}| j|d| d" tt  t  t  t  }t||| | |
t|| W d    n	1 sw   Y  q~|D ]w}| j|d| dd& tt  t  t  t  }t||||f | |
|ft|| W d    n	1 sw   Y  | j|d| dd& tt  t  t  t  }t||||f | ||
ft|| W d    n	1 s*w   Y  qqpd S )Nr   |   iPg?g?r   r   皙?g      ?r   ggٿg      g333333gr   r   r   rC   rE   rD   rF   r   r    r   r   r(   r'   r.   r/   
r*   r+   r,   r-   r1   r3   r2   r4   r)   r0   r.rowname[0][1])r   subTestr   setattrr   getattr)r   zeroposneg	data_rowsZsingle_value_attribute_namestuple_value_attribute_namesrs  initialincexpectedother	new_valueattribute_namer   r   r   r   test_set_float_valuesn  s   	
 !"#$%&'()*-		z"RectTypeTest.test_set_float_valuesc                 C   s  d}t d tft d tft d ft d d ft d d ft d d ft d d ft d d ft d d ftd tftd tftd ftd d ftd d ftd d ftd	 d ftd d ftd d fd
ddg}g d}g d}|D ]}|D ]B}|\}}| j|d| d* tdddd}	|r| tt|	|| nt|	|| | |t|	| W d    n1 sw   Y  qkt	 }
|D ]}|\}}| j|d| dd0 tdddd}	|r| tt|	|||
f nt|	|||
f | ||
ft|	| W d    n1 sw   Y  | j|d| dd1 tdddd}	|r| tt|	||
|f nt|	||
|f | |
|ft|	| W d    n	1 s<w   Y  qqgd S )Nr   r   r   r   rW   ?   @   A   >   )r   N)i N)i`yNro  rp  rq  rr  ru  rv  )
r   r`   r   rw  r   r_   rx  r   ry  r   )r   r=   r}  Zsingle_attribute_namesr~  rs  r  rb   r  r   r  r   r   r   -test_set_out_of_range_number_raises_exception  s   
















z:RectTypeTest.test_set_out_of_range_number_raises_exceptionc                 C   sZ   t dddd}|dddd | d|j | d|j | d|j | d|j dS )z)Test update with 4 int values(x, y, w, h)r   r   r   r   r   Nr   updater   r   r   r   r    r   r<   r   r   r   test_update_XYWidthHeightH  s   z&RectTypeTest.test_update_XYWidthHeightc                 C   sV   t dddd}|dd | d|j | d|j | d|j | d|j dS )	z)Test update with 2 tuples((x, y), (w, h))r   r   r$   r%   r   r   r   Nr  r  r   r   r   test_update__TopLeftSizeR  s   z%RectTypeTest.test_update__TopLeftSizec                 C   s\   t dddd}g d}|| | d|j | d|j | d|j | d|j dS )zTest update with listr   r   r   r   r   r   r   r   r   Nr  r   r<   rect2r   r   r   test_update__List\  s   
zRectTypeTest.test_update__Listc                 C   sb   t dddd}t dddd}|| | d|j | d|j | d|j | d|j dS )z"Test update with other rect objectr   r   r   r   r   Nr  r  r   r   r   test_update__RectObjectg  s   
z$RectTypeTest.test_update__RectObjectc                 C   s<   t dddd}t dddd}| t dddd|| d S Nr   r   rR  r   r  r   r   unionr   r   r   r   r   r   
test_unionr  s    zRectTypeTest.test_unionc                 C   s(   t dddd}| ||t | d S r   r  r
  r   r   r   test_union__with_identical_Rectw  s   z,RectTypeTest.test_union__with_identical_Rectc                 C   s@   t dddd}t dddd}|| | t dddd| d S r  )r   Zunion_ipr   r  r   r   r   test_union_ip{  s   
zRectTypeTest.test_union_ipc                 C   sR   t dddd}t dddd}t dddd}|||g}| t dddd| d S Nr   r   rR  r   r  r   unionallr   r   r   r   r3r4r   r   r   test_unionall  s
   zRectTypeTest.test_unionallc              	   C   sj   g d}g d}ddg}|||fD ]!}|  t tdddd| W d   n1 s-w   Y  qdS )z;Ensures unionall correctly handles invalid rect parameters.)r   g333333?r   gffffff
@)abr  Nr   r   )r_   r`   r   r  )r   numbersstrsZnonesZinvalid_rectsr   r   r   "test_unionall__invalid_rect_format  s   z/RectTypeTest.test_unionall__invalid_rect_formatc                 C   sT   t dddd}t dddd}t dddd}|j||gd}| t dddd| d S )Nr   r   rR  r   rZ  r  r  r  r   r   r   test_unionall__kwargs  s
   z"RectTypeTest.test_unionall__kwargsc                 C   sf   t dddd}t dddd}t dddd}|||g | t dddd| | |g d u  d S r  r   Zunionall_ipr   r   r   r   r   r  r   r   r   test_unionall_ip  s   zRectTypeTest.test_unionall_ipc                 C   sh   t dddd}t dddd}t dddd}|j||gd | t dddd| | |g d u  d S )Nr   r   rR  r   rectsr  r  r  r   r   r   test_unionall_ip__kwargs  s   z%RectTypeTest.test_unionall_ip__kwargsc              
   C   s(  t dddd}| |t ddddd | |t ddddd | |t |j|jddd | |t |jd |jd |jd |j	d d	 | |t |jd |jd |jd |j	d d
 | |t |d | |t |j|jddd | |t |j|jddd d S )Nr   r   r   r   r   z)r1 does not collide with Rect(0, 0, 2, 3)z!r1 collides with Rect(0, 0, 1, 2)z0r1 collides with Rect(r1.right, r1.bottom, 2, 2)zSr1 does not collide with Rect(r1.left + 1, r1.top + 1, r1.width - 2, r1.height - 2)zSr1 does not collide with Rect(r1.left - 1, r1.top - 1, r1.width + 2, r1.height + 2)z*r1 does not collide with an identical rectz0r1 collides with Rect(r1.right, r1.bottom, 0, 0)z0r1 collides with Rect(r1.right, r1.bottom, 1, 1))
r   r   Zcolliderectr   r'   r(   r   r   r   r    r
  r   r   r   test_colliderect  s>   **zRectTypeTest.test_colliderectc           
      C   s   t dddd}t dddd}d	}t dddd}G d
d dt }G dd dt }|dddd}|dddd}| || | || |||||g}	|	| |	| |	| |	| | t|	j| dS )z%check to see how the rect uses __eq__r   r   r   r   rW   ri   r   r  )rW   ri   r   r  c                   @      e Zd Zdd Zdd ZdS )z$RectTypeTest.testEquals.<locals>.fooc                 S   s   t | t |kS r   idr   r  r   r   r   __eq__     z+RectTypeTest.testEquals.<locals>.foo.__eq__c                 S   s   t | t |kS r   r  r  r   r   r   __ne__  r  z+RectTypeTest.testEquals.<locals>.foo.__ne__N)__name__
__module____qualname__r  r  r   r   r   r   foo      r  c                   @   s   e Zd ZdS )z%RectTypeTest.testEquals.<locals>.foo2N)r  r  r  r   r   r   r   foo2  s    r  N)r   rc  r   remover_   
ValueError)
r   r   r   r  r  r  r  Zr5Zr6Z	rect_listr   r   r   
testEquals  s    



zRectTypeTest.testEqualsc                 C   s   t dddd}d| f}dt ddddf}dt ddddf}dt d	d	ddf}t||||f}||f}d
d | D }tdd |D }	dD ]}
|
rQ|}|}n|	}|}|||
}| || qHdS )z'Ensures collidedict detects collisions.r   rW   	collide 1	collide 2r  no collide 1<   no collide 2F   c                 S      i | ]	\}}t ||qS r   r  rY  kvr   r   r   
<dictcomp>      z1RectTypeTest.test_collidedict.<locals>.<dictcomp>c                 s        | ]\}}t ||fV  qd S r   r  r  r   r   r   r[        z0RectTypeTest.test_collidedict.<locals>.<genexpr>TFNr   rb  dictrM  r  collidedictZassertInr   r<   collide_item1collide_item2no_collide_item1no_collide_item2rect_valuesvalue_collide_items	rect_keyskey_collide_items
use_valuesexpected_itemsdcollide_itemr   r   r   test_collidedict  s(   
zRectTypeTest.test_collidedictc           
      C   s   t dddd}dt ddddf}dt ddddf}dt ddddf}t|||f}d	d
 | D }dD ]}|r:|n|}|||}	| |	 q4dS )z4Ensures collidedict returns None when no collisions.r   rW   r  r6   r  r  no collide 3r  c                 S   r  r   r  r  r   r   r   r  "  r  z?RectTypeTest.test_collidedict__no_collision.<locals>.<dictcomp>r  Nr   r  rM  r  assertIsNone
r   r<   r  r  no_collide_item3r  r  r  r  r  r   r   r   test_collidedict__no_collision  s   z+RectTypeTest.test_collidedict__no_collisionc                 C   s   t dddd}t dddd}d|f}dt ddddf}dt ddddf}d	t d
d
ddf}t|||f}dd | D }dD ]9}	t||	t||	 dD ]+}
|
rW|}t|}nt|d |d f}t|}||f |||
}| || qLq?dS )z@Ensures collidedict works correctly for rects that barely touch.r   rW   r   r  r  r6   r  r  r  r  c                 S   r  r   r  r  r   r   r   r  <  r  zBRectTypeTest.test_collidedict__barely_touching.<locals>.<dictcomp>r*   r+   r-   r,   r  N)	r   r  rM  rx  ry  r  r  r  r  )r   r<   collide_rectr  r  r  r  no_collide_rect_valuesno_collide_rect_keysattrr  expected_itemr  r  r   r   r   !test_collidedict__barely_touching+  s.   
z.RectTypeTest.test_collidedict__barely_touchingc                 C   s  t dddd}t dddd}t dddd}t dddd}t dddd}d| f}d| f}d| f}d| f}	d| f}
d	t ddd
d
f}dt ddddf}t||||	|
||f}dd | D }dD ]}|ro|n|}|||||fD ]}|||}| | qxqidS )zEnsures collidedict works correctly with zero sized rects.

        There should be no collisions with zero sized rects.
        r   r   r   r  r  r  no collide 4no collide 5no collide 6rW   no collide 7r   c                 S   r  r   r  r  r   r   r   r  q  r  zCRectTypeTest.test_collidedict__zero_sized_rects.<locals>.<dictcomp>r  N)r   rb  r  rM  r  r  )r   
zero_rect1
zero_rect2
zero_rect3
zero_rect4
zero_rect5r  r  r  no_collide_item4no_collide_item5no_collide_item6no_collide_item7r  r  r  r  	zero_rectr  r   r   r   "test_collidedict__zero_sized_rectsP  sF   z/RectTypeTest.test_collidedict__zero_sized_rectsc           
      C   s   t dddd}dt ddddf}dt ddddf}dt ddddf}t|||f}dd | D }d	D ]}|r:|n|}|||}	| |	 q4d
S )zEnsures collidedict works correctly with zero sized rects as args.

        There should be no collisions with zero sized rects.
        r   rW   r  r   r  r  c                 S   r  r   r  r  r   r   r   r    r  zKRectTypeTest.test_collidedict__zero_sized_rects_as_args.<locals>.<dictcomp>r  Nr  r  r   r   r   *test_collidedict__zero_sized_rects_as_args  s   z7RectTypeTest.test_collidedict__zero_sized_rects_as_argsc                 C   s   t dddd}d| f}dt ddddf}dt ddddf}t|||f}||f}dd	 | D }td
d |D }dD ]}	|	rG|}
|}n|}
|}|||	}| ||
 q>dS )z>Ensures collidedict works correctly with negative sized rects.r   r   r  r  r   rW   r  c                 S   r  r   r  r  r   r   r   r    r  zGRectTypeTest.test_collidedict__negative_sized_rects.<locals>.<dictcomp>c                 s   r  r   r  r  r   r   r   r[    r  zFRectTypeTest.test_collidedict__negative_sized_rects.<locals>.<genexpr>r  Nr  )r   neg_rectr  r  r  r  r  r  r  r  collide_itemsr  r  r   r   r   &test_collidedict__negative_sized_rects  s"   z3RectTypeTest.test_collidedict__negative_sized_rectsc                 C   s   t dddd}dt ddddf}dt ddddf}dt ddddf}t|||f}dd	 | D }d
D ]!}|r=|}|}	nt|d |d f}|}	||	|}
| |
| q4dS )zBEnsures collidedict works correctly with negative sized rect args.r   rW   r  r   r   r  r  c                 S   r  r   r  r  r   r   r   r    r  zORectTypeTest.test_collidedict__negative_sized_rects_as_args.<locals>.<dictcomp>r  N)r   r  rM  r  r  r  )r   r<   r  r  r  r  r  r  r  r  r  r   r   r   .test_collidedict__negative_sized_rects_as_args  s   z;RectTypeTest.test_collidedict__negative_sized_rects_as_argsc              	   C   ~   t dddd}d| f}t|d |d f}dD ]#}|r|n|}| t |||}W d   n1 s7w   Y  qdS )z>Ensures collidedict correctly handles invalid dict parameters.r   rW   collider   r  N)r   rb  r  r_   r`   r  r   r<   Zinvalid_value_dictZinvalid_key_dictr  r  r  r   r   r   %test_collidedict__invalid_dict_format     z2RectTypeTest.test_collidedict__invalid_dict_formatc                 C   V   t dddd}t|di}| t ||d}W d   dS 1 s$w   Y  dS )z@Ensures collidedict correctly handles dicts with invalid values.r   rW   r  r   N)r   r  r_   r`   r  )r   r<   r  r  r   r   r   +test_collidedict__invalid_dict_value_format  
   "z8RectTypeTest.test_collidedict__invalid_dict_value_formatc                 C   T   t dddd}d| i}| t ||}W d   dS 1 s#w   Y  dS )z>Ensures collidedict correctly handles dicts with invalid keys.r   rW   r  N)r   rb  r_   r`   r  )r   r<   r  r  r   r   r   )test_collidedict__invalid_dict_key_format  
   "z6RectTypeTest.test_collidedict__invalid_dict_key_formatc              	   C   \   t dddd}i }d|dfD ]}| t |||}W d   n1 s&w   Y  qdS )zDEnsures collidedict correctly handles invalid use_values parameters.r   r   Nrn  )r   r_   r`   r  )r   r<   r  invalid_paramr  r   r   r   +test_collidedict__invalid_use_values_format  s   z8RectTypeTest.test_collidedict__invalid_use_values_formatc                 C   s   t dddd}d| f}dt ddddf}dt ddddf}dt d	d	ddf}t||||f}||f}d
d | D }tdd |D }	dD ]}
|
rQ|}|}n|	}|}|j||
d}| || qHdS )z=Ensures collidedict detects collisions via keyword arguments.r   rW   r  r  r  r  r  r  r  c                 S   r  r   r  r  r   r   r   r  	  r  z9RectTypeTest.test_collidedict__kwargs.<locals>.<dictcomp>c                 s   r  r   r  r  r   r   r   r[  	  r  z8RectTypeTest.test_collidedict__kwargs.<locals>.<genexpr>r  Z	rect_dictvaluesNr  r  r   r   r   test_collidedict__kwargs  s(   
z%RectTypeTest.test_collidedict__kwargsc                 C   s   t dddd}d| f}dt ddddf}dt ddddf}d	t d
d
ddf}t||||f}||g}dd | D }dd |D }	dD ]}
|
rO|}|}n|	}|}|||
}| || qFdS )z*Ensures collidedictall detects collisions.r   rW   r  r  r  r  r  ri   r  r  c                 S   r  r   r  r  r   r   r   r  &	  r  z4RectTypeTest.test_collidedictall.<locals>.<dictcomp>c                 S      g | ]
\}}t ||fqS r   r  r  r   r   r   
<listcomp>'	      z4RectTypeTest.test_collidedictall.<locals>.<listcomp>r  Nr   rb  r  rM  collidedictallr   r   r<   r  r  r  r  r  r  r  r  r  r  r  r  r   r   r   test_collidedictall	  s(   
z RectTypeTest.test_collidedictallc                 C   s   t dddd}dt ddddf}dt ddddf}dt d	d	ddf}t|||f}d
d | D }g }dD ]}|r<|n|}	||	|}
| |
| q6dS )z@Ensures collidedictall returns an empty list when no collisions.r   rW   r  r6   ri   r  r  r  r  c                 S   r  r   r  r  r   r   r   r  A	  r  zBRectTypeTest.test_collidedictall__no_collision.<locals>.<dictcomp>r  Nr   r  rM  r  r   r   r<   r  r  r  r  r  r  r  r  r  r   r   r   !test_collidedictall__no_collision5	  s   z.RectTypeTest.test_collidedictall__no_collisionc                 C   s   t dddd}t dddd}d|f}dt ddddf}dt d	d	ddf}d
t ddddf}t|||f}dd | D }dD ]:}	t||	t||	 dD ],}
|
rX|g}t|}nt|d |d fg}t|}|| |||
}| || qLq?dS )zCEnsures collidedictall works correctly for rects that barely touch.r   rW   r   r  r  r6   ri   r  r  r  r  c                 S   r  r   r  r  r   r   r   r  ]	  r  zERectTypeTest.test_collidedictall__barely_touching.<locals>.<dictcomp>r  r  N)	r   r  rM  rx  ry  r  r  r  r   )r   r<   r  r  r  r  r  r  r  r  r  r  r  r  r   r   r   $test_collidedictall__barely_touchingL	  s.   

z1RectTypeTest.test_collidedictall__barely_touchingc                 C   s  t dddd}t dddd}t dddd}t dddd}t dddd}d| f}d| f}d| f}d| f}	d| f}
d	t ddd
d
f}dt ddddf}t||||	|
||f}dd | D }g }dD ]}|rq|n|}|||||fD ]}|||}| || qzqkdS )zEnsures collidedictall works correctly with zero sized rects.

        There should be no collisions with zero sized rects.
        r   r   rR  r  r  r  r  r  r  rW   r  c                 S   r  r   r  r  r   r   r   r  	  r  zFRectTypeTest.test_collidedictall__zero_sized_rects.<locals>.<dictcomp>r  Nr  )r   r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r   r   r   %test_collidedictall__zero_sized_rectsq	  sH   z2RectTypeTest.test_collidedictall__zero_sized_rectsc                 C   s   t dddd}dt ddddf}dt ddddf}dt ddddf}t|||f}dd | D }g }d	D ]}|r<|n|}	||	|}
| |
| q6d
S )zEnsures collidedictall works correctly with zero sized rects
        as args.

        There should be no collisions with zero sized rects.
        r   ri   r  r   r  r  c                 S   r  r   r  r  r   r   r   r  	  r  zNRectTypeTest.test_collidedictall__zero_sized_rects_as_args.<locals>.<dictcomp>r  Nr  r  r   r   r   -test_collidedictall__zero_sized_rects_as_args	  s   z:RectTypeTest.test_collidedictall__zero_sized_rects_as_argsc                 C   s   t dddd}d| f}dt ddddf}dt ddddf}t|||f}||g}dd	 | D }d
d |D }dD ]}	|	rE|}
|}n|}
|}|||	}| ||
 q<dS )zAEnsures collidedictall works correctly with negative sized rects.r   rR  r  r  r   ri   r  c                 S   r  r   r  r  r   r   r   r  	  r  zJRectTypeTest.test_collidedictall__negative_sized_rects.<locals>.<dictcomp>c                 S   r  r   r  r  r   r   r   r  	  r  zJRectTypeTest.test_collidedictall__negative_sized_rects.<locals>.<listcomp>r  Nr  )r   r  r  r  r  r  r  r  r  r  r  r  r  r   r   r   )test_collidedictall__negative_sized_rects	  s"   z6RectTypeTest.test_collidedictall__negative_sized_rectsc                 C   s   t dddd}dt ddddf}dt ddddf}dt ddddf}t|||f}|g}dd	 | D }d
d |D }dD ]}	|	rG|}
|}n|}
|}|||	}| ||
 q>dS )zVEnsures collidedictall works correctly with negative sized rect
        args.
        r   rW   r  r   r   r  r  c                 S   r  r   r  r  r   r   r   r  	  r  zRRectTypeTest.test_collidedictall__negative_sized_rects_as_args.<locals>.<dictcomp>c                 S   r  r   r  r  r   r   r   r  	  r  zRRectTypeTest.test_collidedictall__negative_sized_rects_as_args.<locals>.<listcomp>r  Nr  )r   r<   r  r  r  r  r  r  r  r  r  r  r  r   r   r   1test_collidedictall__negative_sized_rects_as_args	  s"   z>RectTypeTest.test_collidedictall__negative_sized_rects_as_argsc              	   C   r  )zAEnsures collidedictall correctly handles invalid dict parameters.r   rW   r  r   r  N)r   rb  r  r_   r`   r  r  r   r   r   (test_collidedictall__invalid_dict_format	  r  z5RectTypeTest.test_collidedictall__invalid_dict_formatc                 C   r  )zCEnsures collidedictall correctly handles dicts with invalid values.r   rW   r  r   N)r   r  r_   r`   r  )r   r<   r  r  r   r   r   .test_collidedictall__invalid_dict_value_format
  r	  z;RectTypeTest.test_collidedictall__invalid_dict_value_formatc                 C   r
  )zAEnsures collidedictall correctly handles dicts with invalid keys.r   rW   r  N)r   rb  r_   r`   r  )r   r<   r  r  r   r   r   ,test_collidedictall__invalid_dict_key_format
  r  z9RectTypeTest.test_collidedictall__invalid_dict_key_formatc              	   C   r  )zXEnsures collidedictall correctly handles invalid use_values
        parameters.
        r   r   Nrn  )r   r_   r`   r  )r   r<   r  r  r  r   r   r   .test_collidedictall__invalid_use_values_format
  s   z;RectTypeTest.test_collidedictall__invalid_use_values_formatc                 C   s   t dddd}d| f}dt ddddf}dt ddddf}d	t d
d
ddf}t||||f}||g}dd | D }dd |D }	dD ]}
|
rO|}|}n|	}|}|j||
d}| || qFdS )z@Ensures collidedictall detects collisions via keyword arguments.r   rW   r  r  r  r  r  ri   r  r  c                 S   r  r   r  r  r   r   r   r  1
  r  z<RectTypeTest.test_collidedictall__kwargs.<locals>.<dictcomp>c                 S   r  r   r  r  r   r   r   r  2
  r  z<RectTypeTest.test_collidedictall__kwargs.<locals>.<listcomp>r  r  Nr  r  r   r   r   test_collidedictall__kwargs!
  s(   
z(RectTypeTest.test_collidedictall__kwargsc                 C   sp   t dddd}t ddddt ddddt ddddg}| ||d t dddddg}| ||d d S )Nr   rW   r6   r  rH  r7   r7   r   r   r   r   r   Zcollidelistr   r"   lfr   r   r   test_collidelist@
  s
   
(zRectTypeTest.test_collidelistc                 C   sr   t dddd}t ddddt ddddt ddddg}| ||d t dddddg}| |j|dd d S )	Nr   rW   r6   r  rH  r'  r  r   r(  r)  r   r   r   test_collidelist__kwargsR
  s
   	(z%RectTypeTest.test_collidelist__kwargsc                 C   s   t dddd}t ddddt ddddt ddddt ddddg}| ||g d t ddddt ddddg}| || d S 	Nr   rW   r  rH  r   r   r   r   r6   ri   r   r   collidelistallr   r)  r   r   r   test_collidelistallc
  s   
z RectTypeTest.test_collidelistallc                 C   sX   t dddd}t ddddt ddddt ddddt ddddg}| ||g  d S )	Nr   rW   p   r6   r  rH  ra  r   )r   r   r1  )r   r"   r*  r   r   r   &test_collidelistall_returns_empty_listz
  s   z3RectTypeTest.test_collidelistall_returns_empty_listc                 C   H   t dddd}g d}| ||g d ddg}| || d S )Nr   rW   r   r   rW   rW   r  r  rW   rW   rH  rH  r   r   r   r   r   r   r/  r6   r6   r   r   ri   ri   r  r  r0  r)  r   r   r   "test_collidelistall_list_of_tuples
  
   z/RectTypeTest.test_collidelistall_list_of_tuplesc                 C   r5  )Nr   rW   )r   r   rW   rW   r  r  rA  ))rH  rH  r@  )rB  r@  r/  )r6   r6   r@  rL  rC  r0  r)  r   r   r   &test_collidelistall_list_of_two_tuples
  r>  z3RectTypeTest.test_collidelistall_list_of_two_tuplesc                 C   sd   t dddd}g dg dg dg dg}| ||g d g dg d	g}| || d S )
Nr   rW   r7  r8  r9  r:  r/  r;  r<  r0  r)  r   r   r   !test_collidelistall_list_of_lists
  s   z.RectTypeTest.test_collidelistall_list_of_listsc                   @      e Zd Zdd ZdS )z%RectTypeTest._ObjectWithRectAttributec                 C   
   || _ d S r   rZ  r!   r   r   r   __init__
     
z.RectTypeTest._ObjectWithRectAttribute.__init__Nr  r  r  rJ  r   r   r   r   _ObjectWithRectAttribute
      rM  c                   @   r  )z-RectTypeTest._ObjectWithCallableRectAttributec                 C   rI  r   Z_rectr!   r   r   r   rJ  
  rK  z6RectTypeTest._ObjectWithCallableRectAttribute.__init__c                 C      | j S r   rO  r   r   r   r   r<   
  s   z2RectTypeTest._ObjectWithCallableRectAttribute.rectN)r  r  r  rJ  r<   r   r   r   r    _ObjectWithCallableRectAttribute
  r  rR  c                   @   s    e Zd Zdd Zedd ZdS )z$RectTypeTest._ObjectWithRectPropertyc                 C   rI  r   rO  r!   r   r   r   rJ  
  rK  z-RectTypeTest._ObjectWithRectProperty.__init__c                 C   rP  r   rO  rQ  r   r   r   r<   
  s   z)RectTypeTest._ObjectWithRectProperty.rectN)r  r  r  rJ  propertyr<   r   r   r   r   _ObjectWithRectProperty
  s    rT  c                   @   rH  )z-RectTypeTest._ObjectWithMultipleRectAttributec                 C   s   || _ || _|| _d S r   )rect1r  rect3r  r   r   r   rJ  
  s   
z6RectTypeTest._ObjectWithMultipleRectAttribute.__init__NrL  r   r   r   r    _ObjectWithMultipleRectAttribute
  rN  rW  c              
   C      t dddd}| t dddd| t dddd| t dddd| t ddddg}| ||g d | t dddd| t ddddg}| || d S r.  )r   rM  r   r1  r   r)  r   r   r   6test_collidelistall_list_of_object_with_rect_attribute
     zCRectTypeTest.test_collidelistall_list_of_object_with_rect_attributec              
   C   rX  r.  )r   rR  r   r1  r   r)  r   r   r   ?test_collidelistall_list_of_object_with_callable_rect_attribute
  rZ  zLRectTypeTest.test_collidelistall_list_of_object_with_callable_rect_attributec                 C   s   t dddd}| | t dddd| | t dddd| | t dddd| | t ddddg}| ||g d | t dddd| t ddddg}| || d S r.  )r   rR  rM  r   r1  r   r)  r   r   r   Ztest_collidelistall_list_of_object_with_callable_rect_returning_object_with_rect_attribute
  s&   zgRectTypeTest.test_collidelistall_list_of_object_with_callable_rect_returning_object_with_rect_attributec              
   C   rX  r.  )r   rT  r   r1  r   r)  r   r   r   5test_collidelistall_list_of_object_with_rect_property  rZ  zBRectTypeTest.test_collidelistall_list_of_object_with_rect_propertyc                 C   s   t dddd}t ddddt ddddt ddddt ddddg}| ||g d t ddddt ddddg}| |j|d	 d S )
Nr   rW   r  rH  r   r/  r6   ri   r  r0  r)  r   r   r   test_collidelistall__kwargs  s   z(RectTypeTest.test_collidelistall__kwargsc              
   C      t dddd}t ddddt ddddg}| t ddddt ddddt d	d
dd| t ddddt ddddt d	d
ddg}|| |j|d d |j|dd d | t|j| d S )Nr   rW   r   r   r   ri   r   r  r7   r9   ,    keyc                 S   rP  r   rU  or   r   r   r   ;      z@RectTypeTest.test_collideobjects_call_variants.<locals>.<lambda>)r   rW  collideobjectsr_   r`   r   r"   r  objectsr   r   r   !test_collideobjects_call_variants+     $$

z.RectTypeTest.test_collideobjects_call_variantsc                 C   s  t dddd}t ddddt ddddt ddddg| t dddd| t dddd| t ddddg| t dddd| t dddd| t ddddg| t dddd| t dddd| t ddddg| | t dddd| | t dddd| | t ddddgg dg dg dg d	g d
gt dddd| t ddddd
gg	}|D ])}| j|d jjd ||}| ||d  W d    n1 sw   Y  qt ddddt ddddg| t dddd| t ddddg| t dddd| t ddddg| t dddd| t ddddg| | t dddd| | t ddddgddgddgg dg dgt ddddg dgg	}|D ]*}| j|d jjd d ||}| |d  W d    n	1 sw   Y  q\d S )Nr   rW   r6   r  r   )r;  r8  r   r   r   r   )rD  rB  )r   r   r@  r;  r8  rm  r   typer7   r'  rD  ))r7   r7   rn  rp  r  )	r   rM  rT  rR  rw  	__class__r  rh  r   )r   r"   types_to_testr*  r   r+  r   r   r   test_collideobjects_without_key>  s   &&

z,RectTypeTest.test_collideobjects_without_keyc                 C   s  t dddd}| t ddddt ddddt dddd| t ddddt ddddt dddd| t ddddt ddddt dd	dd| t d
d
ddt ddddt ddddg}| |j|dd d|d  | |j|dd d|d  | |j|dd d|d  | t ddddt ddddt d
dd
d
| t ddddt ddddt dd
d
d
g}| |j|dd d | |j|dd d | |j|dd d d S )Nr   rW   r  r   rQ  rH  r7   S   r   r   c                 S   rP  r   rd  re  r   r   r   r     rg  z^RectTypeTest.test_collideobjects_list_of_object_with_multiple_rect_attribute.<locals>.<lambda>rb  r   c                 S   rP  r   r  re  r   r   r   r     rg  c                 S   rP  r   rV  re  r   r   r   r     rg  r6   r  ri   ra  c                 S   rP  r   rd  re  r   r   r   r     rg  c                 S   rP  r   rx  re  r   r   r   r     rg  c                 S   rP  r   ry  re  r   r   r   r     rg  )r   rW  r   rh  r   collideobjectsallr   r"   thingsr+  r   r   r   ?test_collideobjects_list_of_object_with_multiple_rect_attribute  s6   $$$$$$zLRectTypeTest.test_collideobjects_list_of_object_with_multiple_rect_attributec              
   C   r_  )Nr   rW   r   r   r   ri   r   r  r7   r9   r`  ra  rb  c                 S   rP  r   rd  re  r   r   r   r     rg  zCRectTypeTest.test_collideobjectsall_call_variants.<locals>.<lambda>)r   rW  r{  r_   r`   ri  r   r   r   $test_collideobjectsall_call_variants  rl  z1RectTypeTest.test_collideobjectsall_call_variantsc                 C   sB  t dddd}t ddddt ddddt ddddt ddddgg dg dg dg d	g d
g dg| t dddd| t dddd| t dddd| t ddddg| t dddd| t dddd| t dddd| t ddddg| | t dddd| | t dddd| | t dddd| | t ddddg| t dddd| t dddd| t dddd| t ddddgg}|D ]3}| j|d jjd |j|d d}| ||d |d |d g W d    n	1 sw   Y  qt ddddt ddddgddgddgg dg dg| t dddd| t ddddg| t dddd| t ddddg| t dddd| t ddddg| t dddd| t ddddgg}|D ])}| j|d jjd d ||}| 	| W d    n	1 sw   Y  qud S )Nr   rW   r  rH  r   r6  r?  r7  r8  r9  r:  r   ro  rb  r   r6   ri   r;  r<  rD  rE  rq  )
r   rM  rR  rT  rw  rr  r  r{  r   r   )r   r"   rs  r}  r   r+  r   r   r   test_collideobjectsall  s   : 
z#RectTypeTest.test_collideobjectsallc                 C   s  t dddd}| t ddddt ddddt dddd| t ddddt ddddt dddd| t ddddt ddddt dd	dd| t d
d
ddt ddddt ddddg}| |j|dd d|d |d |d g | |j|dd d|d |d g | |j|dd d|d |d g | t ddddt ddddt d
dd
d
| t ddddt ddddt dd
d
d
g}| |j|dd d | |j|dd d | |j|dd d d S )Nr   rW   r  ru  r   rQ  rH  r7   rv  r   rw  r   c                 S   rP  r   rd  re  r   r   r   r   7  rg  zaRectTypeTest.test_collideobjectsall_list_of_object_with_multiple_rect_attribute.<locals>.<lambda>rb  r   c                 S   rP  r   rx  re  r   r   r   r   ;  rg  c                 S   rP  r   ry  re  r   r   r   r   >  rg  r6   r  rz  ri   ra  c                 S   rP  r   rd  re  r   r   r   r   I  rg  c                 S   rP  r   rx  re  r   r   r   r   J  rg  c                 S   rP  r   ry  re  r   r   r   r   K  rg  )r   rW  r   r{  r   r|  r   r   r   Btest_collideobjectsall_list_of_object_with_multiple_rect_attribute%  sD   $$$$$$zORectTypeTest.test_collideobjectsall_list_of_object_with_multiple_rect_attributec                 C   sT   t dddd}t dddd}||}| || ||}| || d S )NrW   r   rH  )r   fitr   r   )r   r"   r   r+  f2r   r   r   test_fitM  s   


zRectTypeTest.test_fitc                 C   s&   t dddd}| }| || d S )Nr   r   rW   ri   )r   rb  r   r  r   r   r   	test_copya  s   zRectTypeTest.test_copyc                 C   st  t dddd}| |d d | |d d | |d d | |d d | |d d | |d d | |d d | t|jd	 | t|jd
 | |dd ddg | |dd g d | |dd g d | |d d  g d | |d g d | |ddd ddg | |ddd ddg | |dd d g d | t|jd  d S )Nr   r   r   r   r   r   rR  r   r  rQ  r  r^   .)r   r   r   r   )r   r   r_   
IndexError__getitem__r`   r!   r   r   r   test_subscriptf  s&   zRectTypeTest.test_subscriptc                 C   s  t dddd}d|d< | |g d | t|jd d | |g d | t|jdd | |g d | t|jdd | |g d | t|jdd | |g d d|d< | |g d d	|d
< | |g d d|d< | |g d d|d< | |g d d|dd
< | |g d d|d< | |g d d|d d < | |g d d|d d < | |g d ||d d d< | |g d d S )Nr   r  . r   rQ  rW   )rW   r   r   r   r  r   )rW   r   r   r  ra  r   )rW   r   r   ra  r7   r   )r7   r   r   ra  r   )r7   r   r   ra  )r   r   r   r   	   )r  r  r  r  )r  r         )r  r  r   r  )r   r   r_   r`   __setitem__r  r!   r   r   r   test_ass_subscript{  s:   zRectTypeTest.test_ass_subscriptc                 C   s   t dddd}| t |d= W d    n1 sw   Y  | t |dd= W d    n1 s4w   Y  | t |d= W d    d S 1 sMw   Y  d S )Nr   r   .)r   r_   r`   r!   r   r   r   test_ass_subscript_deletion  s   "z(RectTypeTest.test_ass_subscript_deletionc                 C   s2   t dddd}| t|t | t|t d S Nr  r  K   r   )r   r   
isinstancer   r   r   r!   r   r   r   test_collection_abc  s   z RectTypeTest.test_collection_abcN)r  r  r  r   r#   r&   r5   r?   rK   rN   rR   rS   rT   rV   rY   rc   rg   rj   rk   rl   rm   rn   ro   rs   ru   rv   rw   rx   ry   r|   r}   r~   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r  r  r'  r+  r1  r4  r6  r8  r@  rA  rD  rK  rP  rS  rU  rW  r]  r^  r_  rd  re  rk  rl  unittestZskipIfIS_PYPYr  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r   r  r  r  r  r  r  r  r  r  r  r  r   r!  r"  r#  r$  r%  r&  r,  r-  r2  r4  r=  rF  rG  rM  rR  rT  rW  rY  r[  r\  r]  r^  rk  rt  r~  r  r  r  r  r  r  r  r  r  r   r   r   r   r      s~   
!$

/4#7	
ni


#" %1	 %3R!a(r   c                   @   sd   e Zd ZG dd de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S )SubclassTestc                       s   e Zd Z fddZ  ZS )zSubclassTest.MyRectc                    s"   t tj| j|i | d| _d S )NT)superr  MyRectrJ  an_attribute)r   r   kwdsrr  r   r   rJ    s   
zSubclassTest.MyRect.__init__)r  r  r  rJ  __classcell__r   r   r  r   r    s    r  c                 C   sJ   |  dddd}| |j | }| t|| j  | tt|d d S Nr   r   rW   ri   r  )r  r   r  rb  r  r_   rf   ry  r   mr1Zmr2r   r   r   r    s
   zSubclassTest.test_copyc                 C   sN   |  dddd}| |j |dd}| t|| j  | tt|d d S r  )r  r   r  rg  r  r_   rf   ry  r  r   r   r   rk    
   zSubclassTest.test_movec                 C   sN   |  dddd}| |j |dd}| t|| j  | tt|d d S )Nr   r   rW   ri   r   r  )r  r   r  r   r  r_   rf   ry  r  r   r   r   test_inflate  r  zSubclassTest.test_inflatec                 C   sV   |  dddd}| |j |tdddd}| t|| j  | tt|d d S )Nr   r   r  rW   r  )	r  r   r  r  r   r  r_   rf   ry  r  r   r   r   r    
   zSubclassTest.test_clampc                 C   sV   |  dddd}| |j |tdddd}| t|| j  | tt|d d S )Nr   r   r   r   r   r  )	r  r   r  r	  r   r  r_   rf   ry  r  r   r   r   r    r  zSubclassTest.test_clipc                 C   sV   |  dddd}| |j |tdddd}| t|| j  | tt|d d S )Nr   r   rR  r  )	r  r   r  r  r   r  r_   rf   ry  r  r   r   r   r    r  zSubclassTest.test_unionc                 C   sd   |  dddd}| |j |tddddtddddg}| t|| j  | tt|d d S )Nr   r   rR  r   r  )	r  r   r  r  r   r  r_   rf   ry  r  r   r   r   r    s
   "zSubclassTest.test_unionallc                 C   sV   |  dddd}| |j |tdddd}| t|| j  | tt|d d S )NrW   r   rH  r  )	r  r   r  r  r   r  r_   rf   ry  r  r   r   r   r    r  zSubclassTest.test_fitc                 C   s4   |  dddd}| t|t | t|t d S r  )r  r   r  r   r   r   )r   r  r   r   r   r    s   z SubclassTest.test_collection_abcN)r  r  r  r   r  r  rk  r  r  r  r  r  r  r  r   r   r   r   r    s    r  __main__)r>  r  collections.abcr   r   platformr	   Zpygamer   r   Zpygame.testsr   python_implementationr  r   r   r   ZTestCaser   r  r  mainr   r   r   r   <module>   sR                             /D