ó
H`¾Tc           @   sT  d  d l  m Z d  d l  m Z m Z d  d l m Z d d l  m Z d  d l m Z d  d l m	 Z	 m
 Z
 d d	 l Z d d	 l Z d d
 l m Z m Z d e f d „  ƒ  YZ d e f d „  ƒ  YZ d d l m Z d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e e f d „  ƒ  YZ d e e e j f d „  ƒ  YZ d e f d „  ƒ  YZ d	 S(   i   (   t   config(   t
   assertionst   schema(   t   adicti   (   t   util(   t   drop_all_tables(   t   BasicEntityt   ComparableEntityiÿÿÿÿN(   t   declarative_baset   DeclarativeMetat   TestBasec           B   sD   e  Z d Z d Z d Z d Z d Z d d  „ Z d „  Z	 d „  Z
 RS(   c         C   s   | s t  | ƒ ‚ d  S(   N(   t   AssertionError(   t   selft   valt   msg(    (    sa   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/testing/fixtures.pyt   assert_)   s    c         C   s    t  |  d ƒ r |  j ƒ  n  d  S(   Nt   setUp(   t   hasattrR   (   R   (    (    sa   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/testing/fixtures.pyt   setup-   s    c         C   s    t  |  d ƒ r |  j ƒ  n  d  S(   Nt   tearDown(   R   R   (   R   (    (    sa   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/testing/fixtures.pyt   teardown1   s    (    (    (    N(   t   __name__t
   __module__t   __whitelist__t   __requires__t   __unsupported_on__t   Nonet   __only_on__t   __skip_if__R   R   R   (    (    (    sa   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/testing/fixtures.pyR
      s   	t
   TablesTestc           B   s:  e  Z d  Z d  Z d  Z d Z d Z d Z d Z	 d Z
 d Z d Z e d „  ƒ Z e d „  ƒ Z e d „  ƒ Z e d „  ƒ Z d „  Z d „  Z d „  Z d	 „  Z d
 „  Z e d „  ƒ Z e d „  ƒ Z e d „  ƒ Z e d „  ƒ Z e d „  ƒ Z e d „  ƒ Z e d „  ƒ Z d „  Z d d „ Z e d „  ƒ Z  RS(   t   oncet   eachc         C   s"   |  j  ƒ  |  j ƒ  |  j ƒ  d  S(   N(   t   _init_classt   _setup_once_tablest   _setup_once_inserts(   t   cls(    (    sa   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/testing/fixtures.pyt   setup_classO   s    

c         C   sö   |  j  d k rB |  j d k r* d |  _ n  |  j d k sB t ‚ n  |  j d  k r` t ƒ  |  _ n  |  j d  k r~ t ƒ  |  _ n  |  j d  k r¦ t	 |  d |  j
 ƒ  ƒ n  |  j d  k rÎ t	 |  d t j ƒ  ƒ n  |  j j d  k rò |  j |  j _ n  d  S(   NR   R   t   bindt   metadata(   R   N(   t   run_define_tablest   run_create_tablest   run_insertsR   R   t   otherR   t   tablesR%   t   setattrt
   setup_bindR&   t   sat   MetaData(   R#   (    (    sa   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/testing/fixtures.pyR    W   s    c         C   s*   |  j  d k r& |  j ƒ  |  j ƒ  n  d  S(   NR   (   R)   t   _load_fixturest   insert_data(   R#   (    (    sa   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/testing/fixtures.pyR"   m   s    
c         C   sa   |  j  d k r] |  j |  j ƒ |  j d k rD |  j j |  j ƒ n  |  j j |  j j ƒ n  d  S(   NR   (   R'   t   define_tablesR&   R(   t
   create_allR%   R+   t   update(   R#   (    (    sa   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/testing/fixtures.pyR!   s   s
    c         C   sØ   |  j  d k rœ |  j j ƒ  |  j d k rA t |  j |  j ƒ n  |  j j ƒ  |  j |  j ƒ |  j d k rƒ |  j j |  j ƒ n  |  j j	 |  j j ƒ n8 |  j d k rÔ t |  j |  j ƒ |  j j |  j ƒ n  d  S(   NR   (
   R'   R+   t   clearR(   R   R&   R%   R2   R3   R4   (   R   (    (    sa   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/testing/fixtures.pyt   _setup_each_tables{   s    c         C   s*   |  j  d k r& |  j ƒ  |  j ƒ  n  d  S(   NR   (   R)   R0   R1   (   R   (    (    sa   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/testing/fixtures.pyt   _setup_each_inserts‰   s    
c         C   s˜   |  j  d k r” |  j d k r” xs t |  j j ƒ D]\ } y | j ƒ  j ƒ  j ƒ  Wq1 t j	 j
 k
 rŒ } t j d | | f d t j ƒq1 Xq1 Wn  d  S(   NR   s   Error emptying table %s: %rt   file(   R'   t   run_deletest   reversedR&   t   sorted_tablest   deletet   executet   closeR.   t   exct
   DBAPIErrorR   t   print_t   syst   stderr(   R   t   tablet   ex(    (    sa   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/testing/fixtures.pyt   _teardown_each_tablesŽ   s    c         C   s   |  j  ƒ  |  j ƒ  d  S(   N(   R6   R7   (   R   (    (    sa   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/testing/fixtures.pyR   ™   s    
c         C   s   |  j  ƒ  d  S(   N(   RF   (   R   (    (    sa   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/testing/fixtures.pyR      s    c         C   sl   |  j  r t |  j |  j ƒ n  |  j d k rA |  j |  j ƒ n  d  |  j _ |  j d  k	 rh d  |  _ n  d  S(   NR   (   R(   R   R&   R%   t   run_dispose_bindt   dispose_bindR   t   run_setup_bind(   R#   (    (    sa   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/testing/fixtures.pyt   _teardown_once_metadata_bind    s    	c         C   s   |  j  ƒ  d  S(   N(   RJ   (   R#   (    (    sa   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/testing/fixtures.pyt   teardown_class­   s    c         C   s   t  j S(   N(   R    t   db(   R#   (    (    sa   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/testing/fixtures.pyR-   ±   s    c         C   s<   t  | d ƒ r | j ƒ  n t  | d ƒ r8 | j ƒ  n  d  S(   Nt   disposeR>   (   R   RM   R>   (   R#   R%   (    (    sa   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/testing/fixtures.pyRH   µ   s    c         C   s   d  S(   N(    (   R#   R&   (    (    sa   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/testing/fixtures.pyR2   ¼   s    c         C   s   i  S(   N(    (   R#   (    (    sa   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/testing/fixtures.pyt   fixturesÀ   s    c         C   s   d  S(   N(    (   R#   (    (    sa   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/testing/fixtures.pyR1   Ä   s    c         C   s   |  j  |  j | | ƒ d  S(   N(   t   assert_sql_countR%   (   R   t   countt   fn(    (    sa   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/testing/fixtures.pyt
   sql_count_È   s    c         C   s   |  j  |  j | | | ƒ d  S(   N(   t
   assert_sqlR%   (   R   t	   callable_t
   statementst   with_sequences(    (    sa   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/testing/fixtures.pyt   sql_eq_Ë   s    c      	   C   sö   i  i  } } xv |  j  ƒ  j ƒ  D]b \ } } t | ƒ d k  rD q  n  t | t j ƒ rf |  j | } n  | d | | <| d | | <q  Wxi |  j j D][ } | | k r« q“ n  |  j	 j
 | j ƒ  g  | | D] } t t | | | ƒ ƒ ^ qÈ ƒ q“ Wd S(   s4   Insert rows as represented by the fixtures() method.i   i    i   N(   RN   t   itemst   lent
   isinstanceR   t   string_typesR+   R&   R;   R%   R=   t   insertt   dictt   zip(   R#   t   headerst   rowsRD   t   datat   column_values(    (    sa   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/testing/fixtures.pyR0   Ï   s    		N(!   R   R   RI   R'   R(   R)   R9   R   RG   R%   R&   R+   R*   t   classmethodR$   R    R"   R!   R6   R7   RF   R   R   RJ   RK   R-   RH   R2   RN   R1   RR   RW   R0   (    (    (    sa   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/testing/fixtures.pyR   6   s:   						(   t   eventt   RemovesEventsc           B   s,   e  Z e j d  „  ƒ Z d „  Z d „  Z RS(   c         C   s   t  ƒ  S(   N(   t   set(   R   (    (    sa   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/testing/fixtures.pyt
   _event_fnsæ   s    c         C   s0   |  j  j | | | f ƒ t j | | | ƒ d  S(   N(   Rg   t   addRd   t   listen(   R   t   targett   nameRQ   (    (    sa   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/testing/fixtures.pyt   event_listenê   s    c         C   sP   x |  j  D] } t j | Œ  q
 Wt t |  ƒ } t | d ƒ rL | j ƒ  n  d  S(   NR   (   Rg   Rd   t   removet   superRe   R   R   (   R   t   keyt   super_(    (    sa   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/testing/fixtures.pyR   î   s
    (   R   R   R   t   memoized_propertyRg   Rl   R   (    (    (    sa   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/testing/fixtures.pyRe   å   s   	t   _ORMTestc           B   s   e  Z e d  „  ƒ Z RS(   c         C   s$   t  j j j j ƒ  t  j j ƒ  d  S(   N(   R.   t   ormt   sessiont   Sessiont	   close_allt   clear_mappers(   R#   (    (    sa   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/testing/fixtures.pyRK   ø   s    (   R   R   Rc   RK   (    (    (    sa   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/testing/fixtures.pyRr   ö   s   t   ORMTestc           B   s   e  Z RS(    (   R   R   (    (    (    sa   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/testing/fixtures.pyRx   þ   s   t
   MappedTestc           B   s¶   e  Z d  Z d Z d Z e d „  ƒ Z e d „  ƒ Z d „  Z	 d „  Z
 e d „  ƒ Z e d „  ƒ Z e d „  ƒ Z d	 „  Z e d
 „  ƒ Z d „  Z e d „  ƒ Z e d „  ƒ Z RS(   R   R   c         C   sT   |  j  ƒ  |  j d  k r( t ƒ  |  _ n  |  j ƒ  |  j ƒ  |  j ƒ  |  j ƒ  d  S(   N(   R    t   classesR   R   R!   t   _setup_once_classest   _setup_once_mappersR"   (   R#   (    (    sa   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/testing/fixtures.pyR$     s    



c         C   s   |  j  ƒ  |  j ƒ  d  S(   N(   t   _teardown_once_classRJ   (   R#   (    (    sa   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/testing/fixtures.pyRK     s    
c         C   s"   |  j  ƒ  |  j ƒ  |  j ƒ  d  S(   N(   R6   t   _setup_each_mappersR7   (   R   (    (    sa   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/testing/fixtures.pyR     s    

c         C   s+   t  j j j j ƒ  |  j ƒ  |  j ƒ  d  S(   N(   R.   Rs   Rt   Ru   Rv   t   _teardown_each_mappersRF   (   R   (    (    sa   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/testing/fixtures.pyR   !  s    
c         C   s   |  j  j ƒ  t j ƒ  d  S(   N(   Rz   R5   Rr   RK   (   R#   (    (    sa   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/testing/fixtures.pyR}   &  s    c         C   s&   |  j  d k r" |  j |  j ƒ n  d  S(   NR   (   t   run_setup_classest   _with_register_classest   setup_classes(   R#   (    (    sa   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/testing/fixtures.pyR{   +  s    c         C   s&   |  j  d k r" |  j |  j ƒ n  d  S(   NR   (   t   run_setup_mappersR   t   setup_mappers(   R#   (    (    sa   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/testing/fixtures.pyR|   0  s    c         C   s&   |  j  d k r" |  j |  j ƒ n  d  S(   NR   (   Rƒ   R   R„   (   R   (    (    sa   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/testing/fixtures.pyR~   5  s    c            s–   |  j  ‰  d t f ‡  f d †  ƒ  Y} d t j | t ƒ f d „  ƒ  Y} d t | f d „  ƒ  Y} d t | f d „  ƒ  Y} | |  _ | |  _ | ƒ  d	 S(
   s¥   Run a setup method, framing the operation with a Base class
        that will catch new subclasses to be established within
        the "classes" registry.

        t   FindFixturec              s   e  Z ‡  f d  †  Z RS(   c            s    |  ˆ  | <t  j |  | | | ƒ S(   N(   t   typet   __init__(   R#   t	   classnamet   basest   dict_(   t   cls_registry(    sa   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/testing/fixtures.pyR‡   C  s    
(   R   R   R‡   (    (   R‹   (    sa   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/testing/fixtures.pyR…   B  s   t   _Basec           B   s   e  Z RS(    (   R   R   (    (    (    sa   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/testing/fixtures.pyRŒ   G  s   t   Basicc           B   s   e  Z RS(    (   R   R   (    (    (    sa   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/testing/fixtures.pyR   J  s   t
   Comparablec           B   s   e  Z RS(    (   R   R   (    (    (    sa   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/testing/fixtures.pyRŽ   M  s   N(	   Rz   R†   R   t   with_metaclasst   objectR   R   R   RŽ   (   R#   RQ   R…   RŒ   R   RŽ   (    (   R‹   sa   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/testing/fixtures.pyR   9  s    	"		c         C   s#   |  j  d k r t j j ƒ  n  d  S(   NR   (   Rƒ   R.   Rs   Rw   (   R   (    (    sa   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/testing/fixtures.pyR   T  s    c         C   s   d  S(   N(    (   R#   (    (    sa   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/testing/fixtures.pyR‚   [  s    c         C   s   d  S(   N(    (   R#   (    (    sa   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/testing/fixtures.pyR„   _  s    N(   R   R   R€   Rƒ   R   Rz   Rc   R$   RK   R   R   R}   R{   R|   R~   R   R   R‚   R„   (    (    (    sa   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/testing/fixtures.pyRy     s   				t   DeclarativeMappedTestc           B   s2   e  Z d  Z d  Z e d „  ƒ Z e d „  ƒ Z RS(   R   c         C   s   d  S(   N(    (   R#   (    (    sa   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/testing/fixtures.pyR!   h  s    c            s˜   |  j  ‰  d t f ‡  f d †  ƒ  Y} d t f d „  ƒ  Y} t d |  j d | d | ƒ } | |  _ | ƒ  |  j j r” |  j r” |  j j t	 j
 ƒ n  d  S(   Nt   FindFixtureDeclarativec              s   e  Z ‡  f d  †  Z RS(   c            s    |  ˆ  | <t  j |  | | | ƒ S(   N(   R	   R‡   (   R#   Rˆ   R‰   RŠ   (   R‹   (    sa   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/testing/fixtures.pyR‡   q  s    
(   R   R   R‡   (    (   R‹   (    sa   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/testing/fixtures.pyR’   p  s   t   DeclarativeBasicc           B   s   e  Z e j Z RS(    (   R   R   R   t   Tablet   __table_cls__(    (    (    sa   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/testing/fixtures.pyR“   v  s   R&   t	   metaclassR#   (   Rz   R	   R   R   R&   R“   R+   R(   R3   R    RL   (   R#   RQ   R’   R“   t	   _DeclBase(    (   R‹   sa   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/testing/fixtures.pyR   l  s    			(   R   R   R€   Rƒ   Rc   R!   R   (    (    (    sa   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/testing/fixtures.pyR‘   d  s   (   t    R    R   R   R   R   t   enginesR   t   entitiesR   R   RB   t
   sqlalchemyR.   t   sqlalchemy.ext.declarativeR   R	   R   R
   R   Rd   Re   Rr   Rx   t   AssertsExecutionResultsRy   R‘   (    (    (    sa   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/testing/fixtures.pyt   <module>   s     ¬b