
    Mht                         d Z ddlmZ ddlmZmZ ddlmZ ddlm	Z	  e
d          Z ed          Zd Z G d	 d
e          ZdS )zH
Tests for the parts of jsonschema related to the :kw:`format` keyword.
    )TestCase)FormatCheckerValidationError)FormatError)Draft4ValidatorzBoom!zBang!c                 *    | dk    rt           t          )Nbang)BANGBOOMthings    \/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/jsonschema/tests/test_format.pyboomr      s    

J    c                   >    e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	S )
TestFormatCheckerc                 Z    t          d          }|                     |j                   d S )N formats)r   assertFalsecheckersselfcheckers     r   test_it_can_validate_no_formatsz1TestFormatChecker.test_it_can_validate_no_formats   s/    +++)*****r   c                     |                      t                    5  t          dg           d d d            d S # 1 swxY w Y   d S )Nzo noesr   )assertRaisesKeyErrorr   )r   s    r   .test_it_raises_a_key_error_for_unknown_formatsz@TestFormatChecker.test_it_raises_a_key_error_for_unknown_formats   s    x(( 	. 	.8*----	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	.s   :>>c                    t          t          j                  }|                     t          j        j        d           |                     t                    5   t          j        d          t                     d d d            n# 1 swxY w Y   | 	                    t          j        t          |t          df                     d S Nr   r   )r   )
dictr   r   
addCleanuppopassertWarnsDeprecationWarning
cls_checksr   assertEqual)r   originals     r   !test_it_can_register_cls_checkersz3TestFormatChecker.test_it_can_register_cls_checkers   s    .//.2F;;;011 	3 	3,M$V,,T222	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3"r
+++	
 	
 	
 	
 	
s   #BBBc                     t                      } |                    d          t                     |                     |j        t          t           j        t          df                     d S r"   )r   checksr   r)   r   r#   r   s     r   test_it_can_register_checkersz/TestFormatChecker.test_it_can_register_checkers(   sf    //vt$$$'tRj999	
 	
 	
 	
 	
r   c                    t                      } |                    dt          t                              t                     |                     t                    5 }|                    dd           d d d            n# 1 swxY w Y   |                     |j	        j
        t                     |                     |j	        j        t                     |                     t          |j	                  d           |                     t          t                              5  |                    dd           d d d            d S # 1 swxY w Y   d S )Nr   raises   instanceformatz12 is not a 'boom'r	   )r   r-   typer   r   r   r   checkassertIs	exceptioncause	__cause__r)   strr
   )r   r   cms      r   !test_it_catches_registered_errorsz3TestFormatChecker.test_it_catches_registered_errors0   s   //1vd4jj11$777{++ 	6rMM2fM555	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	bl($///bl,d333R\**,@AAA tDzz** 	: 	:MM6&M999	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	:s$    BBB(EEEc                    t                      } |                    dt                    t                     t	          ddi|          }|                     t                    5 }|                    d           d d d            n# 1 swxY w Y   |                     |j	        j
        t                     |                     |j	        j        t                     d S )Nr   r0   r5   )format_checkerr   )r   r-   
ValueErrorr   r   r   r   validater8   r9   r:   r   r;   )r   r   	validatorr=   s       r   7test_format_error_causes_become_validation_error_causeszITestFormatChecker.test_format_error_causes_become_validation_error_causes?   s    //1vj11$777#Xv$6wOOO	// 	'2v&&&	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	bl($///bl,d33333s   &BBBc                     t                      }|                     t                    5  |                    dd           d d d            d S # 1 swxY w Y   d S )Nznot-an-ipv4ipv4r3   )r   r   r   r7   r   s     r   'test_format_checkers_come_with_defaultsz9TestFormatChecker.test_format_checkers_come_with_defaultsJ   s    
  //{++ 	A 	AMM=M@@@	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	As   AAAc                 &   t          d          } |                    d          d             |                    d          d             |                    d          d            |                     t          |          d	           d S )
Nr   r   fooc                     dS NTr   r   s    r   <lambda>z-TestFormatChecker.test_repr.<locals>.<lambda>U       D r   barc                     dS rK   r   r   s    r   rL   z-TestFormatChecker.test_repr.<locals>.<lambda>V   rM   r   bazc                     dS rK   r   r   s    r   rL   z-TestFormatChecker.test_repr.<locals>.<lambda>W   rM   r   z.<FormatChecker checkers=['bar', 'baz', 'foo']>)r   r-   r)   reprr   s     r   	test_reprzTestFormatChecker.test_reprS   s    +++u00111u00111u00111MM<	
 	
 	
 	
 	
r   N)__name__
__module____qualname__r   r    r+   r.   r>   rD   rG   rS   r   r   r   r   r      s        + + +. . .
 
 

 
 
: : :	4 	4 	4A A A
 
 
 
 
r   r   N)__doc__unittestr   
jsonschemar   r   jsonschema.exceptionsr   jsonschema.validatorsr   rA   r   ZeroDivisionErrorr
   r   r   r   r   r   <module>r]      s           5 5 5 5 5 5 5 5 - - - - - - 1 1 1 1 1 1z'!!  F
 F
 F
 F
 F
 F
 F
 F
 F
 F
r   