o
    iD$                     @   sH   d dl mZ d dlZd dlZd dlZd dlmZmZ G dd deZdS )    )TestCaseN)FormatChecker
validatorsc                   @   sl   e Zd Zdd Zdd Zdd Zdd Zd	d
 Zdd Zdd Z	dd Z
dd Zdd Zdd Zdd ZdS )TestDeprecationsc                 C   ^   |  t}ddlm} W d   n1 sw   Y  | |jt | t|j	
d dS )zY
        As of v4.0.0, __version__ is deprecated in favor of importlib.metadata.
        r   )__version__Nz.Accessing jsonschema.__version__ is deprecated)assertWarnsDeprecationWarning
jsonschemar   assertEqualfilename__file__
assertTruestrwarning
startswith)selfwr    r   ]/var/www/edux/Edux_v2/venv/lib/python3.10/site-packages/jsonschema/tests/test_deprecations.pytest_version
   s   
zTestDeprecations.test_versionc                 C   r   )z
        As of v4.0.0, importing ErrorTree from jsonschema.validators is
        deprecated in favor of doing so from jsonschema.exceptions.
        r   )	ErrorTreeNz<Importing ErrorTree from jsonschema.validators is deprecated)r   r	   jsonschema.validatorsr   r   r   r   r   r   r   r   )r   r   r   r   r   r   test_validators_ErrorTree   s   
z*TestDeprecations.test_validators_ErrorTreec                 C   sf   |  t}tj}W d   n1 sw   Y  | |tj | |jt | t|j	
d dS )za
        As of v4.0.0, accessing jsonschema.validators.validators is
        deprecated.
        Nz8Accessing jsonschema.validators.validators is deprecated)r   r	   r   r   _VALIDATORSr   r   r   r   r   r   r   r   valuer   r   r   test_validators_validators)      
z+TestDeprecations.test_validators_validatorsc                 C   sf   |  t}tj}W d   n1 sw   Y  | |tj | |jt | t	|j
d dS )zc
        As of v4.0.0, accessing jsonschema.validators.meta_schemas is
        deprecated.
        Nz:Accessing jsonschema.validators.meta_schemas is deprecated)r   r	   r   meta_schemasr   _META_SCHEMASr   r   r   r   r   r   r   r   r   r   test_validators_meta_schemas:   r   z-TestDeprecations.test_validators_meta_schemasc              	   C   s   t ji }| t}|d W d   n1 sw   Y  W d   n1 s+w   Y  | |jt | 	t
|jd dS )zC
        As of v4.0.0, RefResolver.in_scope is deprecated.
        fooNz.jsonschema.RefResolver.in_scope is deprecated )r   RefResolverfrom_schemar   r	   in_scoper   r   r   r   r   r   r   )r   resolverr   r   r   r   test_RefResolver_in_scopeK   s   
z*TestDeprecations.test_RefResolver_in_scopec                 C   sv   t i }| t}|dddi}W d   n1 sw   Y  | | | |jt | 	t
|jd dS )zz
        As of v4.0.0, calling is_valid with two arguments (to provide a
        different schema) is deprecated.
        r"   typenumberNz5Passing a schema to Validator.is_valid is deprecated )r   Draft7Validatorr   r	   is_validassertFalser   r   r   r   r   r   r   )r   	validatorr   resultr   r   r   %test_Validator_is_valid_two_arguments\   s   


z6TestDeprecations.test_Validator_is_valid_two_argumentsc                 C   s|   t i }| t}|dddi\}W d   n1 sw   Y  | |jd | |jt | 	t
|jd dS )z}
        As of v4.0.0, calling iter_errors with two arguments (to provide a
        different schema) is deprecated.
        r"   r(   r)   Nz8Passing a schema to Validator.iter_errors is deprecated )r   r*   r   r	   iter_errorsr   r-   r   r   r   r   r   r   )r   r-   r   errorr   r   r   (test_Validator_iter_errors_two_argumentsn   s   

