U
    TZ                     @   s   d Z eZdgZddlZddlZddlZddlmZm	Z	m
Z
mZ ddlZddlmZmZ ejejB ejB Zdd Zdd	 Zdd
dZdd ZdS )zTest harness for doctests.
load_tests    N)resource_filenameresource_existsresource_listdircleanup_resources)install	uninstallc                 C   s&   ddl m} t  tdd|j d S )Nr   	WSGILayerzcookbooks.devP   )0lazr.restful.example.base.tests.test_integrationr
   r   wsgi_interceptZadd_wsgi_interceptZmake_application)testr
    r   D/usr/lib/python3/dist-packages/lazr/restfulclient/tests/test_docs.pysetUp,   s      r   c                 C   s6   ddl m} ddlm} t  ||}i |_d|_d S )Nr   )IFileManager)
getUtility)Z$lazr.restful.example.base.interfacesr   Zzope.componentr   r   filesZcounter)r   r   r   Zfile_managerr   r   r   tearDown3   s    r   c              	   C   s\   g }t ddrXtddD ]>}|dk	r0||r0q|| r|tjtdd|  q|S )z(Find doctests matching a certain suffix.zlazr.restfulclientZdocsNzdocs/%s)r   r   endswithappendospathabspathr   )suffixignore_suffixZdoctest_filesnamer   r   r   find_doctests<   s    

 r   c                 C   sd   ddl m} tt tjtddddtt	t
d}||_|| |tjtddtd |S )	zLoad all the doctests.r   r	   z.rstz.standalone.rst)r   F)module_relativeoptionflagsr   r   )r   r    )r   r
   atexitregisterr   doctestZDocFileSuiter   DOCTEST_FLAGSr   r   ZlayerZaddTest)loaderZtestspatternr
   Zrestful_suiter   r   r   r   L   s"    

  
 
)N)__doc__typeZ__metaclass____all__r!   r#   r   Zpkg_resourcesr   r   r   r   r   Z!wsgi_intercept.httplib2_interceptr   r   ELLIPSISZNORMALIZE_WHITESPACEZREPORT_NDIFFr$   r   r   r   r   r   r   r   r   <module>   s&   	
