
    Vh)                         d Z ddlmZ ddlmZmZmZmZ  G d dej                        Z	 G d dej                        Z
 G d d	ej                        Zy
)z!
Tests for L{twisted.web._abnf}.
    )unittest)_decint_hexint_ishexdigits_istokenc                        e Zd ZdZddZddZy)IsTokenTestsz:
    Test the L{twisted.web._abnf._istoken} function.
    Nc                 F    dD ]  }| j                  t        |              y )N)s   GETs   Cache-Control   &)
assertTruer   selfbs     J/home/dcms/DCMS/lib/python3.12/site-packages/twisted/web/test/test_abnf.pytest_okzIsTokenTests.test_ok   s%    
 	)A
 OOHQK(	)    c                 F    dD ]  }| j                  t        |              y )N)r       s   a b)assertFalser   r   s     r   test_badzIsTokenTests.test_bad   s'    
 	*A
 Xa[)	*r   returnN)__name__
__module____qualname____doc__r   r    r   r   r	   r	      s    )*r   r	   c                   8    e Zd ZdZddZddZddZddZddZy)	DecintTestsz9
    Test the L{twisted.web._abnf._decint} function.
    Nc                     | j                  dt        d             | j                  dt        d             | j                  dt        d             | j                  dt        d             y)	zF
        Given a decimal digits, L{_decint} return an L{int}.
              1
      10i(#  s   9000s   0009000NassertEqualr   r   s    r   
test_validzDecintTests.test_valid'   sV     	GDM*WU^,ww/0wz23r   c                     | j                  dt        d             | j                  dt        d             | j                  dt        d             y)zL
        L{_decint} decodes integers embedded in linear whitespace.
        {   s    123s   123		s    	 123   	  Nr%   r'   s    r   test_validWhitespacez DecintTests.test_validWhitespace0   sD     	gg./gj12g&789r   c                 :    | j                  t        t        d       y)zL
        L{_decint} rejects a number with a leading C{+} character.
        s   +1NassertRaises
ValueErrorr   r'   s    r   test_invalidPluszDecintTests.test_invalidPlus8        	*gu5r   c                 :    | j                  t        t        d       y)zL
        L{_decint} rejects a number with a leading C{-} character.
        s   -1Nr-   r'   s    r   test_invalidMinuszDecintTests.test_invalidMinus>   r1   r   c                     | j                  t        t        d       | j                  t        t        d       | j                  t        t        d       y)zP
        L{_decint} rejects a number embedded in non-linear whitespace.
        s   1s   1s   1Nr-   r'   s    r   test_invalidWhitespacez"DecintTests.test_invalidWhitespaceD   s:     	*gv6*gx8*gx8r   r   )	r   r   r   r   r(   r+   r0   r3   r5   r   r   r   r   r   "   s     4:669r   r   c                   4    e Zd ZdZdZddZddZddZddZy)	HexHelperTestszU
    Test the L{twisted.web._abnf._hexint} and L{_ishexdigits} helper functions.
    )r   s   0x1234s   fedss   -123+123Nc                 H    dD ]  }| j                  dt        |              y)zr
        L{_ishexdigits()} returns L{True} for nonempy bytestrings containing
        hexadecimal digits.
        )r$   s   abcdefs   AB1234s   feds	   123467890TN)assertIsr   r   ss     r   
test_isHexzHexHelperTests.test_isHexT   s&    
 E 	1AMM$Q0	1r   c                     | j                  dt        d             | j                  dt        d             | j                  dt        d             y)zK
        L{_hexint()} returns the integer equivalent of the input.
        r#      a   r$   i#Ѽ
s   abCD123N)r&   r   r'   s    r   test_decodeszHexHelperTests.test_decodes\   sA     	WT]+wu~.GJ$78r   c                 \    | j                   D ]  }| j                  dt        |              y)z
        L{_ishexdigits()} returns L{False} for bytestrings that don't contain
        hexadecimal digits, including the empty string.
        FN)
badStringsr9   r   r:   s     r   test_isNotHexzHexHelperTests.test_isNotHexd   s)    
  	2AMM%a1	2r   c                 \    | j                   D ]  }| j                  t        t        |        y)zb
        L{_hexint()} raises L{ValueError} for bytestrings that can't
        be decoded.
        N)rB   r.   r/   r   r:   s     r   test_decodeNotHexz HexHelperTests.test_decodeNotHexl   s)    
  	6Aj'15	6r   r   )	r   r   r   r   rB   r<   r@   rC   rE   r   r   r   r7   r7   M   s"     <J1926r   r7   N)r   twisted.trialr   twisted.web._abnfr   r   r   r   SynchronousTestCaser	   r   r7   r   r   r   <module>rI      sL    # F F*8// *,(9(.. (9V%6X11 %6r   