ó
ž›V]c           @   s*  d  Z  d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l m Z d d l	 Z	 d d l
 m Z d d l m Z d d l Z d „  Z e	 j d e ƒ d e f d	 „  ƒ  Yƒ Z e	 j d e ƒ d
 e f d „  ƒ  Yƒ Z e	 j d e d e ƒ d e f d „  ƒ  Yƒ Z d „  Z d S(   s>   
Python representations of the JSON Schema Test Suite tests.

iÿÿÿÿN(   t   FilePath(   t   PY3(   t
   validatorsc          C   se   t  j j d ƒ }  |  d  k	 r( t |  ƒ St t j ƒ j ƒ  j d ƒ }  |  j	 ƒ  sa t
 d ƒ ‚ n  |  S(   Nt   JSON_SCHEMA_TEST_SUITEt   jsonsŸ   Can't find the JSON-Schema-Test-Suite directory. Set the 'JSON_SCHEMA_TEST_SUITE' environment variable or run the tests from alongside a checkout of the suite.(   t   ost   environt   gett   NoneR    t
   jsonschemat   __file__t   parentt   siblingt   isdirt
   ValueError(   t   root(    (    s6   lib/python2.7/site-packages/jsonschema/tests/_suite.pyt   _find_suite   s    
t   hasht   Suitec           B   s>   e  Z e j d  e j e ƒ ƒ Z d „  Z d „  Z d „  Z	 RS(   t   defaultc         C   s\   |  j  j d d g ƒ } t j t j | j d g ƒ } d „  t j | j	 d ƒ ƒ j
 ƒ  Dƒ S(   Nt   bint   jsonschema_suitet   remotesc         S   s#   i  |  ] \ } } | d  | “ q S(   s   http://localhost:1234/(    (   t   .0t   namet   schema(    (    s6   lib/python2.7/site-packages/jsonschema/tests/_suite.pys
   <dictcomp>2   s   	s   utf-8(   t   _roott
   descendantt
   subprocesst   check_outputt   syst
   executablet   pathR   t   loadst   decodet   items(   t   selfR   R   (    (    s6   lib/python2.7/site-packages/jsonschema/tests/_suite.pyt   _remotes,   s
    c         C   s1   x* t  D]" } |  j d | ƒ j d | ƒ q Wd  S(   NR   t   runner(   R   t   versiont	   benchmark(   R$   R&   R   (    (    s6   lib/python2.7/site-packages/jsonschema/tests/_suite.pyR(   6   s    c         C   s1   t  d | d |  j j d | g ƒ d |  j ƒ  ƒ S(   NR   R    t   testsR   (   t   VersionR   R   R%   (   R$   R   (    (    s6   lib/python2.7/site-packages/jsonschema/tests/_suite.pyR'   :   s    (
   t   __name__t
   __module__t   attrt   ibt   FactoryR   R   R%   R(   R'   (    (    (    s6   lib/python2.7/site-packages/jsonschema/tests/_suite.pyR   '   s   	
	R*   c           B   sk   e  Z e j ƒ  Z e j ƒ  Z e j ƒ  Z d  „  Z d „  Z d „  Z	 d „  Z
 d „  Z d „  Z d „  Z RS(   c         C   sH   xA |  j  ƒ  D]3 } x* | D]" } | j d | j d | j ƒ q Wq Wd  S(   NR   t   func(   R)   t
   bench_funct   fully_qualified_namet   validate_ignoring_errors(   R$   R&   t   suitet   test(    (    s6   lib/python2.7/site-packages/jsonschema/tests/_suite.pyR(   J   s
    		c            s    ‡  f d †  ˆ  j  j d ƒ Dƒ S(   Nc         3   s>   |  ]4 } ˆ  j  d  | j ƒ  d  d | ƒ D] } | Vq) q d S(   t   subjectiûÿÿÿR    N(   t	   _tests_int   basename(   R   t   childR5   (   R$   (    s6   lib/python2.7/site-packages/jsonschema/tests/_suite.pys	   <genexpr>T   s   	s   *.json(   t   _patht   globChildren(   R$   (    (   R$   s6   lib/python2.7/site-packages/jsonschema/tests/_suite.pyR)   R   s    c            s5   ˆ  j  j d d g ƒ } ‡  f d †  | j d ƒ Dƒ S(   Nt   optionalt   formatc         3   s>   |  ]4 } ˆ  j  d  | j ƒ  d  d | ƒ D] } | Vq) q d S(   R6   iûÿÿÿR    N(   R7   R8   (   R   R9   R5   (   R$   (    s6   lib/python2.7/site-packages/jsonschema/tests/_suite.pys	   <genexpr>_   s   	s   *.json(   R:   R   R;   (   R$   R    (    (   R$   s6   lib/python2.7/site-packages/jsonschema/tests/_suite.pyt   format_tests\   s    c         C   s&   |  j  d | d |  j j | d ƒ ƒ S(   NR6   R    s   .json(   R7   R:   R9   (   R$   R   (    (    s6   lib/python2.7/site-packages/jsonschema/tests/_suite.pyt   tests_ofg   s    	c         C   s,   |  j  d | d |  j j d | d g ƒ ƒ S(   NR6   R    R<   s   .json(   R7   R:   R   (   R$   R   (    (    s6   lib/python2.7/site-packages/jsonschema/tests/_suite.pyt   optional_tests_ofm   s    	c            su   ˆ  j  d d |  j j ƒ  ƒ } ‡  f d †  | Dƒ } t | t j f | ƒ } y t ƒ  | _ Wn t k
 rp n X| S(   NR   t   Testc            s?   i  |  ]5 } | D]( } | D] } | j  ˆ    | j “ q q q S(    (   t   to_unittest_methodt   method_name(   R   R4   R)   R5   (   t   kwargs(    s6   lib/python2.7/site-packages/jsonschema/tests/_suite.pys
   <dictcomp>v   s   	
(	   t   popR   t   titlet   typet   unittestt   TestCaset)   _someone_save_us_the_module_of_the_callerR,   t	   Exception(   R$   t   suitesRD   R   t   methodst   cls(    (   RD   s6   lib/python2.7/site-packages/jsonschema/tests/_suite.pyt   to_unittest_testcases   s    
c         #   sL   xE t  j | j ƒ  j d ƒ ƒ D]% ‰  ‡  ‡ ‡ f d †  ˆ  d Dƒ Vq Wd  S(   Ns   utf-8c         3   sD   |  ]: } t  d  ˆ d ˆ d ˆ  d d ˆ  d d ˆ j |  Vq d S(   R'   R6   t   case_descriptiont   descriptionR   R   N(   t   _TestR%   (   R   R5   (   t   eachR$   R6   (    s6   lib/python2.7/site-packages/jsonschema/tests/_suite.pys	   <genexpr>Š   s   R)   (   R   R!   t
   getContentR"   (   R$   R6   R    (    (   RS   R$   R6   s6   lib/python2.7/site-packages/jsonschema/tests/_suite.pyR7   ‡   s    %(   R+   R,   R-   R.   R:   R%   R   R(   R)   R>   R?   R@   RO   R7   (    (    (    s6   lib/python2.7/site-packages/jsonschema/tests/_suite.pyR*   B   s   		
				t   reprRR   c           B   s¹   e  Z e j ƒ  Z e j ƒ  Z e j ƒ  Z e j ƒ  Z e j ƒ  Z e j d  e	 ƒ Z
 e j ƒ  Z e j ƒ  Z d „  Z e d „  ƒ Z e d „  ƒ Z d „  d „ Z d d „ Z d „  Z RS(	   RU   c         C   s   d j  |  j ƒ S(   Ns	   <Test {}>(   R=   R2   (   R$   (    (    s6   lib/python2.7/site-packages/jsonschema/tests/_suite.pyt   __repr__¥   s    c         C   s(   d j  |  j j |  j |  j |  j g ƒ S(   Ns    > (   t   joinR'   R   R6   RP   RQ   (   R$   (    (    s6   lib/python2.7/site-packages/jsonschema/tests/_suite.pyR2   ¨   s
    	c         C   sk   d } d t  j | d |  j ƒ t  j | d |  j ƒ t  j | d |  j ƒ f } t sg | j d ƒ } n  | S(   Ns   [\W\- ]+s   test_%s_%s_%st   _s   utf-8(   t   ret   subR6   RP   RQ   R   t   encode(   R$   t
   delimitersR   (    (    s6   lib/python2.7/site-packages/jsonschema/tests/_suite.pyRC   ³   s    c         C   s   d  S(   N(   R   (   R5   (    (    s6   lib/python2.7/site-packages/jsonschema/tests/_suite.pyt   <lambda>À   t    c            sd   ˆ j  r ‡  ‡ f d †  } n ‡  ‡ f d †  } ˆ j | _ | ˆ ƒ } t j | d  k	 | ƒ | ƒ S(   Nc            s   ˆ j  ˆ    d  S(   N(   t   validate(   t   this(   RD   R$   (    s6   lib/python2.7/site-packages/jsonschema/tests/_suite.pyt   fnÂ   s    c            s*   |  j  t j ƒ  ˆ j ˆ    Wd  QXd  S(   N(   t   assertRaisesR	   t   ValidationErrorR_   (   R`   (   RD   R$   (    s6   lib/python2.7/site-packages/jsonschema/tests/_suite.pyRa   Å   s    (   t   validRC   R+   RH   t   skipIfR   (   R$   t   skipRD   Ra   t   reason(    (   RD   R$   s6   lib/python2.7/site-packages/jsonschema/tests/_suite.pyRB   À   s    	c      
   K   sP   t  j j d |  j d |  j ƒ } t  j d |  j d |  j d | d | |  d  S(   NR   t   storet   instanceRN   t   resolver(   R	   t   RefResolvert   from_schemaR   R%   R_   t   data(   R$   t	   ValidatorRD   Rj   (    (    s6   lib/python2.7/site-packages/jsonschema/tests/_suite.pyR_   Í   s    			c         K   s,   y |  j  |   Wn t j k
 r' n Xd  S(   N(   R_   R	   Rc   (   R$   RD   (    (    s6   lib/python2.7/site-packages/jsonschema/tests/_suite.pyR3   Ù   s    N(   R+   R,   R-   R.   R'   R6   RP   RQ   Rm   t   FalseR   Rd   R%   RV   t   propertyR2   RC   RB   R   R_   R3   (    (    (    s6   lib/python2.7/site-packages/jsonschema/tests/_suite.pyRR   •   s   	c           C   s   t  j d ƒ j d S(   sˆ  
    The FQON of the module 2nd stack frames up from here.

    This is intended to allow us to dynamicallly return test case classes that
    are indistinguishable from being defined in the module that wants them.

    Otherwise, trial will mis-print the FQON, and copy pasting it won't re-run
    the class that really is running.

    Save us all, this is all so so so so so terrible.
    i   R+   (   R   t	   _getframet	   f_globals(    (    (    s6   lib/python2.7/site-packages/jsonschema/tests/_suite.pyRJ   à   s    (   t   __doc__R   R   RY   R   R   RH   t   twisted.python.filepathR    R-   t   jsonschema.compatR   t   jsonschema.validatorsR   R	   R   t   st   Truet   objectR   R*   Ro   RR   RJ   (    (    (    s6   lib/python2.7/site-packages/jsonschema/tests/_suite.pyt   <module>   s&   	RJ