Ñò
¼²‚Mc           @   sU  d  d k  Z d  d k l Z d  d k l Z d  d k l Z l Z d  d k	 l
 Z d  d k l Z l Z d  d k l Z l Z l Z d  d k l  Z  y e Wn# e j
 o d  d	 k l Z n Xd Z d Z e ƒ  Z d
 e  i f d „  ƒ  YZ d „  Z d „  Z d „  Z d „  Z d „  Z  d „  Z! d e" f d „  ƒ  YZ# d e$ e% d d „ Z' d S(   iÿÿÿÿN(   t   settings(   t   ImproperlyConfigured(   t   get_appt   get_apps(   t   _doctest(   t   setup_test_environmentt   teardown_test_environment(   t   OutputCheckert   DocTestRunnert   TestCase(   t   unittest(   t   allt   DjangoTestRunnert   DjangoTestSuiteRunnert	   run_testst   testsc           B   s   e  Z d  „  Z RS(   c         O   s9   d d  k  } | i d t ƒ t t |  ƒ i | | Ž  d  S(   Niÿÿÿÿs[   DjangoTestRunner is deprecated; it's functionality is indistinguishable from TextTestRunner(   t   warningst   warnt   PendingDeprecationWarningt   superR   t   __init__(   t   selft   argst   kwargsR   (    (    s<   /usr/local/lib/python2.6/dist-packages/django/test/simple.pyR      s
    (   t   __name__t
   __module__R   (    (    (    s<   /usr/local/lib/python2.6/dist-packages/django/test/simple.pyR      s   c      	   C   sØ   y? |  i  i d ƒ d  } t d i | t g ƒ h  h  t ƒ } Wn’ t j
 o† } d d  k } d d k l } y% | t | i	 i
 |  i ƒ g ƒ } Wn t j
 o d  } qÔ X| d o | d i ƒ  n ‚  n X| S(   Nt   .iÿÿÿÿ(   t   find_modulei    (   R   t   splitt
   __import__t   joint   TEST_MODULEt   ImportErrort   os.patht   impR   t   patht   dirnamet   __file__t   Nonet   close(   t
   app_modulet   app_patht   test_modulet   et   osR   t   mod(    (    s<   /usr/local/lib/python2.6/dist-packages/django/test/simple.pyt	   get_tests    s    )%c         C   s  t  i ƒ  } t |  d ƒ o | i |  i ƒ  ƒ nV | i t  i i |  ƒ ƒ y& | i t i |  d t	 d t
 ƒƒ Wn t j
 o n Xt |  ƒ } | o€ t | d ƒ o | i | i ƒ  ƒ q| i t  i i | ƒ ƒ y& | i t i | d t	 d t
 ƒƒ Wqt j
 o qXn | S(   sG   Create a complete Django test suite for the provided application modulet   suitet   checkert   runner(   R
   t	   TestSuitet   hasattrt   addTestR/   t   defaultTestLoadert   loadTestsFromModulet   doctestt   DocTestSuitet   doctestOutputCheckerR   t
   ValueErrorR.   (   R(   R/   R*   (    (    s<   /usr/local/lib/python2.6/dist-packages/django/test/simple.pyt   build_suite9   s,    	c   	      C   s2  |  i  d ƒ } t | ƒ d j  p t | ƒ d j o t d |  ƒ ‚ n t | d ƒ } t | ƒ } t | | d d ƒ } | d j o% | o t | | d d ƒ } q­ n y† t | t i	 t
 i	 f ƒ of t | ƒ d j oA y t i ƒ  i | ƒ SWq.t j
 o t d |  ƒ ‚ q.Xq2| | d ƒ Sn Wn t j
 o n Xg  } x¸ | | f D]ª } yŽ t i | d t d	 t ƒ} xl | D]d } | i i d
 | i d i | d ƒ f d | i d i | d ƒ f f j o | i | ƒ q‡q‡WWq\t j
 o q\Xq\W| p t d |  ƒ ‚ n t i | ƒ S(   sÙ   Construct a test case with the specified label. Label should be of the
    form model.TestClass or model.TestClass.test_method. Returns an
    instantiated test or test suite corresponding to the label provided.

    R   i   i   sN   Test label '%s' should be of the form app.TestCase or app.TestCase.test_methodi    i   s.   Test label '%s' does not refer to a test classR0   R1   s   %s.%ss   %s.__test__.%ss(   Test label '%s' does not refer to a testN(   R   t   lenR:   R   R.   t   getattrR&   t
   issubclassR
   R	   t   real_unittestt
   TestLoadert   loadTestsFromTestCaset	   TypeErrorR7   R8   R9   R   t   _dt_testt   nameR   R   t   appendR2   (	   t   labelt   partsR(   R*   t	   TestClassR   t   modulet   doctestst   test(    (    s<   /usr/local/lib/python2.6/dist-packages/django/test/simple.pyt
   build_test^   sJ    & 	 	'	c         C   s”   x |  D]… } t  | t i ƒ o t | | | ƒ q xU t t | ƒ ƒ D]0 } t  | | | ƒ o | | i | ƒ PqG qG W| d i | ƒ q Wd S(   s  
    Partitions a test suite by test type.

    classes is a sequence of types
    bins is a sequence of TestSuites, one more than classes

    Tests of type classes[i] are added to bins[i],
    tests with no match found in classes are place in bins[-1]
    iÿÿÿÿN(   t
   isinstanceR
   R2   t   partition_suitet   rangeR<   R4   (   R/   t   classest   binsRK   t   i(    (    s<   /usr/local/lib/python2.6/dist-packages/django/test/simple.pyRN   œ   s    
  	c         C   s…   t  | ƒ } g  } t | d ƒ D] } | t i ƒ  q! ~ } t |  | | ƒ x- t | ƒ D] } | d i | | d ƒ qZ W| d S(   sÜ   
    Reorders a test suite by test type.

    classes is a sequence of types

    All tests of type clases[0] are placed first, then tests of type classes[1], etc.
    Tests with no match in classes are placed last.
    i   i    (   R<   RO   R
   R2   RN   t   addTests(   R/   RP   t   class_countt   _[1]RR   RQ   (    (    s<   /usr/local/lib/python2.6/dist-packages/django/test/simple.pyt   reorder_suite±   s    	1 c   
         s/  g  } t  ƒ  ‰  x|  ot } g  } xá |  oÙ |  i ƒ  \ } \ } } t } xq | D]i }	 |	 | j oI t ‡  f d †  | |	 Dƒ ƒ o | i |	 ƒ ˆ  i |	 ƒ q½ t } qT ˆ  i |	 ƒ qT W| o# | i | | | f f ƒ t } q( | i | | | f f ƒ q( W| p t d ƒ ‚ n | }  q W| S(   sj   Reorder test_databases into an order that honors the dependencies
    described in TEST_DEPENDENCIES.
    c         3   s   x |  ] } | ˆ  j Vq Wd  S(   N(    (   t   .0t   a(   t   resolved_databases(    s<   /usr/local/lib/python2.6/dist-packages/django/test/simple.pys	   <genexpr>Ð   s   	 s(   Circular dependency in TEST_DEPENDENCIES(   t   sett   Falset   popt   TrueR   t   addRE   R   (
   t   test_databasest   dependenciest   ordered_test_databasest   changedt   deferredt	   signaturet   db_namet   aliasest   dependencies_satisfiedt   alias(    (   RY   s<   /usr/local/lib/python2.6/dist-packages/django/test/simple.pyt   dependency_orderedÁ   s4    	   !

c           B   sh   e  Z d  e e d „ Z d „  Z d
 d „ Z d „  Z d „  Z d „  Z	 d „  Z
 d „  Z d
 d	 „ Z RS(   i   c         K   s   | |  _  | |  _ | |  _ d  S(   N(   t	   verbosityt   interactivet   failfast(   R   Rj   Rk   Rl   R   (    (    s<   /usr/local/lib/python2.6/dist-packages/django/test/simple.pyR   å   s    		c         K   s   t  ƒ  t t _ t i ƒ  d  S(   N(   R   R[   R    t   DEBUGR
   t   installHandler(   R   R   (    (    s<   /usr/local/lib/python2.6/dist-packages/django/test/simple.pyR   ê   s    	c         K   sË   t  i ƒ  } | oX x| | D]I } d | j o | i t | ƒ ƒ q t | ƒ } | i t | ƒ ƒ q Wn( x$ t ƒ  D] } | i t | ƒ ƒ qu W| o" x | D] } | i | ƒ q  Wn t | t f ƒ S(   NR   (	   R
   R2   R4   RL   R   R;   R   RV   R	   (   R   t   test_labelst   extra_testsR   R/   RF   t   appRK   (    (    s<   /usr/local/lib/python2.6/dist-packages/django/test/simple.pyR;   ï   s      
  c      
   K   sM  d d k  l } l } h  } h  } h  } xÆ | D]¾ } | | } | i d o | i d | | <q/ | i | i i ƒ  | i d g  f ƒ }	 |	 d i | ƒ d | i j o | i d | | <q/ | | j o  | i i d | g ƒ | | <q/ q/ Wg  }
 g  } xì t	 | i
 ƒ  | ƒ D]Õ \ } \ } } | | d } |
 i | | t f ƒ | i i |  i d |  i ƒ} x} | d D]q } | | } | o' |
 i | | t f ƒ | | i d <qs|
 i | | t f ƒ | i i |  i d |  i ƒqsWqWxT | i
 ƒ  D]F \ } } | i | | | i d f ƒ | | i d | | i d <qùW|
 | f S(	   Niÿÿÿÿ(   t   connectionst   DEFAULT_DB_ALIASt   TEST_MIRRORt   NAMEi   t   TEST_DEPENDENCIESi    t   autoclobber(   t	   django.dbRr   Rs   t   settings_dictt
   setdefaultt   creationt   test_db_signatureRE   t   getRi   t   itemsR]   t   create_test_dbRj   Rk   R[   (   R   R   Rr   Rs   t   mirrored_aliasesR_   R`   Rh   t
   connectiont   itemt	   old_namest   mirrorsRd   Re   Rf   t   test_db_namet   mirror_alias(    (    s<   /usr/local/lib/python2.6/dist-packages/django/test/simple.pyt   setup_databases  sJ     
$  
%  c         K   s%   t  i d |  i d |  i ƒ i | ƒ S(   NRj   Rl   (   R
   t   TextTestRunnerRj   Rl   t   run(   R   R/   R   (    (    s<   /usr/local/lib/python2.6/dist-packages/django/test/simple.pyt	   run_suite;  s    c   
      K   s   d d k  l } | \ } } x% | D] \ } } | | | i d <q# WxE | D]= \ } } }	 |	 o | i i | |  i ƒ qK | | i d <qK Wd  S(   Niÿÿÿÿ(   Rr   Ru   (   Rx   Rr   Ry   R{   t   destroy_test_dbRj   (
   R   t
   old_configR   Rr   Rƒ   R„   Rh   t   old_nameR   t   destroy(    (    s<   /usr/local/lib/python2.6/dist-packages/django/test/simple.pyt   teardown_databases>  s      c         K   s   t  i ƒ  t ƒ  d  S(   N(   R
   t   removeHandlerR   (   R   R   (    (    s<   /usr/local/lib/python2.6/dist-packages/django/test/simple.pyR   K  s    
c         K   s   t  | i ƒ t  | i ƒ S(   N(   R<   t   failurest   errors(   R   R/   t   resultR   (    (    s<   /usr/local/lib/python2.6/dist-packages/django/test/simple.pyt   suite_resultO  s    c         K   s^   |  i  ƒ  |  i | | ƒ } |  i ƒ  } |  i | ƒ } |  i | ƒ |  i ƒ  |  i | | ƒ S(   s…  
        Run the unit tests for all the test labels in the provided list.
        Labels must be of the form:
         - app.TestClass.test_method
            Run a single specific test method
         - app.TestClass
            Run all the test methods in a given class
         - app
            Search for doctests and unittests in the named application.

        When looking for tests, the test runner will look in the models and
        tests modules for the application.

        A list of 'extra' tests may also be provided; these tests
        will be added to the test suite.

        Returns the number of tests that failed.
        (   R   R;   R‡   RŠ   R   R   R”   (   R   Ro   Rp   R   R/   RŒ   R“   (    (    s<   /usr/local/lib/python2.6/dist-packages/django/test/simple.pyR   R  s    

N(   R   R   R]   R   R   R&   R;   R‡   RŠ   R   R   R”   R   (    (    (    s<   /usr/local/lib/python2.6/dist-packages/django/test/simple.pyR   ä   s   		8				i   c         C   sJ   d d  k  } | i d t ƒ t d | d | d | ƒ } | i |  d | ƒS(   NiÿÿÿÿsR   The run_tests() test runner has been deprecated in favor of DjangoTestSuiteRunner.Rj   Rk   Rl   Rp   (   R   R   t   DeprecationWarningR   R   (   Ro   Rj   Rk   Rl   Rp   R   t   test_runner(    (    s<   /usr/local/lib/python2.6/dist-packages/django/test/simple.pyR   m  s    (   s   DjangoTestRunners   DjangoTestSuiteRunners	   run_tests((   R
   R?   t   django.confR    t   django.core.exceptionsR   t   django.db.modelsR   R   t   django.testR   R7   t   django.test.utilsR   R   t   django.test.testcasesR   R   R	   t   django.utilsR   t	   NameErrort   django.utils.itercompatt   __all__R   R9   Rˆ   R   R.   R;   RL   RN   RV   Ri   t   objectR   R]   R[   R&   R   (    (    (    s<   /usr/local/lib/python2.6/dist-packages/django/test/simple.pyt   <module>   s.   				%	>			#‰