o
    ~¨Êhs  ã                   @   s  d dl mZ d dlZd dlZzd dlZW n ey   dZY nw zd dlZW n ey1   dZY nw d dlmZ d dl	m
Z
mZ d dlmZ d dlmZ G dd„ deƒZe edu d	¡G d
d„ deeƒƒZe edu d¡G dd„ deeƒƒZG dd„ deeƒZG dd„ deeƒZdS )é    )Úwith_statementN)Úoverride_settings)ÚSOURCE_HUNKÚSOURCE_FILE)Úsettings)ÚCompressorTestCasec                       s$   e Zd Z‡ fdd„Zdd„ Z‡  ZS )ÚParserTestCasec                    s,   | j | jd�| _| j ¡  tt| ƒ ¡  d S )N)ÚCOMPRESS_PARSER)r   Ú
parser_clsr   Ú	__enter__Úsuperr   ÚsetUp©Úself©Ú	__class__© úO/var/www/html/env/lib/python3.10/site-packages/compressor/tests/test_parsers.pyr      s   
zParserTestCase.setUpc                 C   s   | j  d d d ¡ d S ©N)r   Ú__exit__r   r   r   r   ÚtearDown   s   zParserTestCase.tearDown)Ú__name__Ú
__module__Ú__qualname__r   r   Ú__classcell__r   r   r   r   r      s    r   zlxml not foundc                   @   ó   e Zd ZdZdS )ÚLxmlParserTestszcompressor.parser.LxmlParserN©r   r   r   r
   r   r   r   r   r       s    r   zhtml5lib not foundc                   @   sF   e Zd ZdZdd„ Zdd„ Zedd�dd	„ ƒZed
dd�dd„ ƒZdS )ÚHtml5LibParserTestsz compressor.parser.Html5LibParserc                 C   sú   | j  ¡ }ttj tjdd¡ddddddœf}|  ||d	 d d
… |d	 d
 j	|d	 d
 j
f ¡ tdd df}|  ||d d d
… | j j |d d
 ¡f ¡ ttj tjdd¡ddddddœf}|  ||d d d
… |d d
 j	|d d
 j
f ¡ d S )NÚcssúone.cssúcss/one.cssz"{http://www.w3.org/1999/xhtml}linkÚ
stylesheetz/static/css/one.cssztext/css)ÚrelÚhrefÚtyper   é   úp { border:5px solid green;}ú;<style type="text/css">p { border:5px solid green;}</style>é   útwo.cssúcss/two.cssz/static/css/two.cssé   ©Úcss_nodeÚsplit_contentsr   ÚosÚpathÚjoinr   ÚCOMPRESS_ROOTÚassertEqualÚtagÚattribr   ÚparserÚelem_str©r   ÚsplitÚout0Úout1Úout2r   r   r   Útest_css_split+   s>   
ÿû ÿüÿÿû ÿz"Html5LibParserTests.test_css_splitc                 C   sÆ   | j  ¡ }ttj tjdd¡dddddœd f}|  ||d d d	… |d d	 j	|d d	 j
|d d	 jf ¡ td
d dddid
f}|  ||d d d	… |d d	 j	|d d	 j
|d d	 jf ¡ d S )NÚjszone.jsz	js/one.jsz${http://www.w3.org/1999/xhtml}scriptz/static/js/one.jsztext/javascript)Úsrcr%   r   r&   zobj.value = "value";r%   r)   )Újs_noder/   r   r0   r1   r2   r   r3   r4   r5   r6   Útextr   )r   r:   r;   r<   r   r   r   Útest_js_splitJ   s.   
ú þú þz!Html5LibParserTests.test_js_splitF©ÚCOMPRESS_ENABLEDc                 C   ó    |   t| jƒt| j ¡ ƒ¡ d S r   )r4   Úlenr   r.   Úoutputr   r   r   r   Útest_css_return_if_offc   s    z*Html5LibParserTests.test_css_return_if_offr   )ÚCOMPRESS_PRECOMPILERSrE   c                 C   rF   r   )r4   rG   r?   rA   rH   r   r   r   r   Útest_js_return_if_offl   s    z)Html5LibParserTests.test_js_return_if_offN)	r   r   r   r
   r>   rC   r   rI   rK   r   r   r   r   r   %   s    

r   c                   @   s*   e Zd ZdZdd„ Zedd�dd„ ƒZdS )	ÚBeautifulSoupParserTestsz%compressor.parser.BeautifulSoupParserc                 C   sê   | j  ¡ }ttj tjdd¡dd d f}|  ||d d d… |d d j	|d d j
f ¡ tdd df}|  ||d d d… | j j |d d ¡f ¡ ttj tjdd	¡d
d d f}|  ||d d d… |d d j	|d d j
f ¡ d S )Nr   r    r!   r   r&   r'   r(   r)   r*   r+   r,   r-   r9   r   r   r   r>   w   s6   
û ÿüÿû ÿz'BeautifulSoupParserTests.test_css_splitFrD   c                 C   s,   | j  ¡  dd¡}|  t| jƒt|ƒ¡ d S )Nz"/>z" />)r.   rH   Úreplacer4   rG   r   )r   Úfixed_outputr   r   r   rI   ”   s   z/BeautifulSoupParserTests.test_css_return_if_offN)r   r   r   r
   r>   r   rI   r   r   r   r   rL   r   s
    rL   c                   @   r   )ÚHtmlParserTestszcompressor.parser.HtmlParserNr   r   r   r   r   rO   œ   s    rO   )Ú
__future__r   r0   ÚunittestÚlxmlÚImportErrorÚhtml5libÚdjango.test.utilsr   Úcompressor.baser   r   Úcompressor.confr   Úcompressor.tests.test_baser   Úobjectr   ÚskipIfr   r   rL   rO   r   r   r   r   Ú<module>   s0    ÿÿ
L*