
%![c           @   s  d  Z  d d l Z d d l Z d d l m Z d d l Z d d l Z d d l Z d d l m	 Z	 m
 Z
 m Z d d l m Z m Z d d l m Z d d l m Z m Z m Z m Z d d l m Z d d	 l m Z d d
 l m Z d d l m Z d d l m Z d d l m Z d d l m Z d d l m  Z  d   Z! e
 j"   Z
 e j# d d f k  rod Z$ d Z% n e Z$ d Z% d e j& f d     YZ' d   Z( d   Z) d e  j* e j& f d     YZ+ d e j& f d     YZ, d e j& f d     YZ- d  e j& f d!     YZ. d" e j& f d#     YZ/ d$ e j& f d%     YZ0 d& e j& f d'     YZ1 d( e j& f d)     YZ2 d* e j& f d+     YZ3 d, e j& f d-     YZ4 d. e j& f d/     YZ5 d0   Z6 e7 d1 k re j8   n  d S(2   s-   tests for the astroid inference capabilities
iN(   t   partial(   t   InferenceErrort   buildert   nodes(   t   parset   extract_node(   t	   infer_end(   t   Instancet   BoundMethodt   UnboundMethodt   BUILTINS(   t	   arguments(   t
   decorators(   t
   exceptions(   t   helpers(   t   objects(   t
   test_utils(   t   util(   t	   resourcesc         C   s   t  |  j |   S(   N(   t   nextt   nodes_of_class(   t
   start_fromt   klass(    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   get_node_of_class%   s    i   i    R   t   __nonzero__t   __bool__t   InferenceUtilsTestc           B   s   e  Z d    Z RS(   c         C   sm   d   } t  j |  } t  j t  } |  j t   t | d   Wd  QX|  j t | d   d  d  S(   Nc         W   s
   t   d  S(   N(   R   (   t   selft   args(    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   infer_default5   s    i   (   t   decoratorsmodt   path_wrappert   inference_infer_endt   assertRaisesR   R   t   assertEqual(   R   R   R   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_path_wrapper4   s    	(   t   __name__t
   __module__R#   (    (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyR   2   s   c         C   sI   t  | j    } | j | |   | j t d   | j D  |  d  S(   Nc         s   s   |  ] } | j  Vq d  S(   N(   t   value(   t   .0t   elt(    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pys	   <genexpr>A   s    (   R   t   infert   assertIsInstanceR"   t   sortedt   elts(   t	   node_typeR   t   nodeR,   t   inferred(    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   _assertInferElts>   s    c            s      f d   S(   s{   similar to functools.partial but return a lambda instead of a class so returned value may be
    turned into a method.
    c             s      |  |  S(   N(    (   R   t   kwargs(   t   argt   func(    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   <lambda>H   s    (    (   R3   R2   (    (   R2   R3   s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   partialmethodD   s    t   InferenceTestc           B   s	  e  Z d    Z d   Z e e e j  Z e e e j	  Z
 e e e j  Z e e e j  Z d Z e e e   Z d   Z d   Z d   Z d   Z d   Z d   Z d	   Z d
   Z d   Z d   Z d   Z d   Z d   Z d   Z  d   Z! d   Z" d   Z# d   Z$ d   Z% d   Z& d   Z' d   Z( d   Z) d   Z* d   Z+ d   Z, d   Z- d   Z. d   Z/ e0 j1 d  d!  d"    Z2 e3 j4 d#    Z5 d$   Z6 d%   Z7 d&   Z8 d'   Z9 d(   Z: d)   Z; d*   Z< d+   Z= d,   Z> d-   Z? d.   Z@ d/   ZA d0   ZB d1   ZC d2   ZD eE jF d3 k rOe3 j4 eD  ZD n  d4   ZG d5   ZH d6   ZI d7   ZJ d8   ZK d9   ZL d:   ZM e0 j1 d; d<  d=    ZN d>   ZO d?   ZP d@   ZQ dA   ZR dB   ZS dC   ZT dD   ZU dE   ZV dF   ZW dG   ZX dH   ZY dI   ZZ dJ   Z[ dK   Z\ dL   Z] dM   Z^ dN   Z_ dO   Z` dP   Za dQ   Zb dR   Zc dS   Zd dT   Ze dU   Zf dV   Zg dW   Zh dX   Zi dY   Zj dZ   Zk d[   Zl d\   Zm d]   Zn d^   Zo d_   Zp d`   Zq da   Zr db   Zs dc   Zt dd   Zu de   Zv df   Zw dg   Zx dh   Zy di   Zz dj   Z{ dk   Z| e0 j1 d<  dl    Z} e0 j1 d<  dm    Z~ e0 j1 d<  dn    Z e0 j1 d<  do    Z e0 j1 d<  dp    Z e0 j1 d<  dq    Z e0 j1 d<  dr    Z e0 j1 d<  ds    Z dt   Z du   Z dv   Z dw   Z e0 j1 d!  dx    Z dy   Z dz   Z e0 j1 d<  d{    Z d|   Z d}   Z d~   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z e3 j4 d    Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z e3 j4 d    Z d   Z d   Z d   Z d   Z d   Z d   Z e3 j4 d    Z e0 j1 d; d!  d    Z d   Z e0 j1 d  d!  d    Z d   Z d   Z e3 j4 d    Z d   Z RS(   c         C   s<   t  | j    } |  j | t j  |  j | j |  d  S(   N(   R   R)   R*   R   t   ConstR"   R&   (   R   R.   t   expectedR/   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   assertInferConstN   s    c         C   s   t  | j    } |  j | t j  t g  | j D] \ } } | j | j f ^ q2  } |  j t	 |  t	 | j     d  S(   N(
   R   R)   R*   R   t   Dictt   sett   itemsR&   R"   R+   (   R   R.   R8   R/   t   keyR&   R,   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   assertInferDictS   s
    .s  
        class C(object):
            "new style"
            attr = 4

            def meth1(self, arg1, optarg=0):
                var = object()
                print ("yo", arg1, optarg)
                self.iattr = "hop"
                return var

            def meth2(self):
                self.meth1(*self.meth3)

            def meth3(self, d=attr):
                b = self.attr
                c = self.iattr
                return b, c

        ex = Exception("msg")
        v = C().meth1(1)
        m_unbound = C.meth1
        m_bound = C().meth1
        a, b, c = ex, 1, "bonjour"
        [d, e, f] = [ex, 1.0, ("bonjour", v)]
        g, h = f
        i, (j, k) = "glup", f

        a, b= b, a # Gasp !
        c         C   sL   t  d  } t | d j    } |  j | t j  |  j | j d  d  S(   Ns   
        import abc

        class A(object):
            @abc.abstractproperty
            def test(self):
                return 42

        a = A()
        x = a.test
        t   xi*   (   R   R   R)   R*   R   R7   R"   R&   (   R   t   moduleR/   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt*   test_infer_abstract_property_return_values   s
    
	c         C   sd   |  j  j   } t |  } |  j | j t  |  j | j   j t  |  j t t	 t |   d  S(   N(
   t   astR)   R   R"   t   nameR$   t   rootR!   t   StopIterationR    (   R   R/   t   obj(    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_module_inference   s
    c         C   sh   |  j  d j   } t |  } |  j | j d  |  j | j   j t  |  j t t	 t |   d  S(   Nt   C(
   RB   R)   R   R"   RC   RD   R$   R!   RE   R    (   R   R/   RF   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_class_inference   s
    c         C   sl   |  j  d d j   } t |  } |  j | j d  |  j | j   j t  |  j t t	 t |   d  S(   NRH   t   meth1(
   RB   R)   R   R"   RC   RD   R$   R!   RE   R    (   R   R/   RF   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_function_inference   s
    c         C   sp   |  j  d d d j   } t |  } |  j | j d  |  j | j   j t  |  j t t	 t |   d  S(   NRH   RJ   t   vart   object(
   RB   R)   R   R"   RC   RD   R
   R!   RE   R    (   R   R/   RL   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_builtin_name_inference   s
    c         C   s4  |  j  d j   } t |  } |  j | t  |  j | j d  |  j | j   j t  |  j	 t
 t t |   |  j  d j   } t |  } |  j | t j  |  j | j d  |  j	 t
 t t |   |  j  d j   } t |  } |  j | t j  |  j | j d  |  j	 t
 t t |   d  S(   Nt   at	   Exceptiont   bi   t   ct   bonjour(   RB   R)   R   R*   R   R"   RC   RD   t
   EXC_MODULER!   RE   R    R   R7   R&   (   R   R/   t   exct   const(    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_tupleassign_name_inference   s     c         C   s!  |  j  d j   } t |  } |  j | t  |  j | j d  |  j | j   j t  |  j	 t
 t t |   |  j  d j   } t |  } |  j | t j  |  j | j d  |  j	 t
 t t |   |  j  d j   } t |  } |  j | t j  |  j	 t
 t t |   d  S(   Nt   dRP   t   eg      ?t   f(   RB   R)   R   R*   R   R"   RC   RD   RT   R!   RE   R    R   R7   R&   t   Tuple(   R   R/   RU   RV   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_listassign_name_inference   s    c         C   s   |  j  d j   } t |  } |  j | t j  |  j | j d  |  j t	 t
 t |   |  j  d j   } t |  } |  j | j d  |  j | j   j t  |  j t	 t
 t |   d  S(   Nt   gRS   t   hRM   (   RB   R)   R   R*   R   R7   R"   R&   R!   RE   R    RC   RD   R
   (   R   R/   RV   RL   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt)   test_advanced_tupleassign_name_inference1   s    c         C   s$  |  j  d j   } t |  } |  j | t j  |  j | j d  |  j t	 t
 t |   |  j  d j   } t |  } |  j | t j  |  j | j d  |  j t	 t
 t |   |  j  d j   } t |  } |  j | j d  |  j | j   j t  |  j t	 t
 t |   d  S(   Nt   iu   glupt   jRS   t   kRM   (   RB   R)   R   R*   R   R7   R"   R&   R!   RE   R    RC   RD   R
   (   R   R/   RV   RL   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt)   test_advanced_tupleassign_name_inference2   s    c         C   s   |  j  j d d j   } t |  } |  j | t j  |  j | j d  |  j	 t
 t t |   |  j  j d d j   } t |  } |  j | t  |  j | j d  |  j | j   j t  |  j	 t
 t t |   d  S(   NRO   i   RQ   RP   (   RB   t   localsR)   R   R*   R   R7   R"   R&   R!   RE   R    R   RC   RD   RT   (   R   R/   RV   RU   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_swap_assign_inference   s    c         C   sx   |  j  d j   } t |  } |  j | t  |  j | j d  |  j | j   j t  |  j	 t
 t t |   d  S(   Nt   exRP   (   RB   R)   R   R*   R   R"   RC   RD   RT   R!   RE   R    (   R   R/   RU   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_getattr_inference1   s    c         C   sx   t  |  j d d t j  j   } t |  } |  j | j d  |  j | j   j t	  |  j
 t t t |   d  S(   NRH   t   meth2RJ   (   R   RB   R   t	   AttributeR)   R   R"   RC   RD   R$   R!   RE   R    (   R   R/   RJ   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_getattr_inference2  s
    #c         C   sj   |  j  d d d j   } t |  } |  j | t j  |  j | j d  |  j t	 t
 t |   d  S(   NRH   t   meth3RQ   i   (   RB   R)   R   R*   R   R7   R"   R&   R!   RE   R    (   R   R/   RV   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_getattr_inference3	  s
    c         C   sj   |  j  d d d j   } t |  } |  j | t j  |  j | j d  |  j t	 t
 t |   d  S(   NRH   Rk   RR   t   hop(   RB   R)   R   R*   R   R7   R"   R&   R!   RE   R    (   R   R/   RV   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_getattr_inference4  s
    c         C   sx   |  j  d j   } t |  } |  j | t  |  j | j d  |  j | j   j t  |  j	 t
 t t |   d  S(   Nt   vRM   (   RB   R)   R   R*   R   R"   RC   RD   R
   R!   RE   R    (   R   R/   RJ   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_callfunc_inference  s    c         C   s{   |  j  d j   } t |  } |  j | t  |  j | j d  |  j | j j   j d  |  j	 t
 t t |   d  S(   Nt	   m_unboundRJ   RH   (   RB   R)   R   R*   R	   R"   RC   t   parentt   frameR!   RE   R    (   R   R/   RJ   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_unbound_method_inference  s    c         C   s{   |  j  d j   } t |  } |  j | t  |  j | j d  |  j | j j   j d  |  j	 t
 t t |   d  S(   Nt   m_boundRJ   RH   (   RB   R)   R   R*   R   R"   RC   Rr   Rs   R!   RE   R    (   R   R/   RJ   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_bound_method_inference'  s    c         C   s   t  j |  j d d d  } | j   } t |  } |  j | t j  |  j | j	 d  t |  } |  j
 | t j |  |  j t t t |   d  S(   NRH   RJ   t   optargi    (   R   t   get_name_nodeRB   R)   R   R*   R   R7   R"   R&   t   assertIsR   t   UninferableR!   RE   R    (   R   Rw   R/   t   obj1(    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_args_default_inference1/  s    c         C   s   |  j  d d j d  } t |  } |  j | t j  |  j | j d  t |  } |  j | t	 j
 |  |  j t t t |   d  S(   NRH   Rk   RX   i   (   RB   t   ilookupR   R*   R   R7   R"   R&   Ry   R   Rz   R!   RE   R    (   R   R/   R{   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_args_default_inference29  s    c         C   sb   t  j |  j d d d  j   } t |  } |  j | t j |  |  j t	 t
 t |   d  S(   NRH   RJ   t   arg1(   R   Rx   RB   R)   R   Ry   R   Rz   R!   RE   R    (   R   R/   R{   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_inference_restrictionsB  s    #c         C   s[   d } t  | t  \ } } t | j    } |  j t |  d  |  j | d |  d  S(   Nsq   
            class A(object):  #@
                pass

            class A(A):  #@
                pass
        i   i    (   R   R$   t   listt	   ancestorsR"   t   lenRy   (   R   t   codet   a1t   a2t   a2_ancestors(    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_ancestors_inferenceH  s
    c         C   sr   d } t  | t  \ } } } t | j    } |  j t |  d  |  j | d |  |  j | d |  d  S(   Ns   
            class A(object):  #@
                pass

            class B(A):  #@
                pass

            class A(B):  #@
                pass
        i   i    i   (   R   R$   R   R   R"   R   Ry   (   R   R   R   RQ   R   R   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_ancestors_inference2U  s    
c         C   s\   d } t  | t  } | d } | j   } |  j | d j d  |  j t |  d  d  S(   NsO   
            def f(f=1):
                return f

            a = f()
        RO   i    i   (   R   R$   R/   R"   R&   R   (   R   R   RB   RO   t
   a_inferred(    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_f_arg_ff  s    
c      	   C   su   d } t  | t  } | d } t j d t  > } t j t   | j   Wd  QX|  j	 | d j
 t  Wd  QXd  S(   NsO   
            def f(f=1):
                return f

            a = f()
        RO   t   recordi    (   R   R$   t   warningst   catch_warningst   TrueR   t   enable_warningt   PendingDeprecationWarningt   inferedR*   t   message(   R   R   RB   RO   t   w(    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_infered_warnings  s    
c         C   s   d } t  | t  } | j   d } |  j | t j  g  | j   D] } | j ^ qE } t j	 d	 k  r d d d d d g } |  j
 | |  n" d d d d g } |  j
 | |  d  S(
   NsD   
        def f():
            raise __(NotImplementedError)
        i    i   t   RuntimeErrort   StandardErrorRP   t   BaseExceptionRM   (   i   i    (   R   R$   R/   R*   R   t   ClassDefR   RC   t   syst   version_infoR"   (   R   R   t   errort   nieRR   t   nie_ancestorsR8   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_exc_ancestors  s    "c         C   s   d } t  | t  } | d } | j   } t |  } |  j | t  |  j | j d  |  j t	 t
 t |   | d } | j   } t |  } |  j | t  |  j | j d  |  j t	 t
 t |   d  S(   Ns   
            try:
                print (hop)
            except NameError as ex:
                ex1 = ex
            except Exception as ex:
                ex2 = ex
                raise
        t   ex1t	   NameErrort   ex2RP   (   R   R$   R)   R   R*   R   R"   RC   R!   RE   R    (   R   R   RB   R   t	   ex1_inferR   t	   ex2_infer(    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_except_inference  s    	

c         C   s,   d } t  | t  } |  j t | j  d  S(   Ns(   
            del undefined_attr
        (   R   R$   R!   R   R)   (   R   R   t   delete(    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt	   test_del1  s    c         C   s
  d } t  | t  } | d } | j   } t |  } |  j | t j  |  j | j d  |  j	 t
 t t |   | d } | j   } |  j	 t t t |   | d } | j   } t |  } |  j | t j  |  j | j d  |  j	 t
 t t |   d  S(   Nsu   
            a = 1
            b = a
            del a
            c = a
            a = 2
            d = a
        RQ   i   RR   RX   i   (   R   R$   R)   R   R*   R   R7   R"   R&   R!   RE   R    R   (   R   R   RB   t   nt   n_inferR/   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt	   test_del2  s"    


c         C   s  d } t  | t  } | d } t | j    } |  j | t j  |  j | t  |  j | j	 t j
 d   j d  |  j | j t j  |  j | j j d  |  j d | j j  | d } t | j    } |  j | t j  |  j | t  |  j | j	 t j
 d   j d  |  j | j t j  |  j | j j d	  | d
 } t | j    } |  j | t j  |  j | t  |  j | j t j  |  j | j j d  |  j d | j j  | d } t | j    } |  j | t j
  |  j | t  |  j | j d  |  j d | j j  | d } t | j    } |  j | j	 t j
 d   j d  d } t  | t  } | d } t | j    } |  j | t j  |  j | t  |  j | j d  |  j d | j j  d  S(   Nsm   
            l = [1]
            t = (2,)
            d = {}
            s = ''
            s2 = '_'
        t   li    i   R   t   appendt   ti   t   tupleRX   t   dictt   gett   st   strt   lowert   s2t   _s   s = {1}R;   t   remove(   R   R$   R   R)   R*   R   t   ListR   R"   t   getitemR7   R&   t   _proxiedR   RC   t   assertInRd   R[   R:   t   Set(   R   R   RB   R   R/   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_builtin_types  sR    
%
%


%
t   maxvers   3.0c         C   s   d } t  | t  } | d } t | j    } |  j | t j  |  j | t  |  j | j	 d  |  j
 d | j j  d  S(   Ns   u = u""t   ut   unicodeR   (   R   R$   R   R)   R*   R   R7   R   R"   RC   R   R   Rd   (   R   R   RB   R   R/   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_unicode_type  s    
c         C   sq   d } t  | t  } t | d j d   } |  j | j    t | d j d   } |  j | j    d  S(   Nsx   
            class A:
                statm = staticmethod(open)
                clsm = classmethod('whatever')
        t   At   statmt   clsm(   R   R$   R   t   igetattrt
   assertTruet   callablet   assertFalse(   R   R   RB   R   R   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_descriptor_are_callable	  s    c         C   s(  d } t  | t  } | d } | j   } t |  } |  j | j d  |  j | j   j t  t |  } |  j | j d  |  j | j   j t  t |  } |  j | j d  |  j | j   j t  t |  } |  j | j d  |  j | j   j t  |  j	 t
 t t |   d  S(   NsB   
            class Warning(Warning):
                pass
        t   WarningRP   R   RM   (   R   R$   R   R   R"   RC   RD   RT   R
   R!   RE   R    (   R   R   RB   R   R   t   ancestor(    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_bt_ancestor_crash  s"    
c         C   sR   d } t  | t  } | d } |  j d   | j   D t j t j j h  d  S(   Ns   
            from astroid.modutils import load_module_from_name
            xxx = load_module_from_name('__pkginfo__')
        t   xxxc         S   s   h  |  ] } | j   q S(    (   t	   __class__(   R'   R   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pys	   <setcomp>3  s   	 (	   R   R$   t   assertSetEqualR/   R   R7   R   Rz   R   (   R   R   RB   R   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt	   test_qqch,  s
    
c         C   s  d } t  | t  } t j | d d d  } |  j g  | j   D] } | j ^ qB t j j g  t j | d d d  } |  j g  | j   D] } | j ^ q t	 j
 g  t j | d d d  } |  j g  | j   D] } | j ^ q t j j g  t j | d d d  } |  j g  | j   D] } | j ^ q,t	 j g  t j | d d d  } |  j g  | j   D] } | j ^ qxt	 j
 g  d  S(   Ns  
            class ErudiEntitySchema:
                """a entity has a type, a set of subject and or object relations"""
                def __init__(self, e_type, **kwargs):
                    kwargs['e_type'] = e_type.capitalize().encode()

                def meth(self, e_type, *args, **kwargs):
                    kwargs['e_type'] = e_type.capitalize().encode()
                    print(args)
            t   ErudiEntitySchemat   __init__t   e_typeR1   t   methR   (   R   R$   R   Rx   R"   R)   R   R   Rz   R   R:   R[   (   R   R   RB   R2   R   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_method_argument6  s"    
%%%%%c         C   sw   d } t  | t  } | j   } t |  } |  j | t j  |  j | j g   |  j	 t
   t |  Wd  QXd  S(   Ns~   
            def test_view(rql, vid, tags=()):
                tags = list(tags)
                __(tags).append(vid)
        (   R   R$   R)   R   R*   R   R   R"   R,   R!   RE   (   R   R   RC   t   itt   tags(    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_tuple_then_listR  s    c         C   s   d } t  | t  } |  j t t | d j d     d  |  j t t | d j     d  d d d g } |  j t	 d   t
 | d	 j   |  D   d  S(
   Ns  
            def first_word(line):
                """Return the first word of a line"""

                return line.split()[0]

            def last_word(line):
                """Return last word of a line"""

                return line.split()[-1]

            def process_line(word_pos):
                """Silly function: returns (ok, callable) based on argument.

                   For test purpose only.
                """

                if word_pos > 0:
                    return (True, first_word)
                elif word_pos < 0:
                    return  (True, last_word)
                else:
                    return (False, None)

            if __name__ == '__main__':

                line_number = 0
                for a_line in file('test_callable.py'):
                    tupletest  = process_line(line_number)
                    (ok, fct)  = process_line(line_number)
                    if ok:
                        fct(a_line)
        t   process_linei   t	   tupletests   <FunctionDef.first_words   <FunctionDef.last_words   <Const.NoneTypec         s   s*   |  ]  \ } } t  |  j |  Vq d  S(   N(   t   reprt
   startswith(   R'   R/   R&   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pys	   <genexpr>  s    t   fct(   R   R$   R"   R   R   t   infer_call_resultt   NoneR)   R   t   allt   zip(   R   R   RB   t   values(    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_mulassign_inference`  s    !)&	c         C   s   d } t  | t  \ } } |  j g  | j d  D] } | j ^ q1 d d g  |  j g  | j   D] } | j ^ qc d d g  d  S(   Ns  
            def no_conjugate_member(magic_flag):  #@
                """should not raise E1101 on something.conjugate"""
                if magic_flag:
                    something = 1.0
                else:
                    something = 1.0j
                if isinstance(something, float):
                    return something
                return __(something).conjugate()
        t	   somethingg      ?y              ?(   R   R$   R"   R}   R&   R)   (   R   R   R3   t   retvalR`   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_float_complex_ambiguity  s    "c         C   s`   d } t  | t  } g  t j | d d  j   D] } | j ^ q1 } |  j | d d g  d  S(   Ns  
            def no_conjugate_member(magic_flag):
                """should not raise E1101 on something.conjugate"""
                something = 1.0
                if magic_flag:
                    something = 1.0j
                return something.conjugate()
        R   ig      ?y              ?(   R   R$   R   Rx   R)   R&   R"   (   R   R   RB   R`   R   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_lookup_cond_branches  s    1c      
   C   s   d } t  | t  } d d d d d d d d d d	 g
 } xU t | |  D]D \ } } t | j    } |  j | t j  |  j | j	 |  qI Wd  S(
   Ns  
            class A(object):
                def __getitem__(self, index):
                    return index + 42
            [1, 2, 3][0] #@
            (1, 2, 3)[1] #@
            (1, 2, 3)[-1] #@
            [1, 2, 3][0] + (2, )[0] + (3, )[-1] #@
            e = {'key': 'value'}
            e['key'] #@
            "first"[0] #@
            list([1, 2, 3])[-1] #@
            tuple((4, 5, 6))[2] #@
            A()[0] #@
            A()[-1] #@
        i   i   i   i   R&   RZ   i*   i)   (
   R   R$   R   R   R)   R*   R   R7   R"   R&   (   R   R   t	   ast_nodesR8   R.   t   expected_valueR/   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_simple_subscript  s    $c         C   s   t  d  } x+ | d  D] } |  j t t | j    q Wx1 | d D]% } |  j t | j    t j  qE Wt  d  } x' | D] } |  j t t | j    q Wd  S(   Ns'  
        class NoGetitem(object):
            pass
        class InvalidGetitem(object):
            def __getitem__(self): pass
        class InvalidGetitem2(object):
            __getitem__ = 42
        NoGetitem()[4] #@
        InvalidGetitem()[5] #@
        InvalidGetitem2()[10] #@
        i   s>   
        [1, 2, 3][None] #@
        'lala'['bala'] #@
        (   R   R!   R   R   R)   R"   R   Rz   (   R   R   R.   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_invalid_subscripts  s    
	#	c         C   sg   t  d  } t | j    } |  j | t j  t j rP |  j | j	 d  n |  j | j	 d  d  S(   Ns   b'a'[0]RO   ia   (
   R   R   R)   R*   R   R7   t   sixt   PY2R"   R&   (   R   R.   R/   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_bytes_subscript  s    	c         C   s   t  d  } t | d j    } |  j | t j  |  j t | j  d  |  j | j d j	 d  |  j | j d j	 d  d  S(   NsD   
        a = (1,)
        b = (22,)
        some = a + b #@
        t   somei   i    i   i   (
   R   R   R)   R*   R   R[   R"   R   R,   R&   (   R   R@   RB   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_simple_tuple  s    	c         C   sa  d } t  | t  } |  j g  t j | d d  j   D] } | j ^ q7 d d d g  |  j g  t j | d d  j   D] } | j ^ q{ d d g  |  j g  t j | d d  j   D] } | j ^ q d d	 g  |  j g  t j | d
 d  j   D] } | j ^ q d d	 g  |  j g  t j | d d  j   D] } | j ^ q>d d g  d  S(   Ns   
            for a in [1, 2, 3]:
                print (a)
            for b,c in [(1,2), (3,4)]:
                print (b)
                print (c)

            print ([(d,e) for e,d in ([1,2], [3,4])])
        RO   ii   i   i   RQ   RR   i   RX   RY   (   R   R$   R"   R   Rx   R)   R&   (   R   R   RB   R`   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_simple_for  s    		;	8	8	8	c         C   s   d } t  | t  } |  j g  t j | d d  j   D] } | j ^ q7 d d g  |  j g  t j | d d  j   D] } | j ^ qx d d g  d  S(	   Ns=   
            print ((d,e) for e,d in ([1,2], [3,4]))
        RX   ii   i   RY   i   i   (   R   R$   R"   R   Rx   R)   R&   (   R   R   RB   R`   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_simple_for_genexpr  s    	8	c         C   sr   d } t  | t  } t | j j    } |  j t |  d |  |  j | d t  |  j | d j	 d  d  S(   Ns   
            help()
        i   i    t   _Helper(
   R   R$   R   R3   R)   R"   R   R*   R   RC   (   R   R   R.   R/   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_builtin_help  s    c         C   s   d } t  | t  j } t | j    } |  j t |  d  t t d  r |  j	 | d t
 j  |  j | d j d  n. |  j	 | d t
 j  |  j | d j d  d  S(   Ns&   
            open("toto.txt")
        i   t   pypy_version_infoi    t   filet   open(   R   R$   R3   R   R)   R"   R   t   hasattrR   R*   R   R   RC   t   FunctionDef(   R   R   R.   R/   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_builtin_open  s    t   javac         C   sr   d } t  | t  } t | j d   } |  j t |  d  |  j | d t j  |  j | d j	 d  d  S(   Nsb   
            def mirror(arg=None):
                return arg

            un = mirror(1)
        t   uni   i    (
   R   R$   R   R   R"   R   R*   R   R7   R&   (   R   R   RB   R/   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_callfunc_context_func.  s    c         C   s   d } t  | t  } t | j d   } |  j t |  d  |  j | d t j  t | j d   } |  j t |  d  |  j | d t j	  |  j | d j
 d  d  S(   NsK   
            mirror = lambda x=None: x

            un = mirror(1)
        t   mirrori   i    R   (   R   R$   R   R   R"   R   R*   R   t   LambdaR7   R&   (   R   R   RB   R/   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_callfunc_context_lambda;  s    c         C   sr   d } t  | t  } t | j d   } |  j t |  d  |  j | d t  |  j | d j j	 d  d  S(   Ns,  
            class Super(object):
                  @classmethod
                  def instance(cls):
                          return cls()

            class Sub(Super):
                  def method(self):
                          print ('method called')

            sub = Sub.instance()
        t   subi   i    t   Sub(
   R   R$   R   R   R"   R   R*   R   R   RC   (   R   R   RB   R/   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_factory_methodJ  s    c         C   s   d } t  | t  } t | j d   } |  j t |  d  |  j | d t j  |  j | d j	 d  t | j d   } |  j t |  d  |  j | d t j
  |  j | d j	 d  d  S(   Ns   
            import os.path as osp
            print (osp.dirname(__file__))

            from os.path import exists as e
            assert e(__file__)
        t   ospi   i    s   os.pathRY   t   exists(   R   R$   R   R   R"   R   R*   R   t   ModuleRC   R   (   R   R   RB   R/   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_import_as^  s    c         C   sZ   t  | j    } |  j t |  d  |  j | d t j  |  j | d j |  d  S(   Ni   i    (   R   R)   R"   R   R*   R   R7   R&   (   R   R.   R&   R/   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   _test_const_inferredp  s    c         C   sR   xK d
 D]C } t  j | t t  } |  j | d t  |  j | d	 t  q Wd  S(   Ns   a = not (1,); b = not ()s   a = not {1:2}; b = not {}s   a = not [1, 2]; b = not []s   a = not {1, 2}; b = not set()s   a = not 1; b = not 0s   a = not "a"; b = not ""s   a = not b"a"; b = not b""RO   RQ   (   s   a = not (1,); b = not ()s   a = not {1:2}; b = not {}s   a = not [1, 2]; b = not []s   a = not {1, 2}; b = not set()s   a = not 1; b = not 0s   a = not "a"; b = not ""s   a = not b"a"; b = not b""(   R   t   string_buildR$   t   __file__R  t   FalseR   (   R   R   RB   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_unary_notv  s         
c         C   sj   t  d  } d d d d d g } xB t | |  D]1 \ } } t | j    } |  j | j |  q1 Wd  S(   NsS   
        +1 #@
        -1 #@
        ~1 #@
        +2.0 #@
        -2.0 #@
        i   iig       @g       (   R   R   R   R)   R"   R&   (   R   R   R8   R.   R   R/   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_unary_op_numbers  s    	t   minvers   3.5c         C   sH   t  d  } t | j    } |  j | t j  |  j | j d  d  S(   Ns~   
        class Array:
            def __matmul__(self, other):
                return 42
        Array() @ Array() #@
        i*   (   R   R   R)   R*   R   R7   R"   R&   (   R   R.   R/   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_matmul  s
    	c         C   s-   t  j d t t  } |  j | d d  d  S(   Ns	   a = 1 + 2RO   i   (   R   R  R$   R	  R  (   R   RB   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_binary_op_int_add  s    c         C   s-   t  j d t t  } |  j | d d  d  S(   Ns	   a = 1 - 2RO   i(   R   R  R$   R	  R  (   R   RB   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_binary_op_int_sub  s    c         C   s1   t  j d t t  } |  j | d d d  d  S(   Ns
   a = 1 / 2.RO   i   g       @(   R   R  R$   R	  R  (   R   RB   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_binary_op_float_div  s    c         C   s1   t  j d t t  } |  j | d d d  d  S(   Ns   a = "*" * 40RO   t   *i(   (   R   R  R$   R	  R  (   R   RB   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_binary_op_str_mul  s    c         C   s-   t  j d t t  } |  j | d d  d  S(   Ns	   a = 23&20RO   i   i   i   (   R   R  R$   R	  R  (   R   RB   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_binary_op_int_bitand  s    c         C   s-   t  j d t t  } |  j | d d  d  S(   Ns   a = 23|8RO   i   i   i   (   R   R  R$   R	  R  (   R   RB   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_binary_op_int_bitor  s    c         C   s-   t  j d t t  } |  j | d d  d  S(   Ns   a = 23^9RO   i   i	   i   (   R   R  R$   R	  R  (   R   RB   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_binary_op_int_bitxor  s    c         C   s-   t  j d t t  } |  j | d d  d  S(   Ns
   a = 23 >>1RO   i   i   i   (   R   R  R$   R	  R  (   R   RB   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_binary_op_int_shiftright  s    c         C   s-   t  j d t t  } |  j | d d  d  S(   Ns
   a = 23 <<1RO   i   i   i.   (   R   R  R$   R	  R  (   R   RB   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_binary_op_int_shiftleft  s    c         C   su   t  d  } t | d j    } |  j | t j  |  j | j d  t | d j    } |  j | t j	  d  S(   Ns   
        class A:
            def __add__(self, other):
                return other + 42
        A() + 1 #@
        1 + A() #@
        i    i+   i   (
   R   R   R)   R*   R   R7   R"   R&   R   Rz   (   R   R   t   firstt   second(    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_binary_op_other_type  s    	c         C   su   t  d  } t | d j    } |  j | t j  t | d j    } |  j | t j  |  j | j	 d  d  S(   Ns   
        class A(object):
            def __radd__(self, other):
                return other + 42
        A() + 1 #@
        1 + A() #@
        i    i   i+   (
   R   R   R)   R"   R   Rz   R*   R   R7   R&   (   R   R   R  R  (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt2   test_binary_op_other_type_using_reflected_operands  s    	c         C   s5   t  d  } t | j    } |  j | t j  d  S(   Nss   
        class A(object):
            def __radd__(self, other): return NotImplemented

        1 + A() #@
        (   R   R   R)   R"   R   Rz   (   R   t   ast_nodeR  (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt:   test_binary_op_reflected_and_not_implemented_is_type_error  s    	c         C   s   x d D] } t  j | t t  } t | d j    } |  j t |  d  |  j | d t	 j
  |  j t | d j  d  |  j | d j d t	 j
  |  j | d j d t	 j
  q Wd  S(   Ns   a = [[]] * 2s   a = 2 * [[]]RO   i   i    i   (   s   a = [[]] * 2s   a = 2 * [[]](   R   R  R$   R	  R   R)   R"   R   R*   R   R   R,   (   R   R   RB   R/   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_binary_op_list_mul  s    c         C   s   t  j d  } | d j   } |  j t |  d  |  j | d t j  | d j   } |  j t |  d  |  j | d t j  d S(   s0   test correct handling on list multiplied by Nones   a = [1] * None
b = [1] * "r"RO   i   i    RQ   N(   R   R  R/   R"   R   R   Rz   (   R   RB   R/   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_binary_op_list_mul_none  s    c         C   sx   d } t  | t  } | d j   } |  j t |  d  | d } |  j | t j  |  j t | j    d  d S(   sL   test correct handling on list multiplied by int when there are more than onesF   
        from ctypes import c_int
        seq = [c_int()] * 4
        t   seqi   i    i   N(	   R   R$   R/   R"   R   R*   R   R   t   itered(   R   R   RB   R/   t   listval(    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_binary_op_list_mul_int  s    
c         C   s@   d } t  | t  } | d j   } |  j | d t j  d S(   s9   test correct handling of applying binary operator to selfs|   
        import sys
        sys.path = ['foo'] + sys.path
        sys.path.insert(0, 'bar')
        path = sys.path
        t   pathi    N(   R   R$   R/   R*   R   R   (   R   R   RB   R/   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_binary_op_on_self  s    c         C   s   t  j d t t  } t | d j    } |  j t |  d  |  j | d t	 j
  |  j t | d j  d  |  j | d j d j d  |  j | d j d j d  d  S(   Ns   a = (1,) + (2,)RO   i   i    i   (   R   R  R$   R	  R   R)   R"   R   R*   R   R[   R,   R&   (   R   RB   R/   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_binary_op_tuple_add  s    c         C   s   d } t  | t  } t | j d   } |  j t |  d  g  | D] } t |  ^ qG } |  j | d t d t g  d  S(   Ns  
        class myarray:
            def __init__(self, array):
                self.array = array
            def __mul__(self, x):
                return myarray([2,4,6])
            def astype(self):
                return "ASTYPE"

        def randint(maximum):
            if maximum is not None:
                return myarray([1,2,3]) * 2
            else:
                return int(5)

        x = randint(1)
        R?   i   s   Instance of %s.myarrays   Instance of %s.int(   R   R$   R   R   R"   R   R   R
   (   R   R   RB   R/   Ro   R&   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_binary_op_custom_class  s    c         C   s|   d } t  |  } t | j    } |  j t |  d |  | j t j  |  j | d t	 j
  |  j | d j  d  S(   Ns<   
        def f(g = lambda: None):
                __(g()).x
i   i    (   R   R   R)   R"   R   R   R   Rz   R*   R   R7   t   assertIsNoneR&   (   R   R   t   callfuncnodeR/   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_nonregr_lambda_arg9  s    c         C   s_   d } t  | t  } t | d j d   } |  j t |  d  |  j | d t j  d  S(   Ns9   
            def f(x):
                a = ()[x]
        RZ   RO   i   i    (   R   R$   R   R}   R"   R   R   Rz   (   R   R   RB   R/   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt    test_nonregr_getitem_empty_tupleE  s
    c         C   s  d } t  | t  } | d } | d } | d d d } | j d d } |  j t | j d  d  |  j t | j d  d  |  j | j i | g d 6 | j   d } | j d  |  j t | j d  d  |  j t | j d  d  |  j | j i | g d 6 d	 S(
   s=   non regression for instance_attrs infinite loop : pylint / #4s   
            class Foo(object):

                def set_42(self):
                    self.attr = 42

            class Bar(Foo):

                def __init__(self):
                    self.attr = 41
        t   Foot   BarR   R   t   attri    i   N(   R   R$   t   instance_attrsR"   R   R/   t   getattr(   R   R   RB   t	   foo_classt	   bar_classt   bar_selft   assattrt   instance(    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_nonregr_instance_attrsO  s    

c         C   sZ   t  j d  } |  j | j   t  t t j | d  j    } |  j	 | t
 j  d  S(   Ns   data/package/absimport.pyt    import_package_subpackage_module(   R   t
   build_fileR   t   absolute_import_activatedR   R   R   Rx   R)   Ry   R   Rz   (   R   RB   R/   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt    test_python25_no_relative_importl  s    c         C   s   t  j d d  } |  j | j   t  t t j | d  j    } |  j	 | t
 j  |  j | j d  |  j d | j  d  S(   Ns   data/absimp/string.pys   data.absimp.stringt   stringt   ascii_letters(   R   R9  R   R:  R   R   R   Rx   R)   R*   R   R  R"   RC   R   Rd   (   R   RB   R/   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_nonregr_absolute_imports  s    c         C   se  y d d  l  } Wn t k
 r0 |  j d  n Xd } t | t  } t t j | d  j    } |  j	 | t
 j  t | j d   } |  j d  |  j t |  d  |  j	 | d t
 j  |  j | d j    t t j | d	  j    } |  j	 | t  t | j d   } |  j t |  d  |  j	 | d t  |  j | d j    d  S(
   Nis   require mechanize installedsh   
            from mechanize import Browser
            print(Browser)
            b = Browser()
        t   BrowserR   s'   the commit said: "huum, see that later"i   i    RQ   (   t	   mechanizet   ImportErrort   skipTestR   R$   R   R   Rx   R)   R*   R   R   R   R   R"   R   R   R   R   R   R   (   R   R@  t   dataRB   t   browsert   bopenRQ   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_mechanize_open{  s&    c         C   sX  d } t  d t g  } t | t  } |  j | d d j   |  t | j d j j	    } |  j t
 |  d  | d } |  j | t  |  j | j d  |  j | j   j d	  |  j | d d
 j   |  t | j d j j	    } |  j t
 |  d  | d } |  j | t  |  j | j d  |  j | j   j t  d  S(   Ns  
            from smtplib import SMTP
            class SendMailController(object):

                @property
                def smtp(self):
                    return SMTP(mailhost, port)

                @property
                def me(self):
                    return self

            my_smtp = SendMailController().smtp
            my_me = SendMailController().me
            s   %s.propertyt   SendMailControllert   smtpi   i   i    t   SMTPt   smtplibt   mei   (   R;   R
   R   R$   R"   t   decoratornamesR   t   bodyR&   R)   R   R*   R   RC   RD   (   R   R   R   RB   t   propinferred(    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_property  s&    

c         C   s   d } t  | t  } t j | d  } t | j    } |  j t |  d  |  j | d t	 j
  t j | d d  } t | j    } |  j t |  d  |  j | d t	 j
  d  S(   Ns0  
            class EnvBasedTC:
                def pactions(self):
                    pass
            pactions = EnvBasedTC.pactions.im_func
            print (pactions)

            class EnvBasedTC2:
                pactions = EnvBasedTC.pactions.im_func
                print (pactions)
            t   pactionsi   i    t   EnvBasedTC2(   R   R$   R   Rx   R   R)   R"   R   R*   R   R   (   R   R   RB   RP  R/   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_im_func_unwrap  s    c         C   s{   d } t  | t  } t t j | d  j    } |  j t |  d  |  j | d t	 j
  |  j | d j d  d  S(   NsD   
            a = 1
            a += 2
            print (a)
        RO   i   i    i   (   R   R$   R   R   Rx   R)   R"   R   R*   R   R7   R&   (   R   R   RB   R/   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_augassign  s    c         C   sh   d } t  | t  } t t j | d d  j    } |  j t |  d  |  j | d t	 j
  d  S(   Ns   
            def foo(self, bar):
                def baz():
                    pass
                def qux():
                    return baz
                spam = bar(None, qux)
                print (spam)
            t   foot   spami   i    (   R   R$   R   R   Rx   R)   R"   R   Ry   R   Rz   (   R   R   RB   R/   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_nonregr_func_arg  s
    	"c         C   s   d } t  | t  } t t | d  j d   } |  j t |  d |  t t j | d d d  j	    } |  j t |  d |  xA | D]( } t
 | t  r | j d k r Pq q W|  j d |  d  S(	   Ns*  
            active_application = None

            def get_active_application():
              global active_application
              return active_application

            class Application(object):
              def __init__(self):
                 global active_application
                 active_application = self

            class DataManager(object):
              def __init__(self, app=None):
                 self.app = get_active_application()
              def test(self):
                 p = self.app
                 print (p)
        t   DataManagert   appi   t   testt   pt   Applications1   expected to find an instance of Application in %s(   R   R$   R   R   R   R"   R   R   Rx   R)   t
   isinstanceRC   t   fail(   R   R   RB   R/   R.   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_nonregr_func_global  s    &c         C   su   d } t  | t  } t | d j    } |  j | t j  |  j t | j	  d  |  j | j	 d t j
  d S(   s   #20464s   
            from unknown import Unknown
            A = []
            B = []

            def test():
              xyz = [
                Unknown
              ] + A + B
              return xyz

            Z = test()
        t   Zi   i    N(   R   R$   R   R)   R*   R   R   R"   R   R,   t   Unknown(   R   R   RB   R/   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_list_inference  s    c         C   s}   d } t  | t  } |  j t t | d j d   t | d j    } t | j d   } |  j t	 |  d |  d  S(   Ns   
            class NewTest(object):
                "doc"
                def __new__(cls, arg):
                    self = object.__new__(cls)
                    self.arg = arg
                    return self

            n = NewTest()
        t   NewTestR2   R   i   (
   R   R$   R!   R   R   R   R   R)   R"   R   (   R   R   RB   R   R/   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test__new__  s    
 c         C   sO   t  d  } t | j    } |  j | t  |  j | j | j   d  d  S(   NsG   
        class cls(object): pass
        cls().__new__(cls) #@
        t   cls(   R   R   R)   R*   R   R"   R   RD   (   R   R.   R/   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test__new__bound_methods.  s
    	c         C   sH   d } t  | t  } t | d j    } |  j t |  d |  d  S(   Nsu   
            from data import nonregr
            class Xxx(nonregr.Aaa, nonregr.Ccc):
                "doc"
        t   Xxxi   (   R   R$   R   R   R"   R   (   R   R   RB   t   parents(    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt!   test_two_parents_from_same_module7  s    c         C   s   d } t  | t  } | d j   d } |  j | t j  |  j d | j  |  j d | j  | d j   d } |  j | t j  |  j d | j  |  j d | j  d  S(   Ns   
            from collections import namedtuple
            A = namedtuple('A', ['a', 'b'])
            B = namedtuple('B', 'a b')
        R   i    RO   RQ   t   B(   R   R$   R/   R*   R   R   R   R0  (   R   R   RB   t   aclasst   bclass(    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_pluggable_inferenceA  s    c         C   s  d } t  | t  } | d j   d } |  j | t j  |  j | j d  | d j   d } |  j | t j  | d j   d } |  j | t j  |  j | j d  | d j   d } |  j | t j  |  j | j d  | d	 j   d } |  j | t j  d  S(
   Ns  
            class A(object):
                def first(self, arg1, arg2):
                    return arg1
                @classmethod
                def method(cls, arg1, arg2):
                    return arg2
                @classmethod
                def empty(cls):
                    return 2
                @staticmethod
                def static(arg1, arg2):
                    return arg1
                def empty_method(self):
                    return []
            x = A().first(1, [])
            y = A.method(1, [])
            z = A.static(1, [])
            empty = A.empty()
            empty_list = A().empty_method()
        R?   i    i   t   yt   zt   emptyi   t
   empty_list(	   R   R$   R/   R*   R   R7   R"   R&   R   (   R   R   RB   t   int_nodet	   list_nodeRo  Rp  (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_infer_argumentsQ  s    c         C   s   d } t  | t  } | d } | j d j } | j d j } | j   d } |  j | t j  |  j | j	 | j
  | j   d } |  j | t j  |  j | j	 | j
  d  S(   Nsm   
            def test(*args, **kwargs):
                vararg = args
                kwarg = kwargs
        RY  i    i   (   R   R$   RM  R&   R/   R*   R   R:   Ry   Rr   R   R[   (   R   R   RB   R3   t   varargt   kwargt   kwarg_inferredt   vararg_inferred(    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_infer_variable_argumentsv  s    
c         C   sZ   d } t  | t  } t | j t j   } | j } | j   d } |  j | t	  d  S(   Ns   
            def nested():
                from threading import Thread

                class NestedThread(Thread):
                    def __init__(self):
                        Thread.__init__(self)
        i    (
   R   R$   R   R   R   t   CallR3   R/   R*   R	   (   R   R   RB   t   callfuncR3   R/   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_infer_nested  s    	c         C   sz   d } t  | t  } | d j   d } | d j   d } |  j | t j  |  j | t j  |  j	 | j
 d  d  S(   Ns   
            class A(object):
                def __mul__(self, other):
                    return 42
            a = A()
            b = A()
            sub = a - b
            mul = a * b
        R   i    t   muli*   (   R   R$   R/   Ry   R   Rz   R*   R   R7   R"   R&   (   R   R   RB   R   R|  (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_instance_binary_operations  s    	c         C   sz   d } t  | t  } | d j   d } | d j   d } |  j | t j  |  j | t j  |  j	 | j
 d  d  S(   Ns   
            class A(object):
                def __mul__(self, other):
                    return 42
            class B(A):
                pass
            a = B()
            b = B()
            sub = a - b
            mul = a * b
        R   i    R|  i*   (   R   R$   R/   Ry   R   Rz   R*   R   R7   R"   R&   (   R   R   RB   R   R|  (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt&   test_instance_binary_operations_parent  s    c         C   s   d } t  | t  } | d j   d } | d j   d } |  j | t j  |  j | t j  |  j | j	 d t j
  |  j | j	 d j d  d  S(   Ns(  
            class A(object):
                def __mul__(self, other):
                    return 42
            class B(A):
                def __mul__(self, other):
                    return [42]
            a = B()
            b = B()
            sub = a - b
            mul = a * b
        R   i    R|  i*   (   R   R$   R/   Ry   R   Rz   R*   R   R   R,   R7   R"   R&   (   R   R   RB   R   R|  (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt0   test_instance_binary_operations_multiple_methods  s    c         C   s?   d } t  | t  } | d } |  j | j   t j g  d  S(   Ns   
            class A(object):
                def __mul__(self, other):
                    return type.__new__()

            a = A()
            b = A()
            c = a * b
        RR   (   R   R$   R"   R/   R   Rz   (   R   R   RB   R.   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_infer_call_result_crash  s    	
c         C   s,   t  j   } |  j | j   t j g  d  S(   N(   R   t	   EmptyNodeR"   R/   R   Rz   (   R   R.   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_infer_empty_nodes  s    c         C   s6   d } t  | t  } | d } |  j | j d  d  S(   Ns   
            def decorator():
                def wrapper():
                    return decorator()
                return wrapper

            @decorator()
            def do_a_thing():
                pass
        t
   do_a_thingt   function(   R   R$   R"   t   type(   R   R   RB   R.   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt!   test_infinite_loop_for_decorators  s    
c         C   s<   t  d  } |  j d g  | j   D] } | j ^ q"  d  S(   Ns   
            import datetime

            def method(self):
                datetime.datetime = something()

            class something(datetime.datetime):  #@
                pass
        RM   (   R   R   R   RC   (   R   R   t   base(    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_no_infinite_ancestor_loop  s
    	c         C   s>   d } t  | t  } | j j } |  j t t | j    d  S(   Ns   
            class Test:
                def __init__(self):
                    self.config = {0: self.config[0]}
                    self.config[0].test() #@
        (   R   R$   R3   t   exprR!   R   R   R)   (   R   R   RB   R  (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_stop_iteration_leak  s    c         C   s0  d } t  | t  } |  j | d g   |  j | d d g  |  j | d d g  |  j | d d d d g  |  j | d	 d g  |  j | d
 d d g  |  j | d d g  |  j | d d d g  xS | d D]G } t | j    } |  j | t  |  j | j   d j	 t
   q Wd  S(   Ns(  
        var = (1, 2)
        tuple() #@
        tuple([1]) #@
        tuple({2}) #@
        tuple("abc") #@
        tuple({1: 2}) #@
        tuple(var) #@
        tuple(tuple([1])) #@
        tuple(frozenset((1, 2))) #@

        tuple(None) #@
        tuple(1) #@
        tuple(1, 2) #@
        i    i   i   i   RO   RQ   RR   i   i   i   i   i   s   {}.tuple(   R   R$   t   assertInferTupleR   R)   R*   R   R"   t   qnamet   formatR
   (   R   R   RB   R.   R/   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_tuple_builtin_inference  s    c         C   s   d } t  | t  } |  j | d d d d d g  |  j | d d d d d d g  |  j | d d d d d d d d d	 g  |  j | d d d d d d d d d	 d
 g	  |  j | d d d d d d d d d	 d d d g  d  S(   Ns   
        var = (1, 2, 3)
        bar = (5, 6, 7)
        foo = [999, 1000, 1001]
        (0, *var) #@
        (0, *var, 4) #@
        (0, *var, 4, *bar) #@
        (0, *var, 4, *(*bar, 8)) #@
        (0, *var, 4, *(*bar, *foo)) #@
        i    i   i   i   i   i   i   i   i   i  i  i  (   R   R$   R  (   R   R   RB   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_starred_in_tuple_literal0  s     #,/c         C   s   d } t  | t  } |  j | d d d d d g  |  j | d d d d d d g  |  j | d d d d d d d d d	 g  |  j | d d d d d d d d d	 d
 g	  |  j | d d d d d d d d d	 d d d g  d  S(   Ns   
        var = (1, 2, 3)
        bar = (5, 6, 7)
        foo = [999, 1000, 1001]
        [0, *var] #@
        [0, *var, 4] #@
        [0, *var, 4, *bar] #@
        [0, *var, 4, *[*bar, 8]] #@
        [0, *var, 4, *[*bar, *foo]] #@
        i    i   i   i   i   i   i   i   i   i  i  i  (   R   R$   t   assertInferList(   R   R   RB   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_starred_in_list_literalC  s     #,/c         C   s   d } t  | t  } |  j | d d d d d g  |  j | d d d d d d g  |  j | d d d d d d d d d	 g  |  j | d d d d d d d d d	 d
 g	  |  j | d d d d d d d d d	 d d d g  d  S(   Ns   
        var = (1, 2, 3)
        bar = (5, 6, 7)
        foo = [999, 1000, 1001]
        {0, *var} #@
        {0, *var, 4} #@
        {0, *var, 4, *bar} #@
        {0, *var, 4, *{*bar, 8}} #@
        {0, *var, 4, *{*bar, *foo}} #@
        i    i   i   i   i   i   i   i   i   i  i  i  (   R   R$   t   assertInferSet(   R   R   RB   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_starred_in_set_literalV  s     #,/c         C   sP   d } t  | t  } x4 | D], } |  j t   t | j    Wd  QXq Wd  S(   Ns   
        {0, *var} #@
        {0, *var, 4} #@
        {0, *var, 4, *bar} #@
        {0, *var, 4, *{*bar, 8}} #@
        {0, *var, 4, *{*bar, *foo}} #@
        (   R   R$   R!   R   R   R)   (   R   R   RB   R.   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt)   test_starred_in_literals_inference_issuesi  s
    c         C   s   d } t  | t  } |  j | d i d d 6d d 6d d 6 |  j | d i d d 6d d 6d d 6d d	 6 |  j | d i d d 6d d 6d d 6d d	 6d
 d 6d d 6d d 6 d  S(   Ns   
        var = {1: 'b', 2: 'c'}
        bar = {4: 'e', 5: 'f'}
        {0: 'a', **var} #@
        {0: 'a', **var, 3: 'd'} #@
        {0: 'a', **var, 3: 'd', **{**bar, 6: 'g'}} #@
        i    RO   RQ   i   RR   i   RX   i   RY   i   RZ   i   R]   i   (   R   R$   R>   (   R   R   RB   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_starred_in_mapping_literalw  s    )0,c         C   s/   t  d  } |  j t | j    t j  d  S(   Ns   
        from unknown import unknown

        def test(a):
           return a + 1

        def func():
            a = {unknown: 'a'}
            return {0: 1, **a}

        test(**func())
        (   R   R"   R   R)   R   Rz   (   R   R.   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt5   test_starred_in_mapping_literal_no_inference_possible  s    	c         C   sP   d } t  | t  } x4 | D], } |  j t   t | j    Wd  QXq Wd  S(   Ns}   
        {0: 'a', **var} #@
        {0: 'a', **var, 3: 'd'} #@
        {0: 'a', **var, 3: 'd', **{**bar, 6: 'g'}} #@
        (   R   R$   R!   R   R   R)   (   R   R   RB   R.   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt(   test_starred_in_mapping_inference_issues  s
    c         C   sy   d } t  | t  } |  j | d i d d 6d d 6d d 6 |  j | d	 i d d 6d d 6d d 6d
 d 6d d 6 d  S(   Ns   
        a, b, c, d, e, f, g, h, i, j = "ABCDEFGHIJ"
        var = {c: d, e: f}
        bar = {i: j}
        {a: b, **var} #@
        {a: b, **var, **{g: h, **bar}} #@
        i    Ri  R   t   DRH   t   Ft   Ei   t   Ht   Gt   Jt   I(   R   R$   R>   (   R   R   RB   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt5   test_starred_in_mapping_literal_non_const_keys_values  s    )c         C   s  d } t  | t  } |  j | d g   |  j | d d d g  |  j | d d d d g  |  j | d d d d g  |  j | d	 d g  |  j | d
 d d g  |  j | d d g  xS | d D]G } t | j    } |  j | t  |  j | j   d j	 t
   q Wd  S(   Nsm  
        var = (1, 2)
        frozenset() #@
        frozenset([1, 2, 1]) #@
        frozenset({2, 3, 1}) #@
        frozenset("abcab") #@
        frozenset({1: 2}) #@
        frozenset(var) #@
        frozenset(tuple([1])) #@

        frozenset(set(tuple([4, 5, set([2])]))) #@
        frozenset(None) #@
        frozenset(1) #@
        frozenset(1, 2) #@
        i    i   i   i   RO   RQ   RR   i   i   i   i   s   {}.frozenset(   R   R$   t   assertInferFrozenSetR   R)   R*   R   R"   R  R  R
   (   R   R   RB   R.   R/   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt    test_frozenset_builtin_inference  s    c         C   s  d } t  | t  } |  j | d g   |  j | d d d g  |  j | d d d d g  |  j | d d d d g  |  j | d	 d g  |  j | d
 d d g  |  j | d d g  xS | d D]G } t | j    } |  j | t  |  j | j   d j	 t
   q Wd  S(   Ns+  
        var = (1, 2)
        set() #@
        set([1, 2, 1]) #@
        set({2, 3, 1}) #@
        set("abcab") #@
        set({1: 2}) #@
        set(var) #@
        set(tuple([1])) #@

        set(set(tuple([4, 5, set([2])]))) #@
        set(None) #@
        set(1) #@
        set(1, 2) #@
        i    i   i   i   RO   RQ   RR   i   i   i   i   s   {}.set(   R   R$   R  R   R)   R*   R   R"   R  R  R
   (   R   R   RB   R.   R/   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_set_builtin_inference  s    c         C   s(  d } t  | t  } |  j | d g   |  j | d d d d g  |  j | d d d d g  |  j | d d d d d d g  |  j | d	 d g  |  j | d
 d d g  |  j | d d g  xS | d D]G } t | j    } |  j | t  |  j | j   d j	 t
   q Wd  S(   Ns8  
        var = (1, 2)
        list() #@
        list([1, 2, 1]) #@
        list({2, 3, 1}) #@
        list("abcab") #@
        list({1: 2}) #@
        list(var) #@
        list(tuple([1])) #@

        list(list(tuple([4, 5, list([2])]))) #@
        list(None) #@
        list(1) #@
        list(1, 2) #@
        i    i   i   i   RO   RQ   RR   i   i   i   i   s   {}.list(   R   R$   R  R   R)   R*   R   R"   R  R  R
   (   R   R   RB   R.   R/   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_list_builtin_inference  s    #c         C   s   t  d  } |  j | d d d g  |  j | d d d g  |  j | d d d g  |  j | d d d g  |  j | d d d g  d  S(   Ns   
        list({1:2, 2:3}.values()) #@
        list({1:2, 2:3}.keys()) #@
        tuple({1:2, 2:3}.values()) #@
        tuple({1:2, 3:4}.keys()) #@
        set({1:2, 2:4}.keys()) #@
        i    i   i   i   i   (   R   R  R  R  (   R   R   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_conversion_of_dict_methods  s    	c         C   sp   d } t  | t  } |  j | d d d d g  |  j | d d d d g  |  j | d d d d g  d  S(   NsQ   
        list(b"abc") #@
        tuple(b"abc") #@
        set(b"abc") #@
        i    ia   ib   ic   i   i   (   R   R$   R  R  R  (   R   R   RB   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_builtin_inference_py3k  s
    c         C   s  d } t  | t  } |  j | d i   |  j | d i d d 6d d 6d d 6 x9 t d d	  D]( } |  j | | i d d 6d d 6 qb W|  j | d	 i d d 6d d 6d d 6 |  j | d
 i d d 6 |  j | d i d d 6d d 6d	 d 6 |  j | d i d d 6d d 6 |  j | d i d d 6d d 6d d 6d d 6 xS | d D]G } t | j    } |  j | t  |  j | j	   d j
 t   qXWd  S(   Ns  
        dict() #@
        dict(a=1, b=2, c=3) #@
        dict([(1, 2), (2, 3)]) #@
        dict([[1, 2], [2, 3]]) #@
        dict([(1, 2), [2, 3]]) #@
        dict([('a', 2)], b=2, c=3) #@
        dict({1: 2}) #@
        dict({'c': 2}, a=4, b=5) #@
        def func():
            return dict(a=1, b=2)
        func() #@
        var = {'x': 2, 'y': 3}
        dict(var, a=1, b=2) #@

        dict([1, 2, 3]) #@
        dict([(1, 2), (1, 2, 3)]) #@
        dict({1: 2}, {1: 2}) #@
        dict({1: 2}, (1, 2)) #@
        dict({1: 2}, (1, 2), a=4) #@
        dict([(1, 2), ([4, 5], 2)]) #@
        dict([None,  None]) #@

        def using_unknown_kwargs(**kwargs):
            return dict(**kwargs)
        using_unknown_kwargs(a=1, b=2) #@
        i    i   RO   i   RQ   i   RR   i   i   i   i   i   i	   R?   Rm  i
   s   {}.dict(   R   R$   R>   t   rangeR   R)   R*   R   R"   R  R  R
   (   R   R   RB   R`   R.   R/   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_dict_inference%  s    )&))"0c         C   s5   t  d  } |  j | i d d 6d d 6d d 6 d  S(   Ns   dict(a=1, b=2, **{'c': 3})i   RO   i   RQ   i   RR   (   R   R>   (   R   R  (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_dict_inference_kwargsQ  s    c         C   s   d i d d 6d d 6d d 6f d i d d 6d d 6d d 6d	 d
 6f d i d d 6d d 6d d 6f g } x0 | D]( \ } } t  |  } |  j | |  qn Wd  S(   Ns    dict(a=1, **{"b": 2}, **{"c":3})i   RO   i   RQ   i   RR   s%   dict(a=1, **{"b": 2}, d=4, **{"c":3})i   RX   s   dict({"a":1}, b=2, **{"c":3})(   R   R>   (   R   t   pairsR   R   R.   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt(   test_dict_inference_for_multiple_starredU  s    %$c         C   sq   d d d g } x[ | D]S } t  |  } t | j    } |  j | t  |  j | j   d j t   q Wd  S(   Ns   dict(*1)s   dict(**lala)s
   dict(**[])s   {}.dict(	   R   R   R)   R*   R   R"   R  R  R
   (   R   t   invalid_valuest   invalidR  R/   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_dict_invalid_args`  s    	c         C   s   d } t  | t  } |  j | d d  x+ t d d  D] } |  j | | d  q9 Wx+ t d d  D] } |  j | | d  qg Wd  S(   Ns  
        ' '.decode() #@

        ' '.encode() #@
        ' '.join('abcd') #@
        ' '.replace('a', 'b') #@
        ' '.format('a') #@
        ' '.capitalize() #@
        ' '.title() #@
        ' '.lower() #@
        ' '.upper() #@
        ' '.swapcase() #@
        ' '.strip() #@
        ' '.rstrip() #@
        ' '.lstrip() #@
        ' '.rjust() #@
        ' '.ljust() #@
        ' '.center() #@

        ' '.index() #@
        ' '.find() #@
        ' '.count() #@
        i    u    i   i   t    i   (   R   R$   R9   R  (   R   R   RB   R`   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_str_methodsl  s    c         C   s   d } t  | t  } |  j | d d  x+ t d d  D] } |  j | | d  q9 Wx+ t d d  D] } |  j | | d  qg Wd  S(   Ns  
        u' '.encode() #@

        u' '.decode() #@
        u' '.join('abcd') #@
        u' '.replace('a', 'b') #@
        u' '.format('a') #@
        u' '.capitalize() #@
        u' '.title() #@
        u' '.lower() #@
        u' '.upper() #@
        u' '.swapcase() #@
        u' '.strip() #@
        u' '.rstrip() #@
        u' '.lstrip() #@
        u' '.rjust() #@
        u' '.ljust() #@
        u' '.center() #@

        u' '.index() #@
        u' '.find() #@
        u' '.count() #@
        i    R  i   i   u    i   (   R   R$   R9   R  (   R   R   RB   R`   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_unicode_methods  s    c         C   sr   d } t  | t  } | d j d } t | j    } |  j |  |  j | t j  |  j	 | j
   d  d  S(   Ns   
        import collections
        class Second(collections.Counter):
            def collections(self):
                return "second"

        t   Secondi    s   collections.Counter(   R   R$   t   basesR   R)   R   R*   R   R   R"   R  (   R   R   RB   R  R/   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt!   test_scope_lookup_same_attributes  s    c         C   sg   t  d  } |  j t t | d j    |  j t t | d j    |  j t t | d j    d  S(   Ns{  
        class NoEnter(object):
            pass
        class NoMethod(object):
            __enter__ = None
        class NoElts(object):
            def __enter__(self):
                return 42

        with NoEnter() as no_enter:
            pass
        with NoMethod() as no_method:
            pass
        with NoElts() as (no_elts, no_elts1):
            pass
        t   no_entert	   no_methodt   no_elts(   R   R!   R   R   R)   (   R   R@   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt&   test_inferring_with_statement_failures  s
    	c         C   sQ  t  d  } | d } t | j    } |  j | t  |  j | j d  | d } t | j    } |  j | t  |  j | j d  | d } t | j    } |  j | t  |  j | j d  | d } t | j    } |  j | t j  |  j | j	 d  | d } t | j    } |  j | t j  |  j | j	 d	  d  S(
   Ns  
        class SelfContext(object):
            def __enter__(self):
                return self

        class OtherContext(object):
            def __enter__(self):
                return SelfContext()

        class MultipleReturns(object):
            def __enter__(self):
                return SelfContext(), OtherContext()

        class MultipleReturns2(object):
            def __enter__(self):
                return [1, [2, 3]]

        with SelfContext() as self_context:
            pass
        with OtherContext() as other_context:
            pass
        with MultipleReturns(), OtherContext() as multiple_with:
            pass
        with MultipleReturns2() as (stdout, (stderr, stdin)):
            pass
        t   self_contextt   SelfContextt   other_contextt   multiple_witht   stdouti   t   stderri   (
   R   R   R)   R*   R   R"   RC   R   R7   R&   (   R   R@   R  R/   R  R  R  R  (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_inferring_with_statement  s,    	




c         C   s-  t  d  } | d } t | j    } |  j | t j  |  j | j  | d } | j   } |  j	 t
 |  d  | d } |  j | t j  |  j	 | j d  | d | d } } t | j    } t | j    } |  j | t j  |  j | j  |  j | t j  |  j	 | j d  d  S(	   Ns  
        import contextlib
        from contextlib import contextmanager

        @contextlib.contextmanager
        def manager_none():
            try:
                yield
            finally:
                pass

        @contextlib.contextmanager
        def manager_something():
            try:
                yield 42
                yield 24 # This should be ignored.
            finally:
                pass

        @contextmanager
        def manager_multiple():
            with manager_none() as foo:
                with manager_something() as bar:
                    yield foo, bar

        with manager_none() as none:
            pass
        with manager_something() as something:
            pass
        with manager_multiple() as (first, second):
            pass
        t   noneR   i   i    i*   R  R  (   R   R   R)   R*   R   R7   R)  R&   R/   R"   R   (   R   R@   R  R/   R   R  R  (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt-   test_inferring_with_contextlib_contextmanager  s&    	


