3
3P	'                 @   s  d Z ddlmZ ddlZddlZddlZddlmZmZm	Z	 dd Z
ejjdd
d eefD dd Zejjdeegdd Zejjd dd eefD dd Zdd Zejjd!dd eefD dd Zejjd"dd eefD dd Zejjd#dd eefD dd ZdS )$z
    Tests for the tokenizer
    -----------------------

    :copyright: (c) 2012 by Simon Sapin.
    :license: BSD, see LICENSE for more details.
    )unicode_literalsN)python_tokenize_flatcython_tokenize_flatregroupc               C   s$   t jjdrd S td k	s tdd S )NZTINYCSS_SKIP_SPEEDUPS_TESTSzCython speedups are not installed, related tests will be skipped. Set the TINYCSS_SKIP_SPEEDUPS_TESTS environment variable if this is expected (eg. on PyPy).)osenvirongetr   AssertionError r
   r
   \/var/www/html/enquirykeeper_venv/lib/python3.6/site-packages/tinycss/tests/test_tokenizer.pytest_speedups   s    
r   tokenize
css_sourceexpected_tokensc          0   C   s  g | ]}d g fddadbdcgfddddegfddfdgdhdidjdkgfddldmdndodqdrdsdtdug	fd!dvgfd$dwgfd%dxgfd'dygfd)dzd{d|d}gfd.d~gfd0dgfd1dgfd2dgfd4dgfd6dgfd7dgfd8dddgfd:dgfd<dgfd>dgfd?dgfdBdgfdCdgfdFdgfdGdgfdJdgfdKdgfdNdgfdPdgfdQdgfdRdgfdSdgfdTdgfdUdgfdVdgfdWdgfdXdgfdZdgfd\ddgfd^ddddgfg)D ]}|f| qqS ) zred -->IDENTredS CDC-->zred-->red--DELIM>z1p[example="\
foo(int x) {\
    this.x = x;\
}\
"]p[example=STRINGfoo(int x) {    this.x = x;}]z42 .5 -4pX 1.25em 30%INTEGER*   NUMBER      ?	DIMENSION   px      ?em
PERCENTAGE   %zurl(foo.png)URIfoo.pngzurl("foo.png") /* Comment with a \ backslash */COMMENTz"Lorem\
Ipsum"
LoremIpsumzLorem\
IpsumLorem\
Ipsumz"Lore\m Ipsum"Lorem Ipsumz"Lorem \49psum"z"Lorem \49 psum"z"Lorem\"Ipsum"Lorem"Ipsumz"Lorem\\Ipsum"Lorem\Ipsumz"Lorem\5c Ipsum"zLorem\+IpsumLorem+Ipsum+zurl(foo\).png)foo).pngz\26 B&Bz\&Bz@\26	B	ATKEYWORD@&Bz@\&Bz#\26
BHASH#&Bz#\&Bz\26
B(FUNCTION&B(z\&B(z12.5\000026B      )@&bz12.5\0000263B&3bz12.5\&Bz"\26 B"z
'\000026B'z"\&B"zurl("\26 B")z
url(\26 B)z
url("\&B")zurl(\&B)zLorem\110000Ipsum   Lorem�Ipsum"Lorem\26IpsumLorem&Ipsumz"Lorem\26Ipsum

BAD_STRINGz"Lorem\26Ipsum
dolor" sitdolor sit)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%   rL   r'   )r   r   )r%   r(   r)   )r   r   )r*   r+   r,   )r-   r.   )r-   r.   )r0   r/   )r   r1   )r   r2   )r   r3   )r   r4   )r   r5   )r   r6   )r   r6   )r   r6   )r   r7   )r   r8   )r   r8   )r   r9   )r   r2   )r   r:   )r   r5   )r-   r;   )r   r<   )r   r<   )r=   r>   )r=   r>   )r?   r@   )r?   r@   )rA   rB   )rA   rB   )r%   rC   rD   )r%   rC   rE   )r%   rC   rD   )r   r<   )r   r<   )r   r<   )r-   r<   )r-   r<   )r-   r<   )r-   r<   )r   rF   )r   rH   )rI   rG   )r   r4   )rI   rG   )r   r4   )r   rJ   )r   rK   r
   ).0r   	test_datar
   r
   r   
<listcomp>    sz   
rO   c             C   sn   | d krt jd |g}tjd dk r6|j|jd x2|D ]*}| |dd}dd |D }||ks<tq<W d S )	NzSpeedups not availabler      asciiF)ignore_commentsc             S   s.   g | ]&}|j |jf|jd kr f n|jf qS )N)typevalueZunit)rM   tokenr
   r
   r   rO      s   ztest_tokens.<locals>.<listcomp>)pytestskipsysversion_infoappendencoder	   )r   r   r   sourcestokensresultr
   r
   r   test_tokens   s    `

r_   c             C   sd   | dkrt jd d}| |dd}dd |D }|d d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1gks`tdS )2z5Test the reported line/column position of each token.NzSpeedups not availablez=/* Lorem
ipsum */a {
    color: red;	content: "dolor\sit" }F)rR   c             S   s   g | ]}|j |j|jfqS r
   )rS   linecolumn)rM   rU   r
   r
   r   rO      s    z"test_positions.<locals>.<listcomp>r0      r      	   r   rP   {r&      :
         ;               r      }   )r0   rb   rb   )r   rc   rd   )r   rP   rb   )r   rP   rc   )re   rP   rP   )r   rP   r&   )r   r&   rf   )rg   r&   rh   )r   r&   ri   )r   r&   rj   )rk   r&   rl   )r   r&   rm   )r   r&   rn   )rg   r&   ro   )r   r&   rp   )r   r&   rq   )r   rf   rf   )rr   rf   rs   )rV   rW   r	   )r   cssr]   r^   r
   r
   r   test_positions   s    