z9TestDeprecations.test_Validator_iter_errors_two_argumentsc                 C   s   |  t}G dd dtj}W d   n1 sw   Y  | |jt | t|j	
d |  t}G dd dtji d}W d   dS 1 sMw   Y  dS )ac  
        As of v4.12.0, subclassing a validator class produces an explicit
        deprecation warning.

        This was never intended to be public API (and some comments over the
        years in issues said so, but obviously that's not a great way to make
        sure it's followed).

        A future version will explicitly raise an error.
        c                   @      e Zd ZdS )z=TestDeprecations.test_Validator_subclassing.<locals>.SubclassN__name__
__module____qualname__r   r   r   r   Subclass       r8   Nz!Subclassing validator classes is c                   @   r3   )zDTestDeprecations.test_Validator_subclassing.<locals>.AnotherSubclassNr4   r   r   r   r   AnotherSubclass   r9   r:   )meta_schema)r   r	   r   Draft202012Validatorr   r   r   r   r   r   r   create)r   r   r8   r:   r   r   r   test_Validator_subclassing   s   "z+TestDeprecations.test_Validator_subclassingc                 C   sn   |  tjjdd | t}td W d   n1 sw   Y  | |jt	 | 
t|jd dS )zd
        As of v4.14.0, FormatChecker.cls_checks is deprecated without
        replacement.
        boomNzFormatChecker.cls_checks )
addCleanupr   checkerspopr   r	   
cls_checksr   r   r   r   r   r   r   )r   r   r   r   r   test_FormatChecker_cls_checks   s   z.TestDeprecations.test_FormatChecker_cls_checksc           	      C   s  |  t}ddlm} W d   n1 sw   Y  | |tjj | |j	t
 | jt|jd|jd |  t}ddlm} W d   n1 sNw   Y  | |tjj | |j	t
 | jt|jd|jd |  t}ddlm} W d   n1 sw   Y  | |tjj | |j	t
 | jt|jd	|jd |  t}dd
lm} W d   n1 sw   Y  | |tjj | |j	t
 | jt|jd|jd |  t}ddlm} W d   n1 sw   Y  | |tjj | |j	t
 | jt|jd|jd |  t}ddlm} W d   n	1 s/w   Y  | |tjj | |j	t
 | jt|jd|jd | t ddlm} W d   dS 1 siw   Y  dS )z
        As of v4.16.0, accessing jsonschema.draftn_format_checker is deprecated
        in favor of Validator.FORMAT_CHECKER.
        r   )draft202012_format_checkerNz3Accessing jsonschema.draft202012_format_checker is )msg)draft201909_format_checkerz3Accessing jsonschema.draft201909_format_checker is )draft7_format_checkerz.Accessing jsonschema.draft7_format_checker is )draft6_format_checkerz.Accessing jsonschema.draft6_format_checker is )draft4_format_checkerz.Accessing jsonschema.draft4_format_checker is )draft3_format_checkerz.Accessing jsonschema.draft3_format_checker is )draft1234_format_checker)r   r	   r
   rE   assertIsr   r<   FORMAT_CHECKERr   r   r   r   r   r   r   rG   Draft201909ValidatorrH   r*   rI   Draft6ValidatorrJ   Draft4ValidatorrK   Draft3ValidatorassertRaisesImportErrorrL   )	r   r   rE   rG   rH   rI   rJ   rK   rL   r   r   r   test_draftN_format_checker   s   





$z+TestDeprecations.test_draftN_format_checkerc                 C   sh   |  t}ddl}t|j W d   n1 sw   Y  | |jtj | 	t
|jd dS )zH
        As of v4.17.0, importing jsonschema.cli is deprecated.
        r   Nz5The jsonschema CLI is deprecated and will be removed )r   r	   jsonschema.cli	importlibreloadclir   r   r   r   r   r   r   )r   r   r
   r   r   r   test_import_cli  s   
z TestDeprecations.test_import_clic                 C   s(   t jtjddgdd}| d|j dS )zB
        As of v4.17.0, the jsonschema CLI is deprecated.
        z-mr
   T)capture_outputs!   The jsonschema CLI is deprecated N)
subprocessrunsys
executableassertInstderr)r   processr   r   r   test_cli  s
   
zTestDeprecations.test_cliN)r5   r6   r7   r   r   r   r!   r'   r/   r2   r>   rD   rU   rZ   rc   r   r   r   r   r   	   s    cr   )	unittestr   rW   r\   r^   r
   r   r   r   r   r   r   r   <module>   s    