B
    U	                 @   s^   d Z ddlmZmZ ddlmZ ddlmZ eed G dd de	Z
G dd	 d	ee
Zd
S )a  
    werkzeug.contrib.testtools
    ~~~~~~~~~~~~~~~~~~~~~~~~~~

    This module implements extended wrappers for simplified testing.

    `TestResponse`
        A response wrapper which adds various cached attributes for
        simplified assertions on various content types.

    :copyright: (c) 2014 by the Werkzeug Team, see AUTHORS for more details.
    :license: BSD, see LICENSE for more details.
    )cached_propertyimport_string)Response)warnzNwerkzeug.contrib.testtools is deprecated and will be removed with Werkzeug 1.0c               @   s@   e Zd ZdZdd ZeeZdd ZeeZdd ZeeZdS )	ContentAccessorszl
    A mixin class for response objects that provides a couple of useful
    accessors for unittesting.
    c             C   sR   d| j krtd| j  x,dD ]$}t|dd}|dk	r|| jS qW tddS )zGet an etree if possible.xmlz%Not a XML response (Content-Type: %s))zxml.etree.ElementTreeZElementTreezelementtree.ElementTreeT)ZsilentNz;You must have ElementTree installed to use TestResponse.xml)mimetypeAttributeErrorr   XMLZbodyRuntimeError)selfmoduleetree r   9lib/python3.7/site-packages/werkzeug/contrib/testtools.pyr      s    


zContentAccessors.xmlc             C   st   d| j krd| j krtdddlm} yddlm} W n tk
rR   |j}Y nX | j dkrh|| jS |	| jS )zGet an lxml etree if possible.Zhtmlr   zNot an HTML/XML responser   )r   )
fromstringz	text/html)
r   r	   lxmlr   Z	lxml.htmlr   ImportErrorZHTMLdatar
   )r   r   r   r   r   r   r   -   s    

zContentAccessors.lxmlc             C   sN   d| j krtdyddlm} W n  tk
rB   ddlm} Y nX || jS )z/Get the result of simplejson.loads if possible.jsonzNot a JSON responser   )loads)r   r	   Z
simplejsonr   r   r   r   )r   r   r   r   r   r   ;   s    
zContentAccessors.jsonN)__name__
__module____qualname____doc__r   r   r   r   r   r   r   r   r      s   	r   c               @   s   e Zd ZdZdS )TestResponsez;Pass this to `werkzeug.test.Client` for easier unittesting.N)r   r   r   r   r   r   r   r   r   G   s   r   N)r   Zwerkzeug.utilsr   r   Zwerkzeug.wrappersr   warningsr   DeprecationWarningobjectr   r   r   r   r   r   <module>   s   0