ru   c             C   s   g | ]}d g fddddgfdd	d
dddgfgfddd dd!gfgfgfgfdd"dd#dd$gfgfgfdd%dd&dd'd(d)gfgfgfdd*dd+dd,gfd-gfgfgD ]}|f| qqS ).r   zLorem\26 "i\psum"4pxr   Lorem&r   ipsumr%   r&   znot([[lorem]]{ipsum (42)})rA   notr   loremre   r   r   (r!   r"   za[b{"dabdza[b{d]e}r    eza[b{d}e])r   rv   )r   rw   )r%   r&   )r   ry   )r   rw   )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
   )rM   r   rN   r
   r
   r   rO      sF   

c             C   s>   | d krt jd t| |dd}tt|}||ks:td S )NzSpeedups not availableF)rR   )rV   rW   r   listjsonifyr	   )r   r   r   r]   r^   r
   r
   r   test_token_grouping   s
    <
r   c             c   sd   x^| D ]V}|j dkr0|j |jtt|jfV  q|jrN|j tt|jfV  q|j |jfV  qW dS )z3Turn tokens into "JSON-compatible" data structures.rA   N)rS   Zfunction_namer   r   contentZis_containerrT   )r]   rU   r
   r
   r   r      s    

r   rR   c          
   C   sJ   g | ]B}d ddddddgfdgfdddddgfgfgD ]}|f| q6qS )Fr0   /* lorem */r   r   r   rw   r   rJ   	/* sit */BAD_COMMENT/* ametT)r0   r   )r   r   )r   rw   )r   rJ   )r0   r   )r   r   )r   r   )r   rw   )r   rJ   r
   )rM   r   rN   r
   r
   r   rO      s   c             C   s@   | d krt jd d}t| ||}tt|}||ks<td S )NzSpeedups not availablez(/* lorem */ ipsum[dolor/* sit */]/* amet)rV   rW   r   r   r   r	   )r   rR   r   r   r]   r^   r
   r
   r   test_comments   s    
r   c             C   s   g | ]}dD ]}||fqqS )1p[example="\
foo(int x) {\
    this.x = x;\
}\
"]"Lorem\26Ipsum
dolor" sit=/* Lorem
ipsum */a {
    color: red;	content: "dolor\sit" }not([[lorem]]{ipsum (42)})a[b{d]e}a[b{"d)r   r   r   r   r   r   r
   )rM   r   rN   r
   r
   r   rO     s        c             C   s\   | d krt jd xDtdd gD ]4}|| |dd}djdd |D }||ks tq W d S )	NzSpeedups not availablec             S   s   | S )Nr
   )xr
   r
   r   <lambda>"  s    z*test_token_serialize_css.<locals>.<lambda>F)rR   r   c             s   s   | ]}|j  V  qd S )N)Zas_css)rM   rU   r
   r
   r   	<genexpr>$  s    z+test_token_serialize_css.<locals>.<genexpr>)rV   rW   r   joinr	   )r   r   Z_regroupr]   r^   r
   r
   r   test_token_serialize_css  s    
r   c             C   s   g | ]}dD ]}||fqqS )(8, foo, [z])[8, foo, (z)]{8, foo, [z]}func(8, foo, [z]))r   r   r   r   r
   )rM   r   rN   r
   r
   r   rO   )  s   c             C   sT   | d krt jd tt| |}t|dks2t|d }d}t|j|ksPtd S )NzSpeedups not availablerb   r      )rV   rW   r   r   lenr	   r   )r   r   r]   rU   Zexpected_lenr
   r
   r   test_token_api(  s    
r   )r   r   r   )r   r   r   )r   rR   r   )r   r   )r   r   )__doc__
__future__r   rX   r   rV   Ztinycss.tokenizerr   r   r   r   ZmarkZparametrizer_   ru   r   r   r   r   r   r
   r
   r
   r   <module>   s0   	oA