관리-도구
편집 파일: test_validators.cpython-37.opt-1.pyc
B �pSe�� � @ s� d dl mZ d dlmZ d dlmZ d dlmZ d dlm Z d dl Z d dlZd dlZd dl Z d dlZd dlmZ d dlZd dlmZmZmZmZ d d lmZmZ d d lmZ dd� ZG d d� de�ZG dd� de�ZG dd� de �ZG dd� de �ZG dd� de �Z G dd� de!�Z"G dd� de"e!�Z#G dd� de!�Z$G dd� de$e#e �Z%G dd � d e$e#e �Z&G d!d"� d"e#e �Z'G d#d$� d$e#e �Z(G d%d&� d&e�Z)G d'd(� d(e�Z*G d)d*� d*e�Z+d+d,� Z,ej-G d-d.� d.e!��Z.ej-G d/d0� d0e!��Z/dS )1� )�deque)�contextmanager)�Decimal)�BytesIO)�TestCaseN)�SynchronousTestCase)� FormatChecker�TypeChecker� exceptions� validators)�PY3�pathname2url)�bugc c s |� |�st�d�V d S )NzWhoops!)� startswithr �ValidationError)� validatorr �instance�schema� r �Q/opt/alt/python37/lib/python3.7/site-packages/jsonschema/tests/test_validators.pyr s r c @ sd e Zd Zdd� Zdd� Zdd� Zdd� Zd d � Zdd� Zd d� Z dd� Z dd� Zdd� Zdd� Z dS )�TestCreateAndExtendc C sP | � | jtjttj�� ddi| _dti| _t� | _tj | j| j| jd�| _ d S )Nz$idzsome://meta/schemar )�meta_schemar �type_checker)� addCleanup�assertEqualr �meta_schemas�dictr r r r �create� Validator)�selfr r r �setUp s zTestCreateAndExtend.setUpc C s. | � | jj| jj| jjf| j| j| jf� d S )N)r r � VALIDATORS�META_SCHEMA�TYPE_CHECKERr r r )r r r r � test_attrs* s zTestCreateAndExtend.test_attrsc C s ddi}| � | �|�j|� d S )Nr �foo)r r r )r r r r r � test_init7 s zTestCreateAndExtend.test_initc C s� ddi}| � |�j}t|d��}| �|g � tjdd|ddtdg�d�}t|d��}| �t|�d� | �|d �� |�� � d S ) Nr ZhelZhellozWhoops!Zgoodbye)r r r �validator_value�schema_path� r ) r �iter_errors�listr r r r �lenZ _contents)r r r* �errorsZexpected_errorr r r �test_iter_errors; s z$TestCreateAndExtend.test_iter_errorsc C s4 t jddidd�}| �t jjd� | �|jd� d S )Nz$id� somethingz my version)r �versionZMyVersionValidator)r r r r �popr �__name__)r r r r r �.test_if_a_version_is_provided_it_is_registeredO s zBTestCreateAndExtend.test_if_a_version_is_provided_it_is_registeredc C s, t tj�}tjddid� | �tj|� d S )N�id)r )r r r r r )r �originalr r r �6test_if_a_version_is_not_provided_it_is_not_registeredW s zJTestCreateAndExtend.test_if_a_version_is_not_provided_it_is_not_registeredc C sB d}d|i}t j|ddd� d� | �t jj|� | �|t j� d S )Nzmeta schema idr4 z my versionc S s | � dd�S )Nr4 � )�get)�sr r r �<lambda>c � zMTestCreateAndExtend.test_validates_registers_meta_schema_id.<locals>.<lambda>)r r0 �id_of)r r r r r1 �assertIn)r �meta_schema_key�my_meta_schemar r r �'test_validates_registers_meta_schema_id\ s z;TestCreateAndExtend.test_validates_registers_meta_schema_idc C s<