ó
¿b›]c           @   s=  y d  d l  Z Wn! e k
 r3 d d l m Z n Xd  d l Z d  d l Z d  d l Z d  d l Z d  d l Z y d  d l	 Z	 e
 Z Wn e k
 rŸ e Z n Xd „  Z d „  Z d „  Z d „  Z e rë d  d l Z d „  Z d	 „  Z n  d
 „  Z d „  Z d a d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d S(   iÿÿÿÿNi   (   t   plugin_basec            s9   |  j  d ƒ ‰  ‡  f d †  } t j | ƒ t j ƒ  d  S(   Nt
   sqlalchemyc            sŸ   | j  d d  ƒ ‰ ˆ rD d t j f ‡ f d †  ƒ  Y‰  ˆ  | d <n  | j  d d  ƒ ‰ ˆ r‹ d t j f ‡  ‡ f d †  ƒ  Y‰  ˆ  | d <n  ˆ j |  |  d  S(   Nt   callbackt   CallableActionc              s   e  Z d ‡  f d  † Z RS(   c            s   ˆ  | | | ƒ d  S(   N(    (   t   selft   parsert	   namespacet   valuest   option_string(   t	   callback_(    sE   lib/python2.7/site-packages/sqlalchemy/testing/plugin/pytestplugin.pyt   __call__    s    N(   t   __name__t
   __module__t   NoneR
   (    (   R	   (    sE   lib/python2.7/site-packages/sqlalchemy/testing/plugin/pytestplugin.pyR      s   t   actiont   zeroarg_callbackc              s2   e  Z e e d ‡  f d  † Z d ‡ f d † Z RS(   c            sA   t  ˆ  |  ƒ j d | d | d d d t d | d | d | ƒ d  S(	   Nt   option_stringst   destt   nargsi    t   constt   defaultt   requiredt   help(   t   supert   __init__t   True(   R   R   R   R   R   R   (   R   (    sE   lib/python2.7/site-packages/sqlalchemy/testing/plugin/pytestplugin.pyR   +   s    c            s   ˆ  | | | ƒ d  S(   N(    (   R   R   R   R   R   (   R   (    sE   lib/python2.7/site-packages/sqlalchemy/testing/plugin/pytestplugin.pyR
   =   s    N(   R   R   t   FalseR   R   R
   (    (   R   R   (    sE   lib/python2.7/site-packages/sqlalchemy/testing/plugin/pytestplugin.pyR   *   s   (   t   popR   t   argparset   Actiont	   addoption(   t   namet   kw(   t   group(   R   R	   R   sE   lib/python2.7/site-packages/sqlalchemy/testing/plugin/pytestplugin.pyt   make_option   s    "(   t   getgroupR    t   setup_optionst   read_config(   R   R"   (    (   R!   sE   lib/python2.7/site-packages/sqlalchemy/testing/plugin/pytestplugin.pyt   pytest_addoption   s    +c         C   sÆ   t  j d ƒ t |  d ƒ rC t j |  j ƒ t j |  j d ƒ n: |  j j r} t	 j
 j |  j j ƒ r} t	 j |  j j ƒ n  t j |  j ƒ t j t t |  j d t ƒ ƒ ƒ t j t  j j ƒ d  S(   Ns   sqlalchemy.testing.assertionst
   slaveinputt   follower_identt
   cov_source(   t   pytestt   register_assert_rewritet   hasattrR    t!   restore_important_follower_configR'   t   configure_followert   optiont   write_identst   ost   patht   existst   removet	   pre_begint   set_coverage_flagt   boolt   getattrR   t   set_skip_testt   skipt	   Exception(   t   config(    (    sE   lib/python2.7/site-packages/sqlalchemy/testing/plugin/pytestplugin.pyt   pytest_configureJ   s    c         C   s   t  j ƒ  d  S(   N(   R    t
   post_begin(   t   session(    (    sE   lib/python2.7/site-packages/sqlalchemy/testing/plugin/pytestplugin.pyt   pytest_sessionstart_   s    c         C   s   t  j ƒ  d  S(   N(   R    t   final_process_cleanup(   R?   (    (    sE   lib/python2.7/site-packages/sqlalchemy/testing/plugin/pytestplugin.pyt   pytest_sessionfinishc   s    c         C   sY   t  j |  j ƒ d t j ƒ  j d d !|  j d <d d l m } | j |  j d ƒ d  S(   Ns   test_%si    i   R(   iÿÿÿÿ(   t	   provision(	   R    t!   memoize_important_follower_configR'   t   uuidt   uuid4t   hext   sqlalchemy.testingRC   t   create_follower_db(   t   nodeRC   (    (    sE   lib/python2.7/site-packages/sqlalchemy/testing/plugin/pytestplugin.pyt   pytest_configure_nodej   s    !c         C   s(   d d l  m } | j |  j d ƒ d  S(   Niÿÿÿÿ(   RC   R(   (   RH   RC   t   drop_follower_dbR'   (   RJ   t   errorRC   (    (    sE   lib/python2.7/site-packages/sqlalchemy/testing/plugin/pytestplugin.pyt   pytest_testnodedownu   s    c         C   s‘  t  j d „  ƒ } g  | D]: } t | j t j ƒ r | j j j j d ƒ r | ^ q | (t d „  | Dƒ ƒ } x­ | D]¥ } xœ t	 j
 | j | j j ƒ D] } | | j k	 r™ | | j } xZ t j | j d | j j ƒj ƒ  D]1 }	 x( |	 j ƒ  D] }
 | |
 j j |
 ƒ qó Wqà Wq™ q™ Wqw Wg  } xN | D]F } | j j | k rf| j | | j j | j ƒ q-| j | ƒ q-Wt | d d „  ƒ| (d  S(   Nc           S   s   t  j t ƒ S(   N(   t   collectionst   defaultdictt   list(    (    (    sE   lib/python2.7/site-packages/sqlalchemy/testing/plugin/pytestplugin.pyt   <lambda>‡   t    t   _c         s   s   |  ] } | j  Vq d  S(   N(   t   parent(   t   .0t   item(    (    sE   lib/python2.7/site-packages/sqlalchemy/testing/plugin/pytestplugin.pys	   <genexpr>   s    RU   t   keyc         S   s%   |  j  j  j  j |  j  j  j |  j f S(   N(   RU   R   (   RW   (    (    sE   lib/python2.7/site-packages/sqlalchemy/testing/plugin/pytestplugin.pyRR   ©   s    (   RO   RP   t
   isinstanceRU   R*   t   InstanceR   t
   startswitht   setR    t   generate_sub_testst   clst   modulet   ClassR   t   collectt   appendt   extendt   sorted(   R?   R<   t   itemst   rebuilt_itemsRW   t   test_classest
   test_classt   sub_clst   per_cls_dictt   instt   tt   newitems(    (    sE   lib/python2.7/site-packages/sqlalchemy/testing/plugin/pytestplugin.pyt   pytest_collection_modifyitems{   s0    
&		"'!c         C   s‚   t  j | ƒ r1 t j | ƒ r1 t j | d |  ƒSt  j | ƒ rz t |  t j ƒ rz t j	 |  j
 | ƒ rz t j | d |  ƒSg  Sd  S(   NRU   (   t   inspectt   isclassR    t
   want_classR*   R`   t
   isfunctionRY   RZ   t   want_methodR^   t   Function(   t	   collectorR   t   obj(    (    sE   lib/python2.7/site-packages/sqlalchemy/testing/plugin/pytestplugin.pyt   pytest_pycollect_makeitem±   s    c            sq   t  ˆ  t j ƒ s d  St d  k rc t ˆ  j j ƒ ˆ  j j a ‡  f d †  } ˆ  j j j | ƒ n  t ˆ  ƒ d  S(   Nc              s   t  ˆ  j j ƒ d  a d  S(   N(   t   class_teardownRU   R   t   _current_class(    (   RW   (    sE   lib/python2.7/site-packages/sqlalchemy/testing/plugin/pytestplugin.pyt   finalizeÒ   s    (	   RY   R*   Rt   Ry   R   t   class_setupRU   t   addfinalizert
   test_setup(   RW   Rz   (    (   RW   sE   lib/python2.7/site-packages/sqlalchemy/testing/plugin/pytestplugin.pyt   pytest_runtest_setupÁ   s    c         C   s   t  |  ƒ d  S(   N(   t   test_teardown(   RW   (    (    sE   lib/python2.7/site-packages/sqlalchemy/testing/plugin/pytestplugin.pyt   pytest_runtest_teardownÜ   s    c         C   s,   t  j |  |  j j j |  j j |  j ƒ d  S(   N(   R    t   before_testRU   R_   R   R^   R   (   RW   (    (    sE   lib/python2.7/site-packages/sqlalchemy/testing/plugin/pytestplugin.pyR}   ä   s    c         C   s   t  j |  ƒ d  S(   N(   R    t
   after_test(   RW   (    (    sE   lib/python2.7/site-packages/sqlalchemy/testing/plugin/pytestplugin.pyR   ê   s    c         C   s   t  j |  j ƒ d  S(   N(   R    t   start_test_classR^   (   RW   (    (    sE   lib/python2.7/site-packages/sqlalchemy/testing/plugin/pytestplugin.pyR{   î   s    c         C   s   t  j |  j ƒ d  S(   N(   R    t   stop_test_classR^   (   RW   (    (    sE   lib/python2.7/site-packages/sqlalchemy/testing/plugin/pytestplugin.pyRx   ò   s    (   t   sqla_plugin_baseR    t   ImportErrorRS   R   RO   Ro   R1   R*   t   xdistR   t	   has_xdistR   R&   R=   R@   RB   RE   RK   RN   Rn   Rw   R   Ry   R~   R€   R}   R   R{   Rx   (    (    (    sE   lib/python2.7/site-packages/sqlalchemy/testing/plugin/pytestplugin.pyt   <module>   s<   

	2					6						