3 ��:X � @ sl d dl mZmZmZ d dlmZ d dlmZ d dlm Z m Z dd� ZG dd� de j�Z G d d � d e j�ZdS )� )�Draft4Validator�ValidationError�cli)�StringIO)�SchemaError)�mock�unittestc s$ t t� ��� G � fdd�dt�}|S )Nc s( e Zd Zdd� Z� fdd�Zdd� ZdS )z%fake_validator.<locals>.FakeValidatorc _ s d S )N� )�self�args�kwargsr r �/usr/lib/python3.6/test_cli.py�__init__ s z.fake_validator.<locals>.FakeValidator.__init__c s � r� j � S g S )N)�pop)r �instance)�errorsr r �iter_errors s z1fake_validator.<locals>.FakeValidator.iter_errorsc S s d S )Nr )r �schemar r r �check_schema s z2fake_validator.<locals>.FakeValidator.check_schemaN)�__name__� __module__�__qualname__r r r r )r r r � FakeValidator s r )�list�reversed�object)r r r )r r �fake_validator s r c @ s* e Zd Ze� Zdd� Zdd� Zdd� ZdS )� TestParserc C s` t j� }t jjtd|dd�}|j� | j|j� t j� }i |_ t jd�}|j� | j|j� d S )N�openT)Zcreatez json.load) r � mock_openZpatchr r �startZ addCleanup�stopZMockZreturn_value)r r Z patch_openZmock_json_loadZpatch_json_loadr r r �setUp s zTestParser.setUpc C s* t jdddddg�}| j|d | j� d S )Nz--validatorz2jsonschema.tests.test_cli.TestParser.FakeValidatorz --instancezfoo.jsonzschema.json� validator)r � parse_args�assertIsr )r � argumentsr r r �2test_find_validator_by_fully_qualified_object_name( s z=TestParser.test_find_validator_by_fully_qualified_object_namec C s( t jdddddg�}| j|d t� d S )Nz--validatorr z --instancezfoo.jsonzschema.jsonr# )r r$ r% r )r r&