o
    PZhM                     @   s  d dl Z d dlZd dlZd dlZd dlZedZdd Zdd Z	e j
e j
eZe j
e j
ed  d  Zer>dZndZd	d
 Zdd Zdd Zej
d ed dd Zdd Zdd Zd(ddZdd Zdd Zdd Zdd  Zd!d" Zd#d$ ZG d%d& d&ej Z!d'd Z"dS ))    Nzpygame.tests.c                 C   s   |   S )zKConvert row of bytes to string.  Expects `row` to be an
    ``array``.
    )tobytes)row r   O/var/www/auris/lib/python3.10/site-packages/pygame/tests/test_utils/__init__.pytostring   s   r   c                   C   s   t  d S )N   )sysexc_infor   r   r   r   geterror   s   r
   teststestc                 C   s   t jt jt| S N)ospathnormpathjoin	trunk_dir)Zrelativer   r   r   trunk_relative_path!      r   c                 C   s   t tjtd| S )NZfixtures)r   r   r   r   test_moduler   r   r   r   fixture_path%   s   r   c                 C   s   t tjd| S )NZexamples)r   r   r   r   r   r   r   r   example_path)   s   r   .c                   C   s   t  S r   )tempfilemkdtempr   r   r   r   get_tmp_dir3   s   r   c                 C   s"   t d| d d  dkS )N
 z (y/n): y)inputrstriplowerstrip)qr   r   r   question:   s   "r%   c                 C   s   t d| d dS )Nr   r   z (press enter to continue): )r    r!   )pr   r   r   prompt>   r   r'      c                 C   s   | |k r|S | |kr|S | S r   r   )valueminimummaximumr   r   r   rgba_betweenE   s
   r,   c                    s&   g g | D ]} fdd|D  q S )z

    Recipe 496807 from ActiveState Python CookBook

    Non recursive technique for getting all possible combinations of a sequence
    of sequences.

    c                    s    g | ]} D ]}||g qqS r   r   ).0r   irr   r   
<listcomp>Z   s     z combinations.<locals>.<listcomp>r   )Zseqsxr   r/   r   combinationsN   s   
r3   c                 c   sF    t | D ]}t |D ]}||fttt||||| ffV  qqdS )a  

    Yields a pt and corresponding RGBA tuple, for every (width, height) combo.
    Useful for generating gradients.

    Actual gradient may be changed, no tests rely on specific values.

    Used in transform.rotate lossless tests to generate a fixture.

    N)rangetuplemapr,   )widthheightltr   r   r   gradient^   s   &r;   c                 c   s8    t | j| jD ]}t | j| jD ]}||fV  qqd S r   r4   leftrighttopbottom)rectr9   r:   r   r   r   rect_area_ptso   s   rB   c                 #   s     fddt  j jD  fddt  jd  jD  fddt  jd  jd dD  fddt  jd  jdD f}|D ]}|E d	H  qCd	S )
a  

    Returns pts ((L, T) tuples) encompassing the perimeter of a rect.

    The order is clockwise:

          topleft to topright
         topright to bottomright
      bottomright to bottomleft
       bottomleft to topleft

    Duplicate pts are not returned

    c                    s   g | ]}| j fqS r   )r?   r-   r9   rA   r   r   r1          z&rect_perimeter_pts.<locals>.<listcomp>c                    s   g | ]	} j d  |fqS r   )r>   r-   r:   rD   r   r   r1          r   c                    s   g | ]	}| j d  fqS rF   )r@   rC   rD   r   r   r1      rH      c                    s   g | ]} j |fqS r   )r=   rG   rD   r   r   r1      rE   Nr<   )rA   Zclock_wise_from_top_leftliner   rD   r   rect_perimeter_ptsu   s   $ rL   c                 C   s,   | j r| j d | jfgng | j| j| jg S )z

     Returns topleft outerbound if possible and then the other pts, that are
     "exclusive" bounds of the rect

    ?------O
     |RECT|      ?|0)uterbound
     |----|
    O      O

    r   )r=   r?   ZtoprightZ
bottomleftZbottomrightrD   r   r   r   rect_outer_bounds   s
   rM   c                 C   s.   t | }| ddd  D ]}t||}q|S )Nr   r   )
__import__splitgetattr)modulemnr   r   r   import_submodule   s   rT   c                       s    e Zd ZdZ fddZ  ZS )SurfaceSubclassz)A subclassed Surface to test inheritance.c                    s   t  j|i | d| _d S )NT)super__init__Ztest_attribute)selfargskwargs	__class__r   r   rW      s   
zSurfaceSubclass.__init__)__name__
__module____qualname____doc__rW   __classcell__r   r   r[   r   rU      s    rU   c                  C   sp   t dddd} t| g dksJ ttt| dksJ t dddd} tt| g dks2J td dS )	z(

    Lightweight test for helpers

    r   
   ))rb   r   )r   rb   )rb   rb   d      ))r   r   )r   r   )rI   r   )rI   r   )rI   rI   )r   rI   )r   rI   )r   r   z	Tests: OKN)pygameZRectrM   lenlistrB   rL   printr/   r   r   r   r      s   )r   r(   )#r   re   r   r   timer]   
startswithZis_pygame_pkgr   r
   r   dirnameabspath__file__Zthis_dirrO   r   r   r   r   r   insertr   r%   r'   r,   r3   r;   rB   rL   rM   rT   ZSurfacerU   r   r   r   r   r   <module>   s:    

	