o
    ¼>h)  ã                   @   sb   d Z ddlmZ ddlmZmZmZmZ G dd„ dejƒZ	G dd„ dejƒZ
G dd	„ d	ejƒZd
S )z!
Tests for L{twisted.web._abnf}.
é    )Úunittest)Ú_decintÚ_hexintÚ_ishexdigitsÚ_istokenc                   @   s$   e Zd ZdZddd„Zddd„ZdS )	ÚIsTokenTestsz:
    Test the L{twisted.web._abnf._istoken} function.
    ÚreturnNc                 C   ó   dD ]	}|   t|ƒ¡ qd S )N)s   GETs   Cache-Controló   &)Ú
assertTruer   ©ÚselfÚb© r   úz/var/www/vedio/testing/chatpythonscript.ninositsolution.com/env/lib/python3.10/site-packages/twisted/web/test/test_abnf.pyÚtest_ok   ó   ûzIsTokenTests.test_okc                 C   r	   )N)ó    ó    s   a b)ÚassertFalser   r   r   r   r   Útest_bad   r   zIsTokenTests.test_bad©r   N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r   r   r      s    
r   c                   @   sB   e Zd ZdZddd„Zddd„Zddd	„Zdd
d„Zddd„ZdS )ÚDecintTestsz9
    Test the L{twisted.web._abnf._decint} function.
    r   Nc                 C   sD   |   dtdƒ¡ |   dtdƒ¡ |   dtdƒ¡ |   dtdƒ¡ dS )	zF
        Given a decimal digits, L{_decint} return an L{int}.
        é   ó   1é
   ó   10i(#  s   9000s   0009000N©ÚassertEqualr   ©r   r   r   r   Ú
test_valid'   s   zDecintTests.test_validc                 C   s4   |   dtdƒ¡ |   dtdƒ¡ |   dtdƒ¡ dS )zL
        L{_decint} decodes integers embedded in linear whitespace.
        é{   s    123s   123		s    	 123   	  Nr!   r#   r   r   r   Útest_validWhitespace0   ó   z DecintTests.test_validWhitespacec                 C   ó   |   ttd¡ dS )zL
        L{_decint} rejects a number with a leading C{+} character.
        s   +1N©ÚassertRaisesÚ
ValueErrorr   r#   r   r   r   Útest_invalidPlus8   ó   zDecintTests.test_invalidPlusc                 C   r(   )zL
        L{_decint} rejects a number with a leading C{-} character.
        s   -1Nr)   r#   r   r   r   Útest_invalidMinus>   r-   zDecintTests.test_invalidMinusc                 C   s.   |   ttd¡ |   ttd¡ |   ttd¡ dS )zP
        L{_decint} rejects a number embedded in non-linear whitespace.
        s   1s   1s   1Nr)   r#   r   r   r   Útest_invalidWhitespaceD   s   z"DecintTests.test_invalidWhitespacer   )	r   r   r   r   r$   r&   r,   r.   r/   r   r   r   r   r   "   s    

	

r   c                   @   s<   e Zd ZdZdZddd„Zddd„Zdd	d
„Zddd„ZdS )ÚHexHelperTestszU
    Test the L{twisted.web._abnf._hexint} and L{_ishexdigits} helper functions.
    )r   s   0x1234s   fedss   -123+123r   Nc                 C   s   dD ]
}|   dt|ƒ¡ qdS )zr
        L{_ishexdigits()} returns L{True} for nonempy bytestrings containing
        hexadecimal digits.
        )r    s   abcdefs   AB1234s   feds	   123467890TN)ÚassertIsr   ©r   Úsr   r   r   Ú
test_isHexT   s   ÿzHexHelperTests.test_isHexc                 C   s4   |   dtdƒ¡ |   dtdƒ¡ |   dtdƒ¡ dS )zK
        L{_hexint()} returns the integer equivalent of the input.
        r   ó   aé   r    i#Ñ¼
s   abCD123N)r"   r   r#   r   r   r   Útest_decodes\   r'   zHexHelperTests.test_decodesc                 C   s    | j D ]
}|  dt|ƒ¡ qdS )z
        L{_ishexdigits()} returns L{False} for bytestrings that don't contain
        hexadecimal digits, including the empty string.
        FN)Ú
badStringsr1   r   r2   r   r   r   Útest_isNotHexd   s   
ÿzHexHelperTests.test_isNotHexc                 C   s   | j D ]	}|  tt|¡ qdS )zb
        L{_hexint()} raises L{ValueError} for bytestrings that can't
        be decoded.
        N)r8   r*   r+   r   r2   r   r   r   Útest_decodeNotHexl   s   
ÿz HexHelperTests.test_decodeNotHexr   )	r   r   r   r   r8   r4   r7   r9   r:   r   r   r   r   r0   M   s    


r0   N)r   Útwisted.trialr   Útwisted.web._abnfr   r   r   r   ÚSynchronousTestCaser   r   r0   r   r   r   r   Ú<module>   s   +