c         C   s-   t  d  } |  j t t | d j    d  S(   Ns   
        class Manager(object):
            def __enter__(self):
                return []
        with Manager() as (a, b, c):
            pass
        RO   (   R   R!   R   R   R)   (   R   R@   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt/   test_inferring_context_manager_skip_index_error6  s    	c         C   s-   t  d  } |  j t t | d j    d  S(   Ns  
        import contextlib

        @contextlib.contextmanager
        def _select_source(a=None):
            with _select_source() as result:
                yield result

        result = _select_source()
        with result as (a, b, c):
            pass
        RO   (   R   R!   R   R   R)   (   R   R@   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt8   test_inferring_context_manager_unpacking_inference_errorE  s    	c         C   sg   t  d  } |  j t t | d j    |  j t t | d j    |  j t t | d j    d  S(   Ns  
        from contextlib import contextmanager

        def no_decorators_mgr():
            yield
        @no_decorators_mgr
        def other_decorators_mgr():
            yield
        @contextmanager
        def no_yield_mgr():
            pass

        with no_decorators_mgr() as no_decorators:
            pass
        with other_decorators_mgr() as other_decorators:
            pass
        with no_yield_mgr() as no_yield:
            pass
        t   no_decoratorst   other_decoratorst   no_yield(   R   R!   R   R   R)   (   R   R@   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt6   test_inferring_with_contextlib_contextmanager_failuresU  s
    	c         C   sp   d } t  |  \ } } t | j    } t | j    } t | t j  sT t  t | t j  sl t  d S(   s   Make sure contextmanager works with nested functions

        Previously contextmanager would retrieve
        the first yield instead of the yield in the
        proper scope

        Fixes https://github.com/PyCQA/pylint/issues/1746
        s1  
        from contextlib import contextmanager

        @contextmanager
        def outer():
            @contextmanager
            def inner():
                yield 2
            yield inner

        with outer() as ctx:
            ctx #@
            with ctx() as val:
                val #@
        N(   R   R   R)   R\  R   R   t   AssertionErrorR7   (   R   R   t   context_nodet
   value_nodeR&   t   context(    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_nested_contextmanagerm  s    c         C   s/   t  d  } |  j t j t | j     d  S(   Ns   +[] #@(   R   R"   R   Rz   R   R)   (   R   R.   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt"   test_unary_op_leaks_stop_iteration  s    c         C   s   t  d  } d d d d d d g } xY t | d  |  D]D \ } } t | j    } |  j | t j  |  j | j |  q8 Wx7 | d D]+ } t | j    } |  j | t	 j
  q Wd  S(   NsP  
        import os
        def func(): pass
        from missing import missing
        class GoodInstance(object):
            def __pos__(self):
                return 42
            def __neg__(self):
                return +self - 41
            def __invert__(self):
                return 42
        class BadInstance(object):
            def __pos__(self):
                return lala
            def __neg__(self):
                return missing
        class LambdaInstance(object):
            __pos__ = lambda self: self.lala
            __neg__ = lambda self: self.lala + 1
            @property
            def lala(self): return 24
        instance = GoodInstance()
        lambda_instance = LambdaInstance()
        +instance #@
        -instance #@
        ~instance #@
        --instance #@
        +lambda_instance #@
        -lambda_instance #@

        bad_instance = BadInstance()
        +bad_instance #@
        -bad_instance #@
        ~bad_instance #@

        # These should be TypeErrors.
        ~BadInstance #@
        ~os #@
        -func #@
        +BadInstance #@
        i*   i   ii   i   i   (   R   R   R   R)   R*   R   R7   R"   R&   R   Rz   (   R   R   R8   R.   R&   R/   t   bad_node(    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_unary_operands  s    (	 c         C   s)   t  d  } |  j t t | j    d  S(   NsW   
        class A:
            __pos__ = (i for i in range(10))
        +A() #@
        (   R   R!   R   R   R)   (   R   R  (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt*   test_unary_op_instance_method_not_callable  s    	c         C   s  t  d  } d } | j d d d d d d  | j d d	 d d d d
  | j d d d d d d  | j d d d d d d  | j d d d d d d  | j d d d d d d  | j d d	 d d d d  | j d d d d d d  | j d d d d d d  | j d d d d
 d d  | j d d d d d d
  | j d d d d
 d d  | j d d d d d d  | j d d d d d d  | j d d d d d d  | j d d d d d d  | j d d d d d d  | j d d d d d d  | j d d d d d d  | j d d d d d d  | j d d d d d d
  g } x_ t | |  D]N \ } } | j   } |  j t |  d  | d } |  j t |  |  q_Wd  S(   Ns  
        import collections
        1 + "a" #@
        1 - [] #@
        1 * {} #@
        1 / collections #@
        1 ** (lambda x: x) #@
        {} * {} #@
        {} - {} #@
        {} | {} #@
        {} >> {} #@
        [] + () #@
        () + [] #@
        [] * 2.0 #@
        () * 2.0 #@
        2.0 >> 2.0 #@
        class A(object): pass
        class B(object): pass
        A() + B() #@
        class A1(object):
            def __add__(self, other): return NotImplemented
        A1() + A1() #@
        class A(object):
            def __add__(self, other): return NotImplemented
        class B(object):
            def __radd__(self, other): return NotImplemented
        A() + B() #@
        class Parent(object):
            pass
        class Child(Parent):
            def __add__(self, other): return NotImplemented
        Child() + Parent() #@
        class A(object):
            def __add__(self, other): return NotImplemented
        class B(A):
            def __radd__(self, other):
                 return NotImplemented
        A() + B() #@
        # Augmented
        f = 1
        f+=A() #@
        x = 1
        x+=[] #@
        s9   unsupported operand type(s) for {op}: {lhs!r} and {rhs!r}t   opt   +t   lhst   intt   rhsR   t   -R   R  R   t   /R@   s   **R  t   |s   >>R   t   floatR   Ri  t   A1t   Childt   Parents   +=i   i    (   R   R  R   t   type_errorsR"   R   R   (   R   R   t   msgR8   R.   R   t   errorsR   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_binary_op_type_errors  s:    +	!
c         C   s  t  d  } d } | j d d d d  | j d d d d  | j d d d d  | j d d d d  | j d d d d	  | j d d
 d d	  | j d d
 d d  | j d d d d  | j d d d d  | j d d d d  | j d d d d  | j d d d d  | j d d d d  | j d d d d  g } x_ t | |  D]N \ } } | j   } |  j t |  d  | d } |  j t |  |  qNWd  S(   Ns4  
        import collections
        ~[] #@
        ~() #@
        ~dict() #@
        ~{} #@
        ~set() #@
        -set() #@
        -"" #@
        ~"" #@
        +"" #@
        class A(object): pass
        ~(lambda: None) #@
        ~A #@
        ~A() #@
        ~collections #@
        ~2.0 #@
        s'   bad operand type for unary {op}: {type}R  t   ~R  R   R   R   R;   R  R   R  s   <lambda>R   t   collectionsR  i   i    (   R   R  R   R  R"   R   R   (   R   R   R  R8   R.   R   R  R   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_unary_type_errors	  s,    	
c         C   s   t  d  } d d g } xb t | |  D]Q \ } } | j   } |  j t |  d | | f  |  j t | d  |  q( Wd  S(   Ns6   
        ~(2 and []) #@
        -(0 or {}) #@
        s"   bad operand type for unary ~: lists"   bad operand type for unary -: dicti   i    (   R   R   R  R"   R   R   (   R   R   R8   R.   R   R  (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_unary_empty_type_errors@	  s    		c         C   sL   t  d  } | j   } |  j t |  d  |  j t | d  d  d  S(   Ns   ~slice(1, 2, 3)i   i    s#   bad operand type for unary ~: slice(   R   R  R"   R   R   (   R   R.   R  (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt/   test_unary_type_errors_for_non_instance_objectsO	  s    c      	   C   s   d t  f d t f d t  f d t f d t  f d t f d t  f d t f g } xH | D]@ \ } } t |  } t | j    } |  j | j   |  qU Wd  S(	   Ns   {}s   {1:2}s   ()s   (1, 2)s   []s   [1,2]s   frozenset()s   frozenset((1, 2))(   R
  R   R   R   R)   R"   t
   bool_value(   R   R  R   R8   R.   R/   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_bool_value_recursiveX	  s    							c         C   s#   t  d  } |  j | j    d  S(   Ns   (x for x in range(10))(   R   R   R  (   R   R.   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_genexpr_bool_valueh	  s    c         C   s)   t  d  } |  j | j   t j  d  S(   Ns0   
        x = 42
        y = x
        y
        (   R   Ry   R  R   Rz   (   R   R.   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_name_bool_valuel	  s    	c         C   sG  t  d  } t | d j    } |  j | j    | d } |  j | j    | d } |  j | j    t | d j    } |  j | t j  t | d j    } |  j | t j  t | d j    } |  j | t j  t | d j    } |  j |  t | d	 j    }	 |  j |	  t | d
 j    }
 |  j |
  t | d j    } |  j |  | d j j	 } |  j
 | j   t j  | d j j	 } |  j | j   t j  | d j j	 } |  j | j   t j  t | d j    } |  j | j    | d j j	 } |  j | j   t j  d  S(   Ns  
        import collections
        collections_module = collections
        def function(): pass
        class Class(object):
            def method(self): pass
        dict_comp = {x:y for (x, y) in ((1, 2), (2, 3))}
        set_comp = {x for x in range(10)}
        list_comp = [x for x in range(10)]
        lambda_func = lambda: None
        unbound_method = Class.method
        instance = Class()
        bound_method = instance.method
        def generator_func():
             yield
        def true_value():
             return True
        generator = generator_func()
        bin_op = 1 + 2
        bool_op = x and y
        callfunc = test()
        good_callfunc = true_value()
        compare = 2 < 3
        const_str_true = 'testconst'
        const_str_false = ''
        t   collections_moduleR  t   Classt	   dict_compt   set_compt	   list_compt   lambda_funct   unbound_methodt   bound_methodt	   generatort   bin_opt   bool_opRz  t   good_callfunct   compare(   R   R   R)   R   R  R"   R   Rz   Rr   R&   Ry   (   R   R@   R  R  R   R  R  R  R  R  R  R  R  R  Rz  R  R  (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_bool_valuet	  s@    	

c         C   s   t  d j d t   } t t t t t t j t j f } xE t | |  D]4 \ } } t | j	    } |  j
 | j   |  qI Wd  S(   Nsl  
        class FalseBoolInstance(object):
            def {bool}(self):
                return False
        class TrueBoolInstance(object):
            def {bool}(self):
                return True
        class FalseLenInstance(object):
            def __len__(self):
                return 0
        class TrueLenInstance(object):
            def __len__(self):
                return 14
        class AlwaysTrueInstance(object):
            pass
        class ErrorInstance(object):
            def __bool__(self):
                return lala
            def __len__(self):
                return lala
        class NonMethods(object):
            __bool__ = 1
            __len__ = 2
        FalseBoolInstance() #@
        TrueBoolInstance() #@
        FalseLenInstance() #@
        TrueLenInstance() #@
        AlwaysTrueInstance() #@
        ErrorInstance() #@
        t   bool(   R   R  t   BOOL_SPECIAL_METHODR
  R   R   Rz   R   R   R)   R"   R  (   R   t	   instancesR8   R.   R   R/   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_bool_value_instances	  s    !c         C   sG   t  d j d t   } t | j    } |  j | j   t j  d  S(   Ns   
        class VariableBoolInstance(object):
            def __init__(self, value):
                self.value = value
            def {bool}(self):
                return self.value

        not VariableBoolInstance(True)
        R  (	   R   R  R  R   R)   Ry   R  R   Rz   (   R   R6  R/   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_bool_value_variable	  s    c         C   ss   t  d  } d d d d d	 d d
 d g } xB t | |  D]1 \ } } t | j    } |  j | j |  q: Wd  S(   Ns   
        1 + 1.0 #@
        1 * 1.0 #@
        2 - 1.0 #@
        2 / 2.0 #@
        1 + 1j #@
        2 * 1j #@
        2 - 1j #@
        3 / 1j #@
        g       @g      ?i   y              ?y               @i   y              y      ?      ?y       @      (   R   R   R   R)   R"   R&   (   R   R   t   expected_valuesR.   R8   R/   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt,   test_infer_coercion_rules_for_floats_complex	  s    		c         C   s   t  d  } t | j    } |  j | t j  |  j t | j  d  |  j | j d t j	  |  j | j d t j
  d  S(   Ns-   
        x = [A] * 1
        [1] + x
        i   i    i   (   R   R   R)   R*   R   R   R"   R   R,   R7   R`  (   R   R  R/   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_binop_list_with_elts	  s    	c         C   sz   t  d  } d d d d g } xU t | |  D]D \ } } t | j    } |  j | t j  |  j | j |  q. Wd  S(   Ns   
        class A(object):
            def __add__(self, other):
                return 42
        1 + 1 #@
        1 - 1 #@
        "a" + "b" #@
        A() + A() #@
        i   i    t   abi*   (	   R   R   R   R)   R*   R   R7   R"   R&   (   R   R   R  R.   R8   R/   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_binop_same_types	  s    	c         C   sE   t  d  } t | j    } |  j | t  |  j | j d  d  S(   Ns   
        class A(object):
            pass
        class B(object):
            def __radd__(self, other):
                return other
        A() + B() #@
        R   (   R   R   R)   R*   R   R"   RC   (   R   R.   R/   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt)   test_binop_different_types_reflected_only
  s
    	c         C   s5   t  d  } t | j    } |  j | t j  d  S(   Ns   
        from foo import bar

        class A(bar):
            pass
        class B(object):
            def __radd__(self, other):
                return other
        A() + B() #@
        (   R   R   R)   Ry   R   Rz   (   R   R.   R/   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt(   test_binop_different_types_unknown_bases
  s    		c         C   sE   t  d  } t | j    } |  j | t  |  j | j d  d  S(   Ns   
        class A(object):
            def __add__(self, other):
                return NotImplemented
        class B(object):
            def __radd__(self, other):
                return other
        A() + B() #@
        R   (   R   R   R)   R*   R   R"   RC   (   R   R.   R/   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt?   test_binop_different_types_normal_not_implemented_and_reflected&
  s
    	c         C   s5   t  d  } t | j    } |  j | t j  d  S(   Nsf   
        class A(object):
            pass
        class B(object): pass
        A() + B() #@
        (   R   R   R)   R"   R   Rz   (   R   R.   R/   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt0   test_binop_different_types_no_method_implemented4
  s    	c         C   s5   t  d  } t | j    } |  j | t j  d  S(   Ns   
        class A(object):
            def __add__(self, other): return NotImplemented
        class B(object):
            def __radd__(self, other): return NotImplemented
        A() + B() #@
        (   R   R   R)   R"   R   Rz   (   R   R.   R/   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt?   test_binop_different_types_reflected_and_normal_not_implemented>
  s    	c         C   sE   t  d  } t | j    } |  j | t  |  j | j d  d  S(   Ns   
        class A(object): pass
        class B(A):
            def __add__(self, other): return other
        B() + A() #@
        R   (   R   R   R)   R*   R   R"   RC   (   R   R.   R/   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_binop_subtypeI
  s
    	c         C   sE   t  d  } t | j    } |  j | t  |  j | j d  d  S(   Ns   
        class A(object):
            def __add__(self, other): return other
        class B(A): pass
        B() + A() #@
        R   (   R   R   R)   R*   R   R"   RC   (   R   R.   R/   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt(   test_binop_subtype_implemented_in_parentT
  s
    	c         C   s5   t  d  } t | j    } |  j | t j  d  S(   Ns   
        class A(object):
            pass
        class B(A):
            def __add__(self, other): return NotImplemented
        B() + A() #@
        (   R   R   R)   R"   R   Rz   (   R   R.   R/   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt"   test_binop_subtype_not_implemented_
  s    	c         C   sE   t  d  } t | j    } |  j | t  |  j | j d  d  S(   Ns   
        class A(object):
            pass
        class B(A):
            def __radd__(self, other):
                 return other
        A() + B() #@
        R   (   R   R   R)   R*   R   R"   RC   (   R   R.   R/   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_binop_supertypej
  s
    	c         C   sE   t  d  } t | j    } |  j | t  |  j | j d  d  S(   Ns   
        class A(object):
            def __add__(self, other):
                return other
        class B(A):
            def __radd__(self, other):
                 return NotImplemented
        A() + B() #@
        Ri  (   R   R   R)   R*   R   R"   RC   (   R   R.   R/   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt(   test_binop_supertype_rop_not_implementedw
  s
    	c         C   s5   t  d  } t | j    } |  j | t j  d  S(   Ns   
        class A(object):
            def __add__(self): return NotImplemented
        class B(A):
            def __radd__(self, other):
                 return NotImplemented
        A() + B() #@
        (   R   R   R)   R"   R   Rz   (   R   R.   R/   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt)   test_binop_supertype_both_not_implemented
  s    	c         C   s@   t  d  } x- | D]% } |  j t | j    t j  q Wd  S(   Ns*  
        from unknown import Unknown
        class A(object):
           def __add__(self, other): return NotImplemented
        class B(object):
           def __add__(self, other): return Unknown
        A() + Unknown #@
        Unknown + A() #@
        B() + A() #@
        A() + B() #@
        (   R   R"   R   R)   R   Rz   (   R   R   R.   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_binop_inferrence_errors
  s    
	c         C   s@   t  d  } x- | D]% } |  j t | j    t j  q Wd  S(   Ns  
        class A(object):
           def __add__(self, other):
               if isinstance(other, B):
                    return NotImplemented
               if type(other) is type(self):
                    return 42
               return NotImplemented
        class B(A): pass
        class C(object):
           def __radd__(self, other):
               if isinstance(other, B):
                   return 42
               return NotImplemented
        A() + B() #@
        B() + A() #@
        A() + C() #@
        C() + A() #@
        (   R   R"   R   R)   R   Rz   (   R   R   R.   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_binop_ambiguity
  s    	c         C   sH   t  d  } t | j    } |  j | t j  |  j | j d  d  S(   Ns   
        class Meta(type):
            def __getitem__(cls, arg):
                return 24
        import six
        @six.add_metaclass(Meta)
        class A(object):
            pass

        A['Awesome'] #@
        i   (   R   R   R)   R*   R   R7   R"   R&   (   R   R  R/   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_metaclass__getitem__
  s
    
	c         C   sH   t  d  } t | j    } |  j | t j  |  j | j d  d  S(   Ns   
        class Meta(type):
            def __or__(self, other):
                return 24
        import six
        @six.add_metaclass(Meta)
        class A(object):
            pass

        A | A
        i   (   R   R   R)   R*   R   R7   R"   R&   (   R   R  R/   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_bin_op_classes
  s
    
	c         C   sN   t  d  } t | j    } |  j | t j  |  j t | j  d  d  S(   Nsd  
        class A(object):
            def __init__(self):
                self.foo = 42
            def __add__(self, other):
                return other.bar + self.foo / 2

        class B(A):
            def __init__(self):
                self.bar = 24
        def __radd__(self, other):
            return NotImplemented

        A() + B() #@
        i-   (	   R   R   R)   R*   R   R7   R"   R  R&   (   R   R  R/   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt.   test_bin_op_supertype_more_complicated_example
  s
    	c         C   s/   t  d  } |  j t | j    t j  d  S(   Ns   
        class A(object):
            def __iadd__(self, other): return NotImplemented
            def __add__(self, other): return NotImplemented
        A() + A() #@
        (   R   R"   R   R)   R   Rz   (   R   R  (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt%   test_aug_op_same_type_not_implemented
  s    	c         C   sE   t  d  } t | j    } |  j | t  |  j | j d  d  S(   Nsz   
        class A(object):
            def __iadd__(self, other): return other
        f = A()
        f += A() #@
        R   (   R   R   R)   R*   R   R"   RC   (   R   R  R/   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt%   test_aug_op_same_type_aug_implemented
  s
    	c         C   sH   t  d  } t | j    } |  j | t j  |  j | j d  d  S(   Ns   
        class A(object):
            def __iadd__(self, other): return NotImplemented
            def __add__(self, other): return 42
        f = A()
        f += A() #@
        i*   (   R   R   R)   R*   R   R7   R"   R&   (   R   R  R/   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt<   test_aug_op_same_type_aug_not_implemented_normal_implemented
  s
    	c         C   s/   t  d  } |  j t | j    t j  d  S(   Ns   
        class A(object):
            def __iadd__(self, other): return NotImplemented
            def __add__(self, other): return NotImplemented
        class B(A):
            pass
        b = B()
        b+=A() #@
        (   R   R"   R   R)   R   Rz   (   R   R  (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt(   test_aug_op_subtype_both_not_implemented  s    	c         C   sH   t  d  } t | j    } |  j | t j  |  j | j d  d  S(   Ns   
        class A(object):
            def __iadd__(self, other): return 42
        class B(A):
            pass
        b = B()
        b+=A() #@
        i*   (   R   R   R)   R*   R   R7   R"   R&   (   R   R  R/   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt)   test_aug_op_subtype_aug_op_is_implemented  s
    	c         C   sH   t  d  } t | j    } |  j | t j  |  j | j d  d  S(   Ns   
        class A(object):
            def __add__(self, other): return 42
        class B(A):
            pass
        b = B()
        b+=A() #@
        i*   (   R   R   R)   R*   R   R7   R"   R&   (   R   R  R/   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt,   test_aug_op_subtype_normal_op_is_implemented$  s
    	c         C   s/   t  d  } |  j t | j    t j  d  S(   Nsi   
        class A(object): pass
        class B(object): pass
        f = A()
        f += B() #@
        (   R   R"   R   R)   R   Rz   (   R   R  (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt.   test_aug_different_types_no_method_implemented1  s    	c         C   sE   t  d  } t | j    } |  j | t  |  j | j d  d  S(   Ns   
        class A(object):
            def __iadd__(self, other): return other
        class B(object): pass
        f = A()
        f += B() #@
        Ri  (   R   R   R)   R*   R   R"   RC   (   R   R  R/   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt*   test_aug_different_types_augop_implemented:  s
    	c         C   sE   t  d  } t | j    } |  j | t  |  j | j d  d  S(   Ns   
        class A(object):
            def __iadd__(self, other): return NotImplemented
            def __add__(self, other): return other
        class B(object): pass
        f = A()
        f += B() #@
        Ri  (   R   R   R)   R*   R   R"   RC   (   R   R  R/   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt,   test_aug_different_types_aug_not_implementedF  s
    	c         C   sE   t  d  } t | j    } |  j | t  |  j | j d  d  S(   Ns  
        class A(object):
            def __iadd__(self, other): return NotImplemented
            def __add__(self, other): return NotImplemented
        class B(object):
            def __radd__(self, other): return other
        f = A()
        f += B() #@
        R   (   R   R   R)   R*   R   R"   RC   (   R   R  R/   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt9   test_aug_different_types_aug_not_implemented_rop_fallbackS  s
    	c         C   s/   t  d  } |  j t | j    t j  d  S(   Nsi   
        class A(object): pass
        class B(object): pass
        a = A()
        a += B() #@
        (   R   R"   R   R)   R   Rz   (   R   R  (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt&   test_augop_supertypes_none_implementeda  s    	c         C   s/   t  d  } |  j t | j    t j  d  S(   Ns  
        class A(object):
            def __iadd__(self, other): return NotImplemented
            def __add__(self, other): return NotImplemented
        class B(object):
            def __add__(self, other): return NotImplemented
        a = A()
        a += B() #@
        (   R   R"   R   R)   R   Rz   (   R   R  (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt6   test_augop_supertypes_not_implemented_returned_for_allj  s    	c         C   sE   t  d  } t | j    } |  j | t  |  j | j d  d  S(   Ns   
        class A(object):
            def __iadd__(self, other): return other
        class B(A): pass
        a = A()
        a += B() #@
        Ri  (   R   R   R)   R*   R   R"   RC   (   R   R  R/   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt'   test_augop_supertypes_augop_implementedv  s
    	c         C   sE   t  d  } t | j    } |  j | t  |  j | j d  d  S(   Ns   
        class A(object):
            def __iadd__(self, other): return NotImplemented
        class B(A):
            def __radd__(self, other): return other
        a = A()
        a += B() #@
        R   (   R   R   R)   R*   R   R"   RC   (   R   R  R/   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt1   test_augop_supertypes_reflected_binop_implemented  s
    	c         C   sE   t  d  } t | j    } |  j | t  |  j | j d  d  S(   Ns  
        class A(object):
            def __iadd__(self, other): return NotImplemented
            def __add__(self, other): return other
        class B(A):
            def __radd__(self, other): return NotImplemented

        a = A()
        a += B() #@
        Ri  (   R   R   R)   R*   R   R"   RC   (   R   R  R/   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt.   test_augop_supertypes_normal_binop_implemented  s
    		c         C   st   t  d  } d d g } xU t | |  D]D \ } } t | j    } |  j | t j  |  j | j |  q( Wd  S(   NsE   
        "a%d%d" % (1, 2) #@
        "a%(x)s" % {"x": 42} #@
        t   a12t   a42(	   R   R   R   R)   R*   R   R7   R"   R&   (   R   R   R8   R.   R   R/   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_string_interpolation  s    	c         C   s   t  d  } t | d j    } |  j | t j  |  j g  | j   D] } | j ^ qH d d d d g  x7 | d D]+ } t | j    } |  j | t	 j
  qx Wd  S(   Ns"  
        class Index(object):
            def __index__(self): return 2
        class NotIndex(object): pass
        class NotIndex2(object):
            def __index__(self): return None
        a = [1, 2]
        a * Index() #@
        a * NotIndex() #@
        a * NotIndex2() #@
        i    i   i   (   R   R   R)   R*   R   R   R"   R"  R&   R   Rz   (   R   R   R  R.   t   restR/   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_mul_list_supports__index__  s    
	%c         C   s   t  d  } t | d j    } |  j | t j  |  j | j d  t | d j    } |  j | t j  |  j | j d  |  j t	 t | d j    d  S(   Ns  
        class Index(object):
            def __index__(self): return 2
        class LambdaIndex(object):
            __index__ = lambda self: self.foo
            @property
            def foo(self): return 1
        class NonIndex(object):
            __index__ = lambda self: None
        a = [1, 2, 3, 4]
        a[Index()] #@
        a[LambdaIndex()] #@
        a[NonIndex()] #@
        i    i   i   i   (
   R   R   R)   R*   R   R7   R"   R&   R!   R   (   R   R   R  R  (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt    test_subscript_supports__index__  s    	c         C   sH   t  d  } t | j    } |  j | t j  |  j | j d  d  S(   Ns   
        class Info(object):
            def __add__(self, other):
                return "lala"
            __or__ = __add__

        f = Info()
        f | Info() #@
        t   lala(   R   R   R)   R*   R   R7   R"   R&   (   R   R  R/   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt+   test_special_method_masquerading_as_another  s
    	c         C   sH   t  d  } t | j    } |  j | t j  |  j | j d  d  S(   Ns   
        class A(object): pass
        def pos(self):
            return 42
        A.__pos__ = pos
        f = A()
        +f #@
        i*   (   R   R   R)   R*   R   R7   R"   R&   (   R   R  R/   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_unary_op_assignment  s
    	c         C   sH   t  d  } t | j    } |  j | t j  |  j | j d  d  S(   Ns   
        import six
        class Meta(type):
            def __invert__(self):
                return 42
        @six.add_metaclass(Meta)
        class A(object):
            pass
        ~A
        i*   (   R   R   R)   R*   R   R7   R"   R&   (   R   R  R/   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_unary_op_classes  s
    		c         C   sh   xa | D]Y \ } } t  |  } t | j    } |  j | |  |  j | |  | | j    q Wd  S(   N(   R   R   R)   R*   R"   t	   as_string(   R   R  Rd  t   get_eltsR   R8   R  R/   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   _slicing_test_helper  s    c         C   s   d d d d g f d d d d g f d d d d g f d d d d g f d d d g f d	 d d g f d
 d d g f d d d d g f d d d g f d d d d g f d d g f d d d g f f } |  j  | t j d    d  S(   Ns   [1, 2, 3][:] #@i   i   i   s   [1, 2, 3][0:] #@s   [1, 2, 3][None:] #@s   [1, 2, 3][None:None] #@s   [1, 2, 3][0:-1] #@s   [1, 2, 3][0:2] #@s   [1, 2, 3][0:2:None] #@s   [1, 2, 3][::] #@s   [1, 2, 3][::2] #@s   [1, 2, 3][::-1] #@s   [1, 2, 3][0:2:2] #@s    [1, 2, 3, 4, 5, 6][0:4-1:2+0] #@c         S   s   g  |  j  D] } | j ^ q
 S(   N(   R,   R&   (   R/   R(   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyR4     s    (   R,  R   R   (   R   R  (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_slicing_list  s    	c         C   s   d d d d g f d d d d g f d d d d g f d d d d g f d d d g f d	 d d g f d
 d d g f d d d d g f d d d g f d d d d g f d d g f d d d g f f } |  j  | t j d    d  S(   Ns   (1, 2, 3)[:] #@i   i   i   s   (1, 2, 3)[0:] #@s   (1, 2, 3)[None:] #@s   (1, 2, 3)[None:None] #@s   (1, 2, 3)[0:-1] #@s   (1, 2, 3)[0:2] #@s   (1, 2, 3)[0:2:None] #@s   (1, 2, 3)[::] #@s   (1, 2, 3)[::2] #@s   (1, 2, 3)[::-1] #@s   (1, 2, 3)[0:2:2] #@s    (1, 2, 3, 4, 5, 6)[0:4-1:2+0] #@c         S   s   g  |  j  D] } | j ^ q
 S(   N(   R,   R&   (   R/   R(   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyR4   +  s    (   R,  R   R[   (   R   R  (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_slicing_tuple  s    	c         C   sG   d d d d d d d d d d d d f } |  j  | t j d    d  S(   Ns   '123'[:] #@t   123s   '123'[0:] #@s   '123'[None:] #@s   '123'[None:None] #@s   '123'[0:-1] #@t   12s   '123'[0:2] #@s   '123'[0:2:None] #@s   '123'[::] #@s   '123'[::2] #@t   13s   '123'[::-1] #@t   321s   '123'[0:2:2] #@t   1s   '123456'[0:4-1:2+0] #@c         S   s   |  j  S(   N(   R&   (   R/   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyR4   =  s    (   s   '123'[:] #@R/  (   s   '123'[0:] #@R/  (   s   '123'[None:] #@R/  (   s   '123'[None:None] #@R/  (   s   '123'[0:-1] #@R0  (   s   '123'[0:2] #@R0  (   s   '123'[0:2:None] #@R0  (   s   '123'[::] #@R/  (   s   '123'[::2] #@R1  (   s   '123'[::-1] #@R2  (   s   '123'[0:2:2] #@R3  (   s   '123456'[0:4-1:2+0] #@R1  (   R,  R   R7   (   R   R  (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_slicing_str-  s    	c         C   sR   d d d d d d g } x3 | D]+ } t  |  } |  j t t | j    q Wd  S(   Ns   (lambda x: x)[1:2]s   1[2]s   (1, 2, 3)[a:]s   (1, 2, 3)[object:object]s   (1, 2, 3)[1:object]s   enumerate[2](   R   R!   R   R   R)   (   R   t   examplesR   R.   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_invalid_slicing_primaries?  s    	c         C   s   t  d  } d d d d g d d g d d d g g } xk t | |  D]Z \ } } t | j    } |  j | t j  |  j g  | j D] } | j	 ^ q |  qF Wd  S(   Ns   
        class A(object):
            def __getitem__(self, index):
                return [1, 2, 3, 4, 5][index]
        A()[1:] #@
        A()[:2] #@
        A()[1:4] #@
        i   i   i   i   i   (
   R   R   R   R)   R*   R   R   R"   R,   R&   (   R   R   R  R8   R.   R/   R(   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_instance_slicingL  s    		c         C   s[   t  d  } t | j    } |  j | t j  |  j | j j d  |  j	 | j
  d  S(   Ns|   
        class A(object):
            def __getitem__(self, index):
                return index
        A()[1:] #@
        i   (   R   R   R)   R*   R   t   SliceR"   R   R&   R)  t   upper(   R   R  R/   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_instance_slicing_slices_  s    	c         C   s@   t  d  } x- | D]% } |  j t | j    t j  q Wd  S(   Ns   
        class A(object):
            def __getitem__(self, index):
                return 1[index]
        A()[4:5] #@
        A()[2:] #@
        (   R   R"   R   R)   R   Rz   (   R   R   R.   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_instance_slicing_failsk  s    	c         C   s  t  d  } t | j    } |  j | t j  |  j | j d  | j   } |  j | | j	   d  t
 | j    } |  j t |  d  |  j | d | j	   d  | j d  } |  j t |  d  |  j | d t j  |  j | d j d  d  S(	   Ns   
        class Metaclass(type):
            pass
        class Entity(object):
             pass
        type.__new__(Metaclass, 'NewClass', (Entity,), {'a': 1}) #@
        t   NewClasst	   Metaclassi   i    t   EntityRO   i   (   R   R   R)   R*   R   R   R"   RC   t	   metaclassRD   R   R   R   R1  R7   R&   (   R   R  R/   R?  R   t
   attributes(    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_type__new__with_metaclassv  s    	c         C   sC   t  d  } x0 | D]( } t | j    } |  j | t  q Wd  S(   Ns   
        type.__new__(1) #@
        type.__new__(1, 2) #@
        type.__new__(1, 2, 3) #@
        type.__new__(1, 2, 3, 4, 5) #@
        (   R   R   R)   R*   R   (   R   R   R.   R/   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt$   test_type__new__not_enough_arguments  s
    	c         C   sC   t  d  } x0 | D]( } t | j    } |  j | t  q Wd  S(   Nsw   
        class Class(object): pass
        type.__new__(1, 2, 3, 4) #@
        type.__new__(Class, 2, 3, 4) #@
        (   R   R   R)   R*   R   (   R   R   R.   R/   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt$   test_type__new__invalid_mcs_argument  s
    	c         C   sC   t  d  } x0 | D]( } t | j    } |  j | t  q Wd  S(   Ns   
        class Class(type): pass
        type.__new__(Class, object, 1, 2) #@
        type.__new__(Class, 1, 1, 2) #@
        type.__new__(Class, [], 1, 2) #@
        (   R   R   R)   R*   R   (   R   R   R.   R/   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_type__new__invalid_name  s
    	c         C   sC   t  d  } x0 | D]( } t | j    } |  j | t  q Wd  S(   Ns   
        type.__new__(type, 'a', 1, 2) #@
        type.__new__(type, 'a', [], 2) #@
        type.__new__(type, 'a', {}, 2) #@
        type.__new__(type, 'a', (1, ), 2) #@
        type.__new__(type, 'a', (object, 1), 2) #@
        (   R   R   R)   R*   R   (   R   R   R.   R/   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_type__new__invalid_bases  s
    	c         C   sC   t  d  } x0 | D]( } t | j    } |  j | t  q Wd  S(   Ns   
        type.__new__(type, 'a', (), ()) #@
        type.__new__(type, 'a', (), object) #@
        type.__new__(type, 'a', (), 1) #@
        type.__new__(type, 'a', (), {object: 1}) #@
        type.__new__(type, 'a', (), {1:2, "a":5}) #@
        (   R   R   R)   R*   R   (   R   R   R.   R/   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_type__new__invalid_attrs  s
    	c         C   sb  t  d  } t | j    } |  j | t j  | j d  } |  j t |  d  |  j | d t	  |  j | d j
 t j  |  j | d j
 |  | j d  } |  j t |  d  |  j | d t	  |  j | d j
 t j  |  j | d j
 | j    | j d  } |  j t |  d  |  j | d t j  |  j | d j d  d  S(   Ns   
        class Metaclass(type):
            def test(cls): pass
            @classmethod
            def test1(cls): pass
            attr = 42
        type.__new__(Metaclass, 'A', (), {}) #@
        RY  i   i    t   test1R/  i*   (   R   R   R)   R*   R   R   R1  R"   R   R   t   boundR?  R7   R&   (   R   R  R/   RY  RG  R/  (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt    test_type__new__metaclass_lookup  s$    	c         C   ss   t  d  } t | j    } |  j | t j  g  | j d  D] } | j ^ qA } |  j | d d d g  d  S(   Ns   
        class Book(object):
             title = 'Ubik'
        class MetaBook(type):
             title = 'Grimus'
        type.__new__(MetaBook, 'book', (Book, ), {'title':'Catch 22'}) #@
        t   titles   Catch 22t   Ubikt   Grimus(	   R   R   R)   R*   R   R   R   R&   R"   (   R   R  R/   RJ  t   titles(    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt.   test_type__new__metaclass_and_ancestors_lookup  s    	%c         C   s   t  d  } t | j    } | j   } |  j | t j  |  j | j d  t | j	 d   } |  j | t j
  |  j | j d  d  S(   Ns  
        import six

        class BookMeta(type):
            author = 'Rushdie'

        def metaclass_function(*args):
            return BookMeta

        @six.add_metaclass(metaclass_function)
        class Book(object):
            pass
        Book #@
        t   BookMetat   authort   Rushdie(   R   R   R)   R?  R*   R   R   R"   RC   R   R7   R&   (   R   R  R/   R?  RP  (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_function_metaclasses  s    	c         C   s-   t  d  } |  j t j | j d   d  S(   Ns$  
        class AttributeDict(dict):
            def __getitem__(self, name):
                return self
        flow = AttributeDict()
        flow['app'] = AttributeDict()
        flow['app']['config'] = AttributeDict()
        flow['app']['config']['doffing'] = AttributeDict() #@
        i    (   R   R)  R   t
   safe_infert   targets(   R   R  (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_subscript_inference_error  s    	c         C   sE   t  d  } t | j    } |  j | t  |  j | j d  d  S(   Nsh  
        class Super(object):
           def instance(cls):
              return cls()
           instance = classmethod(instance)

        class Sub(Super):
            def method(self):
                return self

        # should see the Sub.instance() is returning a Sub
        # instance, not a Super instance
        Sub.instance().method() #@
        R  (   R   R   R)   R*   R   R"   RC   (   R   R  R/   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt$   test_classmethod_inferred_by_context  s
    	c         C   sO   t  d  } x< | D]4 } t | j    } |  j t t | j |   q Wd  S(   Ns   
        class A:
            __call__ = 42
        class B:
            __call__ = A()
        class C:
            __call = None
        A() #@
        B() #@
        C() #@
        (   R   R   R)   R!   R   R   (   R   R   R.   R/   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt6   test_infer_call_result_invalid_dunder_call_on_instance%  s
    
	c         C   s   t  d  } t | d j    } |  j | t  |  j | j d  t | d j    } |  j | t  |  j | j d  t | d j    } |  j | t  |  j | j d  d  S(   Ns  
        class A:
            def __enter__(self):
                return self
        class B:
            __enter__ = lambda self: self
        class C:
            @property
            def a(self): return A()
            def __enter__(self):
                return self.a
        with A() as a:
            a #@
        with B() as b:
            b #@
        with C() as c:
            c #@
        i    R   i   Ri  i   (   R   R   R)   R*   R   R"   RC   (   R   R   t   first_at   second_bt   third_c(    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt&   test_context_call_for_context_managers5  s    	c         C   sH   t  d  } t | j    } |  j | t j  |  j | j d  d  S(   Ns   
        class A(type):
            def test(cls):
                return cls
        import six
        @six.add_metaclass(A)
        class B(object):
            pass

        B.test() #@
        Ri  (   R   R   R)   R*   R   R   R"   RC   (   R   R  R/   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt=   test_metaclass_subclasses_arguments_are_classes_not_instancesR  s
    
	c         C   s_   t  d  } t | d j    } |  j | t j  t | d j    } |  j | t  d  S(   Ns   
        class A(type):
            def __call__(cls):
                cls #@
        class B(object):
            def __call__(cls):
                cls #@
        i    i   (   R   R   R)   R*   R   R   R   (   R   R   R  R  (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_infer_cls_in_class_methodsb  s    	c         C   sH   t  d  } t | j    } |  j | t j  |  j | j d  d  S(   NsZ   
        class A(type):
            def test(cls): return cls
        A.test() #@
        R   (   R   R   R)   R*   R   R   R"   RC   (   R   R  R/   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt2   test_metaclass_arguments_are_classes_not_instancesp  s
    	c         C   s5   t  d  } t | j    } |  j | t j  d  S(   Ns   
        class TestMetaKlass(type):
            def __new__(mcs, name, bases, ns, kwo_arg):
                return super().__new__(mcs, name, bases, ns)

        class TestKlass(metaclass=TestMetaKlass, kwo_arg=42): #@
            pass
        (   R   R   R)   R*   R   R   (   R   R  R/   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt    test_metaclass_with_keyword_args|  s    	c         C   sU   t  d  } t | j    } |  j t j   | j d  Wd  QX| j d  d  S(   Ns   
        class A(object):
            __slots__ = ('a', )
        a = A()
        a.teta = 24
        a.a = 24
        a #@
        t   tetaRO   (   R   R   R)   R!   R   t   NotFoundErrorR1  (   R   R  R/   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt%   test_delayed_attributes_without_slots  s    	c         C   s)   t  d  } t | j    j d  d  S(   Nsk   
        class A:
            __slots__ = ('a', )
        a = A()
        a.teta = 42
        a #@
        R`  (   R   R   R)   R1  (   R   R  (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt.   test_delayed_attributes_with_old_style_classes  s    	c         C   sH   t  d  } t | j    } |  j | t j  |  j | j d  d  S(   Nso   
        class X:
           m = lambda self, arg: self.z + arg
           z = 24

        X().m(4) #@
        i   (   R   R   R)   R*   R   R7   R"   R&   (   R   R  R/   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_lambda_as_methods  s
    	c         C   sH   t  d  } t | j    } |  j | t j  |  j | j d  d  S(   Ns+  
        class X(object):
            M = lambda self, arg: "a"
            x = 24
            def __init__(self):
                x = 24
                self.m = self.M(x)

        class Y(X):
            M = lambda self, arg: arg + 1
            def blurb(self):
                self.m #@
        i   (   R   R   R)   R*   R   R7   R"   R&   (   R   R  R/   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt&   test_inner_value_redefined_by_subclass  s
    	c         C   sH   t  d  } t | j    } |  j | t j  |  j | j d  d  S(   Nsd  
        class X(object):
            M = lambda self, arg: arg + 1
            x = 24
            def __init__(self):
                y = self
                self.m = y.M(1) + y.z

        class C(object):
            z = 24

        class Y(X, C):
            M = lambda self, arg: arg + 1
            def blurb(self):
                self.m #@
        i   (   R   R   R)   R*   R   R7   R"   R&   (   R   R  R/   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt/   test_inner_value_redefined_by_subclass_with_mro  s
    	c         C   sQ   t  d  } t | j    } |  j t j   | j t j d   Wd  QXd  S(   Ns>   
        def test():
            yield
        test()
        t   4(	   R   R   R)   R!   R   t   AstroidTypeErrorR   R   R7   (   R   R.   R/   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt'   test_getitem_of_class_raised_type_error  s
    	(   R$   R%   R9   R>   R5   R0   R   R[   R  R   R  R   R  R   t	   FrozenSetR  t   CODER   RB   RA   RG   RI   RK   RN   RW   R\   R_   Rc   Re   Rg   Rj   Rl   Rn   Rp   Rt   Rv   R|   R~   R   R   R   R   R   R   R   R   R   R   R   t   require_versionR   t   unittestt   expectedFailureR   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   t   osRC   R   R   R  R  R  R  R  R  R  R  R  R  R  R  R  R  R  R  R  R  R  R   R$  R&  R'  R(  R+  R,  R7  R;  R>  RF  RO  RR  RS  RV  R^  Ra  Rc  Re  Rh  Rl  Rs  Rx  R{  R}  R~  R  R  R  R  R  R  R  R  R  R  R  R  R  R  R  R  R  R  R  R  R  R  R  R  R  R  R  R  R  R  R  R  R  R  R  R  R  R  R  R  R  R  R  R  R  R  R  R  R  R   R  R  R  R  R  R  R  R  R	  R
  R  R  R  R  R  R  R  R  R  R  R  R  R  R  R  R  R  R  R  R  R  R"  R$  R%  R'  R(  R)  R,  R-  R.  R4  R6  R7  R:  R;  RA  RB  RC  RD  RE  RF  RI  RN  RR  RU  RV  RW  R[  R\  R]  R^  R_  Rb  Rc  Rd  Re  Rf  Ri  (    (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyR6   J   s  																				
												2		
			*																														
	
	
							
					#									
		%											 					,							3	5						4		K	*							;	$								
																																														
														t   GetattrTestc           B   s>   e  Z d    Z d   Z d   Z d   Z d   Z d   Z RS(   c         C   s{   t  d  } x+ | d  D] } |  j t t | j    q Wx: | d D]. } t | j    } |  j | t j |  qE Wd  S(   NsR  
        from missing import Missing
        getattr(1, Unknown) #@
        getattr(Unknown, 'a') #@
        getattr(Unknown, Unknown) #@
        getattr(Unknown, Unknown, Unknown) #@

        getattr(Missing, 'a') #@
        getattr(Missing, Missing) #@
        getattr('a', Missing) #@
        getattr('a', Missing, Missing) #@
        i   (   R   R!   R   R   R)   R"   R   Rz   (   R   R   R.   R/   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_yes_when_unknown  s    	c         C   s:   t  d  } x' | D] } |  j t t | j    q Wd  S(   NsK   
        getattr(1, 1) #@
        c = int
        getattr(1, c) #@
        (   R   R!   R   R   R)   (   R   R   R.   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_attrname_not_string  s    	c         C   s:   t  d  } x' | D] } |  j t t | j    q Wd  S(   Ns   
        getattr(1, 'ala') #@
        getattr(int, 'ala') #@
        getattr(float, 'bala') #@
        getattr({}, 'portocala') #@
        (   R   R!   R   R   R)   (   R   R   R.   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_attribute_missing  s    	c         C   s   t  d  } t | d j    } |  j | t j  |  j | j  t | d j    } |  j | t j  |  j	 | j
   d t  t | d j    } |  j | t j  |  j | j  d  S(   Ns   
        getattr(1, 'ala', None) #@
        getattr(int, 'bala', int) #@
        getattr(int, 'bala', getattr(int, 'portocala', None)) #@
        i    i   s   %s.inti   (   R   R   R)   R*   R   R7   R)  R&   R   R"   R  R
   (   R   R   R  R  t   third(    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_default  s    	c         C   s  t  d  } t | d j    } |  j | t  |  j | j j d  t | d j    } |  j | t  |  j | j	 t
 j  |  j | j	 j d  t | d j    } |  j | t  |  j | j j d  |  j | j j j	 j d  t | d j    } |  j | t  |  j | j j d  |  j | j j j	 j d  t | d	 j    } |  j | t  |  j | j j d
  d  S(   Ns  
        class A(object):
            def test(self): pass
        class B(A):
            def test_b(self): pass
        class C(A): pass
        class E(C, B):
            def test_e(self): pass

        getattr(A(), 'test') #@
        getattr(A, 'test') #@
        getattr(E(), 'test_b') #@
        getattr(E(), 'test') #@

        class X(object):
            def test(self):
                getattr(self, 'test') #@
        i    R   i   i   R  Ri  i   i   t   X(   R   R   R)   R*   R   R"   RH  RC   R	   Rr   R   R   R   (   R   R   R  R  Rt  t   fourtht   fifth(    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_lookup   s(    	c         C   s5   t  d  } t | j    } |  j | t j  d  S(   Ns.   
        getattr(lambda x: x, 'f') #@
        (   R   R   R)   R"   R   Rz   (   R   R.   R/   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_lambdaL  s    	(   R$   R%   Rq  Rr  Rs  Ru  Ry  Rz  (    (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyRp    s   				
		,t   HasattrTestc           B   s,   e  Z d    Z d   Z d   Z d   Z RS(   c         C   sF   t  d  } x3 | D]+ } t | j    } |  j | t j  q Wd  S(   Ns   
        from missing import Missing

        hasattr(Unknown, 'ala') #@

        hasattr(Missing, 'bala') #@
        hasattr('portocala', Missing) #@
        (   R   R   R)   R"   R   Rz   (   R   R   R.   R/   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_inference_errorsV  s
    	c         C   sV   t  d  } xC | D]; } t | j    } |  j | t j  |  j | j  q Wd  S(   Ns   
        class A: pass
        hasattr(int, 'ala') #@
        hasattr({}, 'bala') #@
        hasattr(A(), 'portocala') #@
        (   R   R   R)   R*   R   R7   R   R&   (   R   R   R.   R/   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_attribute_is_missingc  s    	c         C   sV   t  d  } xC | D]; } t | j    } |  j | t j  |  j | j  q Wd  S(   Ns  
        class A(object):
            def test(self): pass
        class B(A):
            def test_b(self): pass
        class C(A): pass
        class E(C, B):
            def test_e(self): pass

        hasattr(A(), 'test') #@
        hasattr(A, 'test') #@
        hasattr(E(), 'test_b') #@
        hasattr(E(), 'test') #@

        class X(object):
            def test(self):
                hasattr(self, 'test') #@
        (   R   R   R)   R*   R   R7   R   R&   (   R   R   R.   R/   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_attribute_is_not_missingo  s    	c         C   s5   t  d  } t | j    } |  j | t j  d  S(   Ns.   
        hasattr(lambda x: x, 'f') #@
        (   R   R   R)   R"   R   Rz   (   R   R.   R/   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyRz    s    	(   R$   R%   R|  R}  R~  Rz  (    (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyR{  T  s   			t
   BoolOpTestc           B   s#   e  Z d    Z d   Z d   Z RS(   c         C   s   d d d d d d d d d d d t  f d t  f d d t  f d t  f g } xE | D]= \ } } t |  } t | j    } |  j | j |  qR Wd  S(   Ns   1 and 2i   s   0 and 2i    s   1 or 2i   s   0 or 2s   0 or 0 or 1s   1 and 2 and 3i   s   1 and 2 or 3s   1 and 0 or 3s   1 or 0 and 2s   (1 and 2) and (2 and 3)s   not 2 and 3s   2 and not 3s   not 0 and 3s   True and Falses   not (True or False) and True(   s   1 and 2i   (   s   0 and 2i    (   s   1 or 2i   (   s   0 or 2i   (   s   0 or 0 or 1i   (   s   1 and 2 and 3i   (   s   1 and 2 or 3i   (   s   1 and 0 or 3i   (   s   1 or 0 and 2i   (   s   (1 and 2) and (2 and 3)i   (   s   not 0 and 3i   (   R
  R   R   R)   R"   R&   (   R   R8   R   R   R.   R/   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_bool_ops  s&    			c         C   sF   t  d  } x3 | D]+ } t | j    } |  j | t j  q Wd  S(   Ns   
        from unknown import unknown, any, not_any
        0 and unknown #@
        unknown or 0 #@
        any or not_any and unknown #@
        (   R   R   R)   R"   R   Rz   (   R   R   R.   R/   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyRq    s
    	c         C   su   t  d  } t | d j    } |  j | j d  t | d j    } |  j | t j  |  j | j d  d  S(   NsN   
        def test(): pass
        test and 0 #@
        1 and test #@
        i    i   RY  (	   R   R   R)   R"   R&   R*   R   R   RC   (   R   R   R  R  (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_other_nodes  s    	(   R$   R%   R  Rq  R  (    (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyR    s   		t   TestCallablec           B   s,   e  Z d    Z d   Z d   Z d   Z RS(   c      	   C   s   d t  f d t f d t  f d t  f d t f d t  f d t  f d t  f g } xE | D]= \ } } t |  } t | j    } |  j | j |  qU Wd  S(	   Ns   callable(len)s   callable("a")s   callable(callable)s   callable(lambda x, y: x+y)s   import os; __(callable(os))s   callable(int)s=   
             def test(): pass
             callable(test) #@sY   
             class C1:
                def meth(self): pass
             callable(C1) #@(   R   R
  R   R   R)   R"   R&   (   R   R8   R   R   R.   R/   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_callable  s    							c         C   s@   t  d  } x- | D]% } t | j    } |  j |  q Wd  S(   Ns  
        class C:
            def test(self): pass
            @staticmethod
            def static(): pass
            @classmethod
            def class_method(cls): pass
            def __call__(self): pass
        class D(C):
            pass
        class NotReallyCallableDueToPythonMisfeature(object):
            __call__ = 42
        callable(C.test) #@
        callable(C.static) #@
        callable(C.class_method) #@
        callable(C().test) #@
        callable(C().static) #@
        callable(C().class_method) #@
        C #@
        C() #@
        NotReallyCallableDueToPythonMisfeature() #@
        staticmethod #@
        classmethod #@
        property #@
        D #@
        D() #@
        (   R   R   R)   R   (   R   R   R.   R/   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_callable_methods  s
    	c         C   sF   t  d  } x3 | D]+ } t | j    } |  j | t j  q Wd  S(   Ns   
        from unknown import unknown
        callable(unknown) #@
        def test():
            return unknown
        callable(test()) #@
        (   R   R   R)   R"   R   Rz   (   R   R   R.   R/   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyR|    s
    	c         C   sC   t  d  } x0 | D]( } t | j    } |  j | j  q Wd  S(   NsR   
        callable("") #@
        callable(1) #@
        callable(True) #@
        (   R   R   R)   R   R&   (   R   R   R.   R/   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_not_callable  s
    	(   R$   R%   R  R  R|  R  (    (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyR    s   		 	t   TestBoolc           B   s#   e  Z d    Z d   Z d   Z RS(   c         C   s   d t  f d t f d t  f d t  f d t f d t  f d t f d t  f d	 t  f d
 t j f g
 } xg | D]_ \ } } t |  } t | j    } | t j k r |  j | |  qj |  j | j |  qj Wd  S(   Ns   bool()s   bool(1)s   bool(0)s   bool([])s	   bool([1])s   bool({})s
   bool(True)s   bool(False)s
   bool(None)s.   from unknown import Unknown; __(bool(Unknown))(	   R
  R   R   Rz   R   R   R)   R"   R&   (   R   R  R   R8   R.   R/   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt	   test_bool  s     									c         C   s|   t  d j d t   } t t t t t t t g } xB t | |  D]1 \ } } t | j    } |  j | j	 |  qC Wd  S(   Ns  
        class FalseClass:
           def {method}(self):
               return False
        class TrueClass:
           def {method}(self):
               return True
        class C(object):
           def __call__(self):
               return False
        class B(object):
           {method} = C()
        class LambdaBoolFalse(object):
            {method} = lambda self: self.foo
            @property
            def foo(self): return 0
        class FalseBoolLen(object):
            __len__ = lambda self: self.foo
            @property
            def foo(self): return 0
        bool(FalseClass) #@
        bool(TrueClass) #@
        bool(FalseClass()) #@
        bool(TrueClass()) #@
        bool(B()) #@
        bool(LambdaBoolFalse()) #@
        bool(FalseBoolLen()) #@
        t   method(
   R   R  R  R   R
  R   R   R)   R"   R&   (   R   R   R8   R.   R   R/   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_bool_bool_special_method%  s    c         C   sR   t  d j d t   } x3 | D]+ } t | j    } |  j | t j  q Wd  S(   Ns   
        class BoolInvalid(object):
           {method} = 42
        class LenInvalid(object):
           __len__ = "a"
        bool(BoolInvalid()) #@
        bool(LenInvalid()) #@
        R  (   R   R  R  R   R)   R"   R   Rz   (   R   R   R.   R/   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_bool_instance_not_callableG  s
    (   R$   R%   R  R  R  (    (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyR    s   		"t   TestTypec           B   s   e  Z d    Z RS(   c         C   sz   d d d d d d d g } xX | D]P \ } } t  |  } t | j    } |  j | t j  |  j | j |  q" Wd  S(   Ns   type(1)R  s
   type(type)R  s
   type(None)t   NoneTypes   type(object)s   type(dict())R   s   type({})s   type(frozenset())t	   frozenset(   s   type(1)R  (   s
   type(type)R  (   s
   type(None)R  (   s   type(object)R  (   s   type(dict())R   (   s   type({})R   (   s   type(frozenset())R  (   R   R   R)   R*   R   R   R"   RC   (   R   R  R   R8   R.   R/   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt	   test_typeW  s    	(   R$   R%   R  (    (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyR  U  s   t   ArgumentsTestc           B   s   e  Z e d     Z e d    Z d   Z e j d  d    Z d   Z	 e j d  d    Z
 d   Z d	   Z d
   Z e j d  d    Z d   Z d   Z RS(   c         C   s   |  j  } t d   | D  S(   Nc         s   s'   |  ] \ } } | j  | j  f Vq d  S(   N(   R&   (   R'   R=   R&   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pys	   <genexpr>m  s    (   R<   R+   (   R/   R<   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   _get_dict_valuej  s    	c         C   s   |  j  } t d   | D  S(   Nc         s   s   |  ] } | j  Vq d  S(   N(   R&   (   R'   R(   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pys	   <genexpr>r  s    (   R,   R   (   R/   R,   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   _get_tuple_valueo  s    	c         C   s   d d	 d
 d d d d d d d d d d d d d d g } t  d  } x[ t | |  D]J \ } } t | j    } |  j | t j  |  j |  j |  |  qU Wd  S(   Ni   i   i   i   i   i*   s  
        def func(*args):
            return args
        func() #@
        func(1) #@
        func(2, 3) #@
        func(*(4, 5)) #@
        def func(a, b, *args):
            return args
        func(1, 2, 3) #@
        func(1, 2) #@
        func(1, 2, 3, 4, 5) #@
        def func(a, b, c=42, *args):
            return args
        func(1, 2) #@
        func(1, 2, 3) #@
        func(1, 2, 3, 4) #@
        func(1, 2, 3, 4, 5) #@
        func = lambda a, b, *args: args
        func(1, 2) #@
        func(1, 2, 3) #@
        func = lambda a, b=42, *args: args
        func(1) #@
        func(1, 2) #@
        func(1, 2, 3) #@
        func(1, 2, *(42, )) #@
        (    (   i   (   i   i   (   i   i   (   i   (    (   i   i   i   (    (    (   i   (   i   i   (    (   i   (    (    (   i   (   i*   (	   R   R   R   R)   R*   R   R[   R"   R  (   R   R  R   R.   R   R/   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt	   test_argst  s    		s   3.5c         C   sz   d	 d
 g } t  d  } x[ t | |  D]J \ } } t | j    } |  j | t j  |  j |  j |  |  q( Wd  S(   Ni   i   i   i   i   i   i   s   
        def func(a, b, *args):
            return args
        func(1, 2, *(1, ), *(2, 3)) #@
        func(1, 2, *(1, ), 4, *(2, 3), 5, *(6, 7)) #@
        (   i   i   i   (   i   i   i   i   i   i   i   (	   R   R   R   R)   R*   R   R[   R"   R  (   R   R  R   R.   R   R/   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_multiple_starred_args  s    		c         C   sz   d d d d g } t  d  } xU t | |  D]D \ } } t | j    } |  j | t j  |  j | j |  q. Wd  S(   Ni*   i   i)   s   
        def func(a, b, c=42, *args):
            return c
        func(1, 2) #@
        func(1, 2, 3) #@
        func(1, 2, c=41) #@
        func(1, 2, 42, 41) #@
        (	   R   R   R   R)   R*   R   R7   R"   R&   (   R   R  R   R.   R   R/   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_defaults  s    	s   3.0c         C   s   d d d d d d d g } t  d  } xU t | |  D]D \ } } t | j    } |  j | t j  |  j | j |  q7 Wd  S(   Ni   i*   i   i6   ss  
        def test(*, f, b): return f
        test(f=24, b=33) #@
        def test(a, *, f): return f
        test(1, f=24) #@
        def test(a, *, f=42): return f
        test(1) #@
        test(1, f=23) #@
        def test(a, b, c=42, *args, f=24):
            return f
        test(1, 2, 3) #@
        test(1, 2, 3, 4) #@
        test(1, 2, 3, 4, 5, f=54) #@
        (	   R   R   R   R)   R*   R   R7   R"   R&   (   R   R  R   R.   R   R/   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_kwonly_args  s    	c         C   s   d d	 d
 g d g d g g } t  d  } xa t | |  D]P \ } } t | j    } |  j | t j  |  j |  } |  j | |  q: Wd  S(   NRO   i   RQ   i   RR   i   s   
        def test(**kwargs):
             return kwargs
        test(a=1, b=2, c=3) #@
        test(a=1) #@
        test(**{'a': 'b'}) #@
        (   RO   i   (   RQ   i   (   RR   i   (   RO   i   (   RO   RQ   (	   R   R   R   R)   R*   R   R:   R  R"   (   R   R8   R   R.   R   R/   R&   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_kwargs  s    	c         C   s   t  d  } d d g d	 g d
 d g d g g } xa t | |  D]P \ } } t | j    } |  j | t j  |  j |  } |  j | |  q@ Wd  S(   Ns   
        def test(a=42, b=24, **kwargs):
            return kwargs
        test(42, 24, c=3, d=4) #@
        test(49, b=24, d=4) #@
        test(a=42, b=33, c=3, d=42) #@
        test(a=42, **{'c':42}) #@
        RR   i   RX   i   i*   (   RR   i   (   RX   i   (   RX   i   (   RR   i   (   RX   i*   (   RR   i*   (	   R   R   R   R)   R*   R   R:   R  R"   (   R   R   R  R.   R   R/   R&   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt&   test_kwargs_and_other_named_parameters  s    			c         C   sz   d d d d g } t  d  } xU t | |  D]D \ } } t | j    } |  j | t j  |  j | j |  q. Wd  S(   Ni*   i   s   
        def test(**kwargs):
            return kwargs['f']
        test(f=42) #@
        test(**{'f': 42}) #@
        test(**dict(f=42)) #@
        def test(f=42, **kwargs):
            return kwargs['l']
        test(l=24) #@
        (	   R   R   R   R)   R*   R   R7   R"   R&   (   R   R  R   R  R&   R/   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_kwargs_access_by_name  s    		c         C   si   d d d d d g } t  d  } t | j    } |  j | t j  |  j |  } |  j | |  d  S(   NRO   i   RQ   i   RR   i   RX   i   RZ   i*   sx   
        def test(**kwargs):
             return kwargs
        test(a=1, b=2, **{'c': 3}, **{'d': 4}, f=42) #@
        (   RO   i   (   RQ   i   (   RR   i   (   RX   i   (   RZ   i*   (   R   R   R)   R*   R   R:   R  R"   (   R   R   R  R/   R&   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_multiple_kwargs  s    		c         C   sF   t  d  } x3 | D]+ } t | j    } |  j | t j  q Wd  S(   Ns   
        def test(f):
             return f
        test(f=23, **{'f': 34}) #@
        def test(f=None):
             return f
        test(f=23, **{'f':23}) #@
        (   R   R   R)   R"   R   Rz   (   R   R   R  R/   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_kwargs_are_overridden  s
    	c         C   sF   t  d  } x3 | D]+ } t | j    } |  j | t j  q Wd  S(   Ns)  
        def test(a, **kwargs): return a
        test(*missing) #@
        test(*object) #@
        test(*1) #@


        def test(**kwargs): return kwargs
        test(**miss) #@
        test(**(1, 2)) #@
        test(**1) #@
        test(**{misss:1}) #@
        test(**{object:1}) #@
        test(**{1:1}) #@
        test(**{'a':1, 'a':1}) #@

        def test(a): return a
        test() #@
        test(1, 2, 3) #@

        from unknown import unknown
        test(*unknown) #@
        def test(*args): return args
        test(*unknown) #@
        (   R   R   R)   R"   R   Rz   (   R   R   R.   R/   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_fail_to_infer_args(  s
    	(   R$   R%   t   staticmethodR  R  R  R   Rl  R  R  R  R  R  R  R  R  R  (    (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyR  h  s   	%					t	   SliceTestc           B   s,   e  Z d    Z d   Z d   Z d   Z RS(   c      	   C   s   d d d d g f d d d d g f d d d d g f d d d g f d d g f d	 d g f d
 d d g f g } xw | D]o \ } } t  d j |   } t | j    } |  j | t j  |  j g  | j D] } | j	 ^ q |  qy Wd  S(   Ns   [1, 2, 3][slice(None)]i   i   i   s   [1, 2, 3][slice(None, None)]s"   [1, 2, 3][slice(None, None, None)]s   [1, 2, 3][slice(1, None)]s   [1, 2, 3][slice(None, 1, None)]s   [1, 2, 3][slice(0, 1)]s   [1, 2, 3][slice(0, 3, 2)]s   __({})(
   R   R  R   R)   R*   R   R   R"   R,   R&   (   R   R   R.   R   R  R/   R(   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt
   test_sliceI  s    c         C   s:   t  d  } x' | D] } |  j t t | j    q Wd  S(   Ns|  
        from unknown import unknown
        [1, 2, 3][slice(None, unknown, unknown)] #@
        [1, 2, 3][slice(None, missing, missing)] #@
        [1, 2, 3][slice(object, list, tuple)] #@
        [1, 2, 3][slice(b'a')] #@
        [1, 2, 3][slice(1, 'aa')] #@
        [1, 2, 3][slice(1, 2.0, 3.0)] #@
        [1, 2, 3][slice()] #@
        [1, 2, 3][slice(1, 2, 3, 4)] #@
        (   R   R!   R   R   R)   (   R   R   R.   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_slice_inference_errorY  s    
	c         C   sG  d d f d d f d d f g } x| D]\ } } | \ } } } t |  } t | j    } |  j | t j  t | j d   }	 |  j |	 t j  |  j	 |	 j
 |  t | j d	   }
 |  j |
 t j  |  j	 |
 j
 |  t | j d
   } |  j | t j  |  j	 | j
 |  |  j	 | j   d t  q( Wd  S(   Ns   slice(2, 3, 4)i   i   i   s   slice(None, None, 4)s   slice(None, 1, None)i   t   startt   stopt   steps   %s.slice(   i   i   i   (   NNi   (   Ni   N(   R   R   R   R)   R*   R   R8  R   R7   R"   R&   t   pytypeR
   (   R   R   R   R   R   R9  R  R.   R/   t   lower_valuet   higher_valuet
   step_value(    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_slice_attributesh  s$    		c         C   sH   t  d  } t | j    } |  j | t j  |  j | j d  d  S(   Ns   type(slice(None, None, None))t   slice(   R   R   R)   R*   R   R   R"   RC   (   R   R  R/   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_slice_type~  s    (   R$   R%   R  R  R  R  (    (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyR  G  s   			t   CallSiteTestc           B   se   e  Z e d     Z d   Z d   Z e j d  d    Z d   Z	 d   Z
 d   Z d   Z RS(	   c         C   s   t  j j |   S(   N(   R   t   CallSitet	   from_call(   t   call(    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   _call_site_from_call  s    c   	      C   s   t  |  } |  j |  } |  j t | j  t |   |  j g  | j D] } | j ^ qJ |  |  j t | j  t |   xG | j   D]9 \ } } |  j | | j  |  j | j | j |  q Wd  S(   N(	   R   R  R"   R   t   positional_argumentsR&   t   keyword_argumentsR<   R   (	   R   R   t   expected_argst   expected_keywordsR  t	   call_siteR2   t   keywordR&   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   _test_call_site_pair  s    "c         C   s"   x | D] } |  j  |   q Wd  S(   N(   R  (   R   R  t   pair(    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   _test_call_site  s    s   3.5c      	   C   s~   d d d d d d d g i d d 6d d 6f d d d d d d	 d
 d g i d d 6d d 6f d g  i  f g } |  j  |  d  S(   Ns3   f(*(1, 2), *(2, 3), *(3, 4), **{'a':1}, **{'b': 2})i   i   i   i   RO   RQ   s-   f(1, 2, *(3, 4), 5, *(6, 7), f=24, **{'c':3})i   i   i   i   RZ   RR   s   f(f=24, **{'f':24})(   R  (   R   R  (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_call_site_starred_args  s    c         C   sb   d d d g i  f d d d d d g i  f d g  i d d 6d d 6d d	 6f g } |  j  |  d  S(
   Ns   f(1, 2)i   i   s   f(1, 2, *(1, 2))s   f(a=1, b=2, c=3)RO   RQ   i   RR   (   R  (   R   R  (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_call_site  s    'c         C   sF   x? | D]7 } t  |  } |  j |  } |  j | j   |  q Wd  S(   N(   R   R  R"   t   has_invalid_arguments(   R   R   R  R&   R  R  (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   _test_call_site_valid_arguments  s    c         C   sH   d d d g } |  j  | d t d d d g } |  j  | d t d  S(   Ns   f(*lala)s   f(*1)s
   f(*object)R  s   f()s	   f(*(1, ))s   f(1, 2, *(2, 3))(   R  R   R
  (   R   R   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_call_site_valid_arguments  s    c         C   s2   t  d  } |  j |  } |  j d | j  d  S(   Ns   f(f=24, **{"f": 25})RZ   (   R   R  R   t   duplicated_keywords(   R   R  t   site(    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt!   test_duplicated_keyword_arguments  s    (   R$   R%   R  R  R  R  R   Rl  R  R  R  R  R  (    (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyR    s   					
t   ObjectDunderNewTestc           B   s   e  Z d    Z RS(   c         C   s2   t  d  } t | j    } |  j | t  d  S(   NsR   
        @object.__new__
        class instance(object):
            pass
        (   R   R   R)   R*   R   (   R   R.   R/   (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt/   test_object_dunder_new_is_inferred_if_decorator  s    	(   R$   R%   R  (    (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyR    s   c          C   s7   d }  t  |   } t | j    t j k s3 t  d S(   s   Make sure inference doesn't throw a RecursionError

    Regression test for augmented assign dropping context.path
    causing recursion errors

    sP   
    def rec():
        a = 0
        a += rec()
        return a
    rec()
    N(   R   R   R)   R   Rz   R  (   R   t   cls_node(    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   test_augassign_recursion  s    t   __main__(9   t   __doc__Ro  R   t	   functoolsR    Rm  R   R   t   astroidR   R   R   t   astroid.builderR   R   t   astroid.inferenceR   R    t   astroid.basesR   R   R	   R
   R   R   R   R   R   R   R   R   t   astroid.testsR   R   t   AstroidBuilderR   RT   R  t   TestCaseR   R0   R5   t   SysPathSetupR6   Rp  R{  R  R  R  R  R  R  R  R  R  R$   t   main(    (    (    s?   lib/python2.7/site-packages/astroid/tests/unittest_inference.pyt   <module>   sn   "				             o;1NG>M	