ó
0Rc           @   s[  d  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 m Z d d l	 m
 Z
 e j j e j j e ƒ ƒ Z e j i d d 6ƒ Z e j d d	 ƒ Z e j e d
 ƒ Z e j i d d 6j ƒ Z e j e e g ƒ Z e j i e d 6e d 6ƒ Z d e j f d „  ƒ  YZ d „  Z d e j  f d „  ƒ  YZ! d „  Z" d „  Z# d S(   s   
    jinja2.testsuite
    ~~~~~~~~~~~~~~~~

    All the unittests of Jinja2.  These tests can be executed by
    either running run-tests.py using multiple Python versions at
    the same time.

    :copyright: (c) 2010 by the Jinja Team.
    :license: BSD, see LICENSE for more details.
iÿÿÿÿN(   t   format_exception(   t   loaders(   t   PY2t   FOOs   justdict.htmls   jinja2.testsuite.rest	   templatess   /res/templatess   justfunction.htmlt   at   bt   JinjaTestCasec           B   sG   e  Z d  „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   c         C   s   d  S(   N(    (   t   self(    (    s=   /usr/lib/python2.7/site-packages/jinja2/testsuite/__init__.pyt   setup*   s    c         C   s   d  S(   N(    (   R   (    (    s=   /usr/lib/python2.7/site-packages/jinja2/testsuite/__init__.pyt   teardown-   s    c         C   s   |  j  ƒ  d  S(   N(   R	   (   R   (    (    s=   /usr/lib/python2.7/site-packages/jinja2/testsuite/__init__.pyt   setUp0   s    c         C   s   |  j  ƒ  d  S(   N(   R
   (   R   (    (    s=   /usr/lib/python2.7/site-packages/jinja2/testsuite/__init__.pyt   tearDown3   s    c         C   s   |  j  | | ƒ S(   N(   t   assertEqual(   R   R   R   (    (    s=   /usr/lib/python2.7/site-packages/jinja2/testsuite/__init__.pyt   assert_equal6   s    c         O   s   |  j  | | Ž  S(   N(   t   assertRaises(   R   t   argst   kwargs(    (    s=   /usr/lib/python2.7/site-packages/jinja2/testsuite/__init__.pyt   assert_raises9   s    c         C   s   y | ƒ  Wnq t  k
 r~ } t t j ƒ  Œ  } t j | j ƒ  d j | ƒ ƒ d  k rŒ |  j	 d d j | ƒ | f ƒ ‚ qŒ n X|  j	 d ƒ d  S(   Nt    s)   Traceback did not match:

%s
expected:
%ss   Expected exception(
   t	   ExceptionR    t   syst   exc_infot   ret   searcht   stript   joint   Nonet   fail(   R   t   callbackt   expected_tbt   et   tb(    (    s=   /usr/lib/python2.7/site-packages/jinja2/testsuite/__init__.pyt   assert_traceback_matches<   s    '	 (	   t   __name__t
   __module__R	   R
   R   R   R   R   R!   (    (    (    s=   /usr/lib/python2.7/site-packages/jinja2/testsuite/__init__.pyR   %   s   						c         c   sr   |  g } xb | rm | j  ƒ  } y | j | ƒ Wq t k
 ri | d | j j | j j | j f f Vq Xq Wd S(   s8   Yields all the tests and their names from a given suite.s   %s.%s.%sN(   t   popt   extendt	   TypeErrort	   __class__R#   R"   t   _testMethodName(   t   suitet   suitest   s(    (    s=   /usr/lib/python2.7/site-packages/jinja2/testsuite/__init__.pyt   find_all_testsH   s    				t   BetterLoaderc           B   s#   e  Z d  Z d „  Z d d „ Z RS(   s~  A nicer loader that solves two problems.  First of all we are setting
    up tests from different sources and we're doing this programmatically
    which breaks the default loading logic so this is required anyways.
    Secondly this loader has a nicer interpolation for test names than the
    default one so you can just do ``run-tests.py ViewTestCase`` and it
    will work.
    c         C   s   t  ƒ  S(   N(   R)   (   R   (    (    s=   /usr/lib/python2.7/site-packages/jinja2/testsuite/__init__.pyt   getRootSuite`   s    c   	      C   sö   |  j  ƒ  } | d k r | Sg  } xp t | ƒ D]b \ } } | | k s | j d | ƒ s d | d | k s | j | d ƒ r/ | j | ƒ q/ q/ W| s® t d | ƒ ‚ n  t | ƒ d k rÈ | d St j ƒ  } x | D] } | j	 | ƒ qÛ W| S(   NR)   t   .s!   could not find test case for "%s"i   i    (
   R.   R,   t   endswitht
   startswitht   appendt   LookupErrort   lent   unittestt	   TestSuitet   addTest(	   R   t   namet   modulet   roott	   all_testst   testcaset   testnamet   rvt   test(    (    s=   /usr/lib/python2.7/site-packages/jinja2/testsuite/__init__.pyt   loadTestsFromNamec   s$    N(   R"   R#   t   __doc__R.   R   R@   (    (    (    s=   /usr/lib/python2.7/site-packages/jinja2/testsuite/__init__.pyR-   W   s   	c          C   sš  d d l  m }  m } m } m } m } m } m } m } m	 } m
 }	 m }
 m } m } m } m } t j ƒ  } | j |  j ƒ  ƒ | j | j ƒ  ƒ | j | j ƒ  ƒ | j | j ƒ  ƒ | j | j ƒ  ƒ | j | j ƒ  ƒ | j | j ƒ  ƒ | j | j ƒ  ƒ | j | j ƒ  ƒ | j |	 j ƒ  ƒ | j |
 j ƒ  ƒ | j | j ƒ  ƒ | j | j ƒ  ƒ | j | j ƒ  ƒ t r–| j | j ƒ  ƒ n  | S(   Niÿÿÿÿ(   t   extt   filterst   testst	   core_tagst   loadert   inheritancet   importst	   lexnparset   securityt   apit
   regressiont   debugt   utilst   bytecode_cachet   doctests(   t   jinja2.testsuiteRB   RC   RD   RE   RF   RG   RH   RI   RJ   RK   RL   RM   RN   RO   RP   R5   R6   R7   R)   R   (   RB   RC   RD   RE   RF   RG   RH   RI   RJ   RK   RL   RM   RN   RO   RP   R)   (    (    s=   /usr/lib/python2.7/site-packages/jinja2/testsuite/__init__.pyR)   {   s&    dc          C   s@   y t  j d t ƒ  d d ƒ Wn t k
 r; }  d |  GHn Xd S(   s/   Runs the testsuite as command line application.t
   testLoadert   defaultTestR)   s	   Error: %sN(   R5   t   mainR-   R   (   R   (    (    s=   /usr/lib/python2.7/site-packages/jinja2/testsuite/__init__.pyRT   —   s    ($   RA   t   osR   R   R5   t	   tracebackR    t   jinja2R   t   jinja2._compatR   t   patht   dirnamet   abspatht   __file__t   heret
   DictLoadert   dict_loadert   PackageLoadert   package_loadert   FileSystemLoadert   filesystem_loadert   FunctionLoadert   gett   function_loadert   ChoiceLoadert   choice_loadert   PrefixLoadert   prefix_loadert   TestCaseR   R,   t
   TestLoaderR-   R)   RT   (    (    (    s=   /usr/lib/python2.7/site-packages/jinja2/testsuite/__init__.pyt   <module>   s,   		#	$	