
^Yc           @   s   d  Z  d d l m Z d d l m Z d d l m Z m Z m	 Z	 d e f d     YZ
 d e f d     YZ d	 e f d
     YZ d S(   s&   
Tests for various Pyflakes behavior.
i(   t   version_info(   t   messages(   t   TestCaset   skipt   skipIft   Testc           B   s  e  Z d    Z d   Z e e d= k d  d    Z d   Z e e d> k  d  d	    Z e e d? k  d  d
    Z	 d   Z
 d   Z d   Z d   Z d   Z d   Z d   Z e e d@ k d  d    Z d   Z d   Z e e dA k  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 e e dB k  d#  d$    Z  e e dC k  d#  d%    Z! d&   Z" d'   Z# d(   Z$ d)   Z% d*   Z& d+   Z' d,   Z( e e dD k  d-  d.    Z) e e dE k  d-  d/    Z* e+ d0  d1    Z, d2   Z- d3   Z. d4   Z/ d5   Z0 d6   Z1 d7   Z2 d8   Z3 d9   Z4 d:   Z5 d;   Z6 d<   Z7 RS(F   c         C   s   |  j  d t j  d  S(   Ns   def fu(bar, bar): pass(   t   flakest   mt   DuplicateArgument(   t   self(    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pyt   test_duplicateArgs   s    c         C   s   |  j  d t j t j  d  S(   NsG   
        a = 1
        def f():
            a; a=1
        f()
        (   R   R   t   UndefinedLocalt   UnusedVariable(   R	   (    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pyt$   test_localReferencedBeforeAssignment   s    i   s;   in Python 3 list comprehensions execute in a separate scopec         C   sW   |  j  d t j  |  j  d t j  |  j  d t j  |  j  d  |  j  d  d S(   sb   
        Test that shadowing a variable in a list comprehension raises
        a warning.
        s8   
        a = 1
        [1 for a, b in [(1, 2)]]
        sQ   
        class A:
            a = 1
            [1 for a, b in [(1, 2)]]
        sQ   
        def f():
            a = 1
            [1 for a, b in [(1, 2)]]
        sK   
        [1 for a, b in [(1, 2)]]
        [1 for a, b in [(1, 2)]]
        sY   
        for a, b in [(1, 2)]:
            pass
        [1 for a, b in [(1, 2)]]
        N(   R   R   t   RedefinedInListComp(   R	   (    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pyt   test_redefinedInListComp   s    c         C   sK   |  j  d  |  j  d  |  j  d t j  |  j  d  |  j  d  d S(   s_   
        Test that reusing a variable in a generator does not raise
        a warning.
        s8   
        a = 1
        (1 for a, b in [(1, 2)])
        sU   
        class A:
            a = 1
            list(1 for a, b in [(1, 2)])
        sQ   
        def f():
            a = 1
            (1 for a, b in [(1, 2)])
        sK   
        (1 for a, b in [(1, 2)])
        (1 for a, b in [(1, 2)])
        sY   
        for a, b in [(1, 2)]:
            pass
        (1 for a, b in [(1, 2)])
        N(   R   R   R   (   R	   (    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pyt   test_redefinedInGenerator7   s    i   i   s   Python >= 2.7 onlyc         C   sK   |  j  d  |  j  d  |  j  d t j  |  j  d  |  j  d  d S(   sg   
        Test that reusing a variable in a set comprehension does not raise
        a warning.
        s8   
        a = 1
        {1 for a, b in [(1, 2)]}
        sQ   
        class A:
            a = 1
            {1 for a, b in [(1, 2)]}
        sQ   
        def f():
            a = 1
            {1 for a, b in [(1, 2)]}
        sK   
        {1 for a, b in [(1, 2)]}
        {1 for a, b in [(1, 2)]}
        sY   
        for a, b in [(1, 2)]:
            pass
        {1 for a, b in [(1, 2)]}
        N(   R   R   R   (   R	   (    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pyt    test_redefinedInSetComprehensionT   s    c         C   sK   |  j  d  |  j  d  |  j  d t j  |  j  d  |  j  d  d S(   sh   
        Test that reusing a variable in a dict comprehension does not raise
        a warning.
        s<   
        a = 1
        {1: 42 for a, b in [(1, 2)]}
        sU   
        class A:
            a = 1
            {1: 42 for a, b in [(1, 2)]}
        sU   
        def f():
            a = 1
            {1: 42 for a, b in [(1, 2)]}
        sS   
        {1: 42 for a, b in [(1, 2)]}
        {1: 42 for a, b in [(1, 2)]}
        s]   
        for a, b in [(1, 2)]:
            pass
        {1: 42 for a, b in [(1, 2)]}
        N(   R   R   R   (   R	   (    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pyt!   test_redefinedInDictComprehensionr   s    c         C   s   |  j  d t j  d S(   sf   
        Test that shadowing a function definition with another one raises a
        warning.
        s5   
        def a(): pass
        def a(): pass
        N(   R   R   t   RedefinedWhileUnused(   R	   (    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pyt   test_redefinedFunction   s    c         C   s   |  j  d t j  d S(   sw   
        Test that shadowing a function definition in a class suite with another
        one raises a warning.
        sN   
        class A:
            def a(): pass
            def a(): pass
        N(   R   R   R   (   R	   (    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pyt   test_redefinedClassFunction   s    c         C   s   |  j  d  d S(   s{   
        Test that shadowing a function definition twice in an if
        and else block does not raise a warning.
        s\   
        if True:
            def a(): pass
        else:
            def a(): pass
        N(   R   (   R	   (    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pyt   test_redefinedIfElseFunction   s    c         C   s   |  j  d t j  d S(   sh   
        Test that shadowing a function definition within an if block
        raises a warning.
        sN   
        if True:
            def a(): pass
            def a(): pass
        N(   R   R   R   (   R	   (    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pyt   test_redefinedIfFunction   s    c         C   s   |  j  d  d S(   s{   
        Test that shadowing a function definition twice in try
        and except block does not raise a warning.
        sZ   
        try:
            def a(): pass
        except:
            def a(): pass
        N(   R   (   R	   (    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pyt   test_redefinedTryExceptFunction   s    c         C   s   |  j  d t j  d S(   sh   
        Test that shadowing a function definition within a try block
        raises a warning.
        sk   
        try:
            def a(): pass
            def a(): pass
        except:
            pass
        N(   R   R   R   (   R	   (    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pyt   test_redefinedTryFunction   s    c         C   s   |  j  d  d S(   s   
        Test that shadowing a variable in a list comprehension in
        an if and else block does not raise a warning.
        sY   
        if False:
            a = 1
        else:
            [a for a in '12']
        N(   R   (   R	   (    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pyt   test_redefinedIfElseInListComp   s    c         C   s   |  j  d t j  d S(   s{   
        Test that shadowing a variable in a list comprehension in
        an else (or if) block raises a warning.
        sj   
        if False:
            pass
        else:
            a = 1
            [a for a in '12']
        N(   R   R   R   (   R	   (    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pyt   test_redefinedElseInListComp   s    c         C   s   |  j  d  d S(   s   
        Test that shadowing a function definition with a decorated version of
        that function does not raise a warning.
        si   
        from somewhere import somedecorator

        def a(): pass
        a = somedecorator(a)
        N(   R   (   R	   (    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pyt   test_functionDecorator   s    c         C   s   |  j  d  d S(   s   
        Test that shadowing a function definition in a class suite with a
        decorated version of that function does not raise a warning.
        sS   
        class A:
            def a(): pass
            a = classmethod(a)
        N(   R   (   R	   (    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pyt   test_classFunctionDecorator   s    i   s   Python >= 2.6 onlyc         C   s   |  j  d  d  S(   Ns   
        class A:
            @property
            def t(self):
                pass
            @t.setter
            def t(self, value):
                pass
            @t.deleter
            def t(self):
                pass
        (   R   (   R	   (    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pyt   test_modernProperty  s    c         C   s   |  j  d  d S(   s   Don't die on unary +.s   +1N(   R   (   R	   (    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pyt   test_unaryPlus  s    c         C   s   |  j  d t j  d S(   sn   
        If a name in the base list of a class definition is undefined, a
        warning is emitted.
        s2   
        class foo(foo):
            pass
        N(   R   R   t   UndefinedName(   R	   (    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pyt   test_undefinedBaseClass  s    c         C   s   |  j  d t j  d S(   s   
        If a class name is used in the body of that class's definition and
        the name is not already defined, a warning is emitted.
        s,   
        class foo:
            foo
        N(   R   R   R    (   R	   (    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pyt"   test_classNameUndefinedInClassBody$  s    c         C   s   |  j  d  d S(   s   
        If a class name is used in the body of that class's definition and
        the name was previously defined in some other way, no warning is
        emitted.
        s?   
        foo = None
        class foo:
            foo
        N(   R   (   R	   (    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pyt   test_classNameDefinedPreviously.  s    c         C   s   |  j  d t j  d S(   sW   
        If a class is defined twice in the same module, a warning is emitted.
        sQ   
        class Foo:
            pass
        class Foo:
            pass
        N(   R   R   R   (   R	   (    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pyt   test_classRedefinition:  s    c         C   s   |  j  d t j  d S(   sN   
        If a function is redefined as a class, a warning is emitted.
        sQ   
        def Foo():
            pass
        class Foo:
            pass
        N(   R   R   R   (   R	   (    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pyt   test_functionRedefinedAsClassE  s    c         C   s   |  j  d t j  d S(   sN   
        If a class is redefined as a function, a warning is emitted.
        sQ   
        class Foo:
            pass
        def Foo():
            pass
        N(   R   R   R   (   R	   (    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pyt   test_classRedefinedAsFunctionP  s    c         C   s   |  j  d t j  d S(   sK   
        If a return is used inside a class, a warning is emitted.
        s7   
        class Foo(object):
            return
        N(   R   R   t   ReturnOutsideFunction(   R	   (    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pyt   test_classWithReturn[  s    c         C   s   |  j  d t j  d S(   sP   
        If a return is used at the module level, a warning is emitted.
        s   
        return
        N(   R   R   R'   (   R	   (    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pyt   test_moduleWithReturnd  s    c         C   s   |  j  d t j  d S(   sJ   
        If a yield is used inside a class, a warning is emitted.
        s6   
        class Foo(object):
            yield
        N(   R   R   t   YieldOutsideFunction(   R	   (    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pyt   test_classWithYieldl  s    c         C   s   |  j  d t j  d S(   sO   
        If a yield is used at the module level, a warning is emitted.
        s   
        yield
        N(   R   R   R*   (   R	   (    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pyt   test_moduleWithYieldu  s    s   Python >= 3.3 onlyc         C   s   |  j  d t j  d S(   sO   
        If a yield from is used inside a class, a warning is emitted.
        sE   
        class Foo(object):
            yield from range(10)
        N(   R   R   R*   (   R	   (    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pyt   test_classWithYieldFrom}  s    c         C   s   |  j  d t j  d S(   sT   
        If a yield from is used at the module level, a warning is emitted.
        s&   
        yield from range(10)
        N(   R   R   R*   (   R	   (    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pyt   test_moduleWithYieldFrom  s    c         C   sv   |  j  d t j  |  j  d t j  |  j  d t j  |  j  d t j  |  j  d t j  |  j  d t j  d  S(   Ns   
        continue
        s/   
        def f():
            continue
        sQ   
        while True:
            pass
        else:
            continue
        s   
        while True:
            pass
        else:
            if 1:
                if 2:
                    continue
        sK   
        while True:
            def f():
                continue
        sK   
        while True:
            class A:
                continue
        (   R   R   t   ContinueOutsideLoop(   R	   (    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pyt   test_continueOutsideLoop  s    c         C   sR   |  j  d  |  j  d  |  j  d  |  j  d  |  j  d  |  j  d  d  S(   Ns2   
        while True:
            continue
        s:   
        for i in range(10):
            continue
        sH   
        while True:
            if 1:
                continue
        sP   
        for i in range(10):
            if 1:
                continue
        s   
        while True:
            while True:
                pass
            else:
                continue
        else:
            pass
        s   
        while True:
            try:
                pass
            finally:
                while True:
                    continue
        (   R   (   R	   (    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pyt   test_continueInsideLoop  s    c         C   s=   |  j  d t j  |  j  d t j  |  j  d t j  d  S(   Nsq   
        while True:
            try:
                pass
            finally:
                continue
        s   
        while True:
            try:
                pass
            finally:
                if 1:
                    if 2:
                        continue
        sM   
        try:
            pass
        finally:
            continue
        (   R   R   t   ContinueInFinally(   R	   (    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pyt   test_continueInFinally  s    c         C   s   |  j  d t j  |  j  d t j  |  j  d t j  |  j  d t j  |  j  d t j  |  j  d t j  |  j  d t j  d  S(   Ns   
        break
        s,   
        def f():
            break
        sN   
        while True:
            pass
        else:
            break
        s~   
        while True:
            pass
        else:
            if 1:
                if 2:
                    break
        sH   
        while True:
            def f():
                break
        sH   
        while True:
            class A:
                break
        sJ   
        try:
            pass
        finally:
            break
        (   R   R   t   BreakOutsideLoop(   R	   (    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pyt   test_breakOutsideLoop  s    c         C   sl   |  j  d  |  j  d  |  j  d  |  j  d  |  j  d  |  j  d  |  j  d  |  j  d  d  S(	   Ns/   
        while True:
            break
        s7   
        for i in range(10):
            break
        sE   
        while True:
            if 1:
                break
        sM   
        for i in range(10):
            if 1:
                break
        s   
        while True:
            while True:
                pass
            else:
                break
        else:
            pass
        s   
        while True:
            try:
                pass
            finally:
                while True:
                    break
        sn   
        while True:
            try:
                pass
            finally:
                break
        s   
        while True:
            try:
                pass
            finally:
                if 1:
                    if 2:
                        break
        (   R   (   R	   (    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pyt   test_breakInsideLoop)  s     c         C   sR   |  j  d  |  j  d  |  j  d  |  j  d  |  j  d  |  j  d  d S(   s#  
        A default except block should be last.

        YES:

        try:
            ...
        except Exception:
            ...
        except:
            ...

        NO:

        try:
            ...
        except:
            ...
        except Exception:
            ...
        sS   
        try:
            pass
        except ValueError:
            pass
        st   
        try:
            pass
        except ValueError:
            pass
        except:
            pass
        sH   
        try:
            pass
        except:
            pass
        sr   
        try:
            pass
        except ValueError:
            pass
        else:
            pass
        sg   
        try:
            pass
        except:
            pass
        else:
            pass
        s   
        try:
            pass
        except ValueError:
            pass
        except:
            pass
        else:
            pass
        N(   R   (   R	   (    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pyt   test_defaultExceptLaste  s    	c         C   sL  |  j  d t j  |  j  d t j  |  j  d t j  |  j  d t j t j  |  j  d t j  |  j  d t j  |  j  d t j  |  j  d t j t j  |  j  d	 t j  |  j  d
 t j  |  j  d t j  |  j  d t j t j  |  j  d t j  |  j  d t j  |  j  d t j  |  j  d t j t j  d  S(   Nst   
        try:
            pass
        except:
            pass
        except ValueError:
            pass
        si   
        try:
            pass
        except:
            pass
        except:
            pass
        s   
        try:
            pass
        except:
            pass
        except ValueError:
            pass
        except:
            pass
        s   
        try:
            pass
        except:
            pass
        except ValueError:
            pass
        except:
            pass
        except ValueError:
            pass
        s   
        try:
            pass
        except:
            pass
        except ValueError:
            pass
        else:
            pass
        s   
        try:
            pass
        except:
            pass
        except:
            pass
        else:
            pass
        s   
        try:
            pass
        except:
            pass
        except ValueError:
            pass
        except:
            pass
        else:
            pass
        s   
        try:
            pass
        except:
            pass
        except ValueError:
            pass
        except:
            pass
        except ValueError:
            pass
        else:
            pass
        s   
        try:
            pass
        except:
            pass
        except ValueError:
            pass
        finally:
            pass
        s   
        try:
            pass
        except:
            pass
        except:
            pass
        finally:
            pass
        s   
        try:
            pass
        except:
            pass
        except ValueError:
            pass
        except:
            pass
        finally:
            pass
        s   
        try:
            pass
        except:
            pass
        except ValueError:
            pass
        except:
            pass
        except ValueError:
            pass
        finally:
            pass
        s   
        try:
            pass
        except:
            pass
        except ValueError:
            pass
        else:
            pass
        finally:
            pass
        s   
        try:
            pass
        except:
            pass
        except:
            pass
        else:
            pass
        finally:
            pass
        s   
        try:
            pass
        except:
            pass
        except ValueError:
            pass
        except:
            pass
        else:
            pass
        finally:
            pass
        s  
        try:
            pass
        except:
            pass
        except ValueError:
            pass
        except:
            pass
        except ValueError:
            pass
        else:
            pass
        finally:
            pass
        (   R   R   t   DefaultExceptNotLast(   R	   (    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pyt   test_defaultExceptNotLast  s@    					s   Python 3 onlyc         C   s  |  j  d  |  j  d  |  j  d  |  j  d  |  j  d  |  j  d  |  j  d  |  j  d  |  j  d	  d
 j d   t d d > D  d } |  j  |  d d
 j d   t d d > D  d } |  j  |  d d
 j d   t d d > D  d } |  j  |  d S(   s6   
        Python 3 extended iterable unpacking
        s#   
        a, *b = range(10)
        s#   
        *a, b = range(10)
        s&   
        a, *b, c = range(10)
        s%   
        (a, *b) = range(10)
        s%   
        (*a, b) = range(10)
        s(   
        (a, *b, c) = range(10)
        s%   
        [a, *b] = range(10)
        s%   
        [*a, b] = range(10)
        s(   
        [a, *b, c] = range(10)
        s   , c         s   s   |  ] } d  | Vq d S(   s   a%dN(    (   t   .0t   i(    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pys	   <genexpr>  s    i   i   s   , *rest = range(1<<8)t   (c         s   s   |  ] } d  | Vq d S(   s   a%dN(    (   R:   R;   (    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pys	   <genexpr>  s    s   , *rest) = range(1<<8)t   [c         s   s   |  ] } d  | Vq d S(   s   a%dN(    (   R:   R;   (    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pys	   <genexpr>  s    s   , *rest] = range(1<<8)Ni   i   i   (   R   t   joint   range(   R	   t   s(    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pyt   test_starredAssignmentNoErrorx  s6     $$c         C   s  d j  d   t d  D  d } |  j | t j  d d j  d   t d  D  d } |  j | t j  d	 d j  d
   t d  D  d } |  j | t j  d j  d   t d d > D  d } |  j | t j  d d j  d   t d d  > D  d } |  j | t j  d	 d j  d   t d d! > D  d } |  j | t j  |  j d t j  |  j d t j  |  j d t j  |  j d t j  |  j d t j  |  j d t j  |  j d t j  |  j d t j  |  j d t j  d S("   sp   
        SyntaxErrors (not encoded in the ast) surrounding Python 3 extended
        iterable unpacking
        s   , c         s   s   |  ] } d  | Vq d S(   s   a%dN(    (   R:   R;   (    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pys	   <genexpr>  s    i   i   s   , *rest = range(1<<8 + 1)R<   c         s   s   |  ] } d  | Vq d S(   s   a%dN(    (   R:   R;   (    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pys	   <genexpr>  s    s   , *rest) = range(1<<8 + 1)R=   c         s   s   |  ] } d  | Vq d S(   s   a%dN(    (   R:   R;   (    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pys	   <genexpr>  s    s   , *rest] = range(1<<8 + 1)c         s   s   |  ] } d  | Vq d S(   s   a%dN(    (   R:   R;   (    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pys	   <genexpr>  s    s   , *rest = range(1<<8 + 2)c         s   s   |  ] } d  | Vq d S(   s   a%dN(    (   R:   R;   (    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pys	   <genexpr>  s    s   , *rest) = range(1<<8 + 2)c         s   s   |  ] } d  | Vq d S(   s   a%dN(    (   R:   R;   (    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pys	   <genexpr>  s    s   , *rest] = range(1<<8 + 2)s'   
        a, *b, *c = range(10)
        s*   
        a, *b, c, *d = range(10)
        s(   
        *a, *b, *c = range(10)
        s)   
        (a, *b, *c) = range(10)
        s,   
        (a, *b, c, *d) = range(10)
        s*   
        (*a, *b, *c) = range(10)
        s)   
        [a, *b, *c] = range(10)
        s,   
        [a, *b, c, *d] = range(10)
        s*   
        [*a, *b, *c] = range(10)
        Ni   i   i   i	   i	   i	   (   R>   R?   R   R   t%   TooManyExpressionsInStarredAssignmentt   TwoStarredExpressions(   R	   R@   (    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pyt   test_starredAssignmentErrors  sH       $$s<   todo: Too hard to make this warn but other cases stay silentc         C   s   |  j  d t j  d S(   sd   
        If a variable is re-assigned to without being used, no warning is
        emitted.
        s'   
        x = 10
        x = 20
        N(   R   R   R   (   R	   (    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pyt   test_doubleAssignment  s    c         C   s   |  j  d  d S(   sc   
        If a variable is re-assigned within a conditional, no warning is
        emitted.
        s<   
        x = 10
        if True:
            x = 20
        N(   R   (   R	   (    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pyt"   test_doubleAssignmentConditionally  s    c         C   s   |  j  d  d S(   sb   
        If a variable is re-assigned to after being used, no warning is
        emitted.
        s9   
        x = 10
        y = x * 2
        x = 20
        N(   R   (   R	   (    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pyt   test_doubleAssignmentWithUse  s    c         C   s   |  j  d  d S(   s   
        If a defined name is used on either side of any of the six comparison
        operators, no warning is emitted.
        s   
        x = 10
        y = 20
        x < y
        x <= y
        x == y
        x != y
        x >= y
        x > y
        N(   R   (   R	   (    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pyt   test_comparison  s    	c         C   s   |  j  d  d S(   sn   
        If a defined name is used on either side of an identity test, no
        warning is emitted.
        sI   
        x = 10
        y = 20
        x is y
        x is not y
        N(   R   (   R	   (    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pyt   test_identity'  s    c         C   s   |  j  d  d S(   sp   
        If a defined name is used on either side of a containment test, no
        warning is emitted.
        sI   
        x = 10
        y = 20
        x in y
        x not in y
        N(   R   (   R	   (    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pyt   test_containment3  s    c         C   s   |  j  d  |  j  d  d S(   s>   
        break and continue statements are supported.
        s4   
        for x in [1, 2]:
            break
        s7   
        for x in [1, 2]:
            continue
        N(   R   (   R	   (    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pyt   test_loopControl?  s    c         C   s   |  j  d  d S(   s3   
        Ellipsis in a slice is supported.
        s   
        [1, 2][...]
        N(   R   (   R	   (    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pyt   test_ellipsisL  s    c         C   s   |  j  d  d S(   s0   
        Extended slices are supported.
        s+   
        x = 3
        [1, 2][x,:]
        N(   R   (   R	   (    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pyt   test_extendedSliceT  s    c         C   s   |  j  d  d S(   sh   
        Augmented assignment of a variable is supported.
        We don't care about var refs.
        s*   
        foo = 0
        foo += 1
        N(   R   (   R	   (    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pyt   test_varAugmentedAssignment]  s    c         C   s   |  j  d  d S(   si   
        Augmented assignment of attributes is supported.
        We don't care about attr refs.
        s7   
        foo = None
        foo.bar += foo.baz
        N(   R   (   R	   (    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pyt   test_attrAugmentedAssignmentg  s    c         C   s   |  j  d  d S(   sP   
        A 'global' can be declared in one scope and reused in another.
        sV   
        def f(): global foo
        def g(): foo = 'anything'; foo.is_used()
        N(   R   (   R	   (    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pyt#   test_globalDeclaredInDifferentScopeq  s    (   i   (   i   i   (   i   i   (   i   (   i   i   (   i   i   (   i   i   (   i   (   i   (8   t   __name__t
   __module__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.   R0   R1   R3   R5   R6   R7   R9   RA   RD   R   RE   RF   RG   RH   RI   RJ   RK   RL   RM   RN   RO   RP   (    (    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pyR      sj   				
										
	
										
		&	*		-	<	J	6H										
	
t   TestUnusedAssignmentc           B   s!  e  Z d  Z d   Z d   Z d   Z e d  d    Z d   Z d   Z	 e
 e d8 k  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& e
 e d9 k  d'  d(    Z' e
 e d: k  d'  d)    Z( d*   Z) d+   Z* d,   Z+ d-   Z, d.   Z- d/   Z. d0   Z/ d1   Z0 d2   Z1 e
 e d; k  d3  d4    Z2 e
 e d< k  d6  d7    Z3 RS(=   s5   
    Tests for warning about unused assignments.
    c         C   s   |  j  d t j  d S(   sc   
        Warn when a variable in a function is assigned a value that's never
        used.
        s,   
        def a():
            b = 1
        N(   R   R   R   (   R	   (    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pyt   test_unusedVariable  s    c         C   s   |  j  d  d S(   sO   
        Using locals() it is perfectly valid to have unused variables
        sH   
        def a():
            b = 1
            return locals()
        N(   R   (   R	   (    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pyt   test_unusedVariableAsLocals  s    c         C   s   |  j  d t j  d S(   sA   
        Using locals() in wrong scope should not matter
        sq   
        def a():
            locals()
            def a():
                b = 1
                return
        N(   R   R   R   (   R	   (    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pyt   test_unusedVariableNoLocals  s    sA   todo: Difficult because it doesn't apply in the context of a loopc         C   s   |  j  d t j  d S(   sV   
        Shadowing a used variable can still raise an UnusedVariable warning.
        sR   
        def a():
            b = 1
            b.foo()
            b = 2
        N(   R   R   R   (   R	   (    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pyt   test_unusedReassignedVariable  s    c         C   s   |  j  d  d S(   st   
        Shadowing a used variable cannot raise an UnusedVariable warning in the
        context of a loop.
        s^   
        def a():
            b = True
            while b:
                b = False
        N(   R   (   R	   (    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pyt   test_variableUsedInLoop  s    c         C   s   |  j  d  d S(   s   
        Assigning to a global and then not using that global is perfectly
        acceptable. Do not mistake it for an unused local variable.
        sO   
        b = 0
        def a():
            global b
            b = 1
        N(   R   (   R	   (    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pyt   test_assignToGlobal  s    i   s   new in Python 3c         C   s   |  j  d  d S(   s   
        Assigning to a nonlocal and then not using that binding is perfectly
        acceptable. Do not mistake it for an unused local variable.
        sW   
        b = b'0'
        def a():
            nonlocal b
            b = b'1'
        N(   R   (   R	   (    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pyt   test_assignToNonlocal  s    c         C   s   |  j  d  d S(   s   
        Assigning to a member of another object and then not using that member
        variable is perfectly acceptable. Do not mistake it for an unused
        local variable.
        sR   
        class b:
            pass
        def a():
            b.foo = 1
        N(   R   (   R	   (    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pyt   test_assignToMember  s    c         C   s   |  j  d  d S(   sW   
        Don't warn when a variable in a for loop is assigned to but not used.
        sO   
        def f():
            for i in range(10):
                pass
        N(   R   (   R	   (    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pyt   test_assignInForLoop  s    c         C   s   |  j  d  d S(   si   
        Don't warn when a variable in a list comprehension is
        assigned to but not used.
        s@   
        def f():
            [None for i in range(10)]
        N(   R   (   R	   (    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pyt   test_assignInListComprehension  s    c         C   s   |  j  d  d S(   sk   
        Don't warn when a variable in a generator expression is
        assigned to but not used.
        s@   
        def f():
            (None for i in range(10))
        N(   R   (   R	   (    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pyt   test_generatorExpression  s    c         C   s   |  j  d  d S(   sW   
        Don't warn when a variable assignment occurs lexically after its use.
        s   
        def f():
            x = None
            for i in range(10):
                if i > 2:
                    return x
                x = i * 2
        N(   R   (   R	   (    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pyt   test_assignmentInsideLoop  s    c         C   s]   |  j  d  |  j  d t j t j  |  j  d  |  j  d t j  |  j  d t j  d S(   s   
        Don't warn when a variable included in tuple unpacking is unused. It's
        very common for variables in a tuple unpacking assignment to be unused
        in good Python code, so warning will only create false positives.
        s6   
        def f(tup):
            (x, y) = tup
        s4   
        def f():
            (x, y) = 1, 2
        sq   
        def f():
            (x, y) = coords = 1, 2
            if x > 1:
                print(coords)
        s=   
        def f():
            (x, y) = coords = 1, 2
        s=   
        def f():
            coords = (x, y) = 1, 2
        N(   R   R   R   (   R	   (    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pyt   test_tupleUnpacking  s    c         C   s*   |  j  d  |  j  d t j t j  d S(   sR   
        Don't warn when a variable included in list unpacking is unused.
        s6   
        def f(tup):
            [x, y] = tup
        s6   
        def f():
            [x, y] = [1, 2]
        N(   R   R   R   (   R	   (    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pyt   test_listUnpacking(  s    c         C   s   |  j  d  d S(   sN   
        Don't warn when the assignment is used in an inner function.
        s~   
        def barMaker():
            foo = 5
            def bar():
                return foo
            return bar
        N(   R   (   R	   (    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pyt   test_closedOver5  s    c         C   s   |  j  d  d S(   s   
        Don't warn when the assignment is used in an inner function, even if
        that inner function itself is in an inner function.
        s   
        def barMaker():
            foo = 5
            def bar():
                def baz():
                    return foo
            return bar
        N(   R   (   R	   (    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pyt   test_doubleClosedOverA  s    c         C   s   |  j  d  d S(   s}   
        Do not warn about unused local variable __tracebackhide__, which is
        a special variable for py.test.
        sL   
            def helper():
                __tracebackhide__ = True
        N(   R   (   R	   (    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pyt!   test_tracebackhideSpecialVariableO  s    c         C   s7   |  j  d  |  j  d t j  |  j  d t j  d S(   s9   
        Test C{foo if bar else baz} statements.
        s   a = 'moo' if True else 'oink's   a = foo if True else 'oink's   a = 'moo' if True else barN(   R   R   R    (   R	   (    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pyt
   test_ifexpY  s    c         C   s   |  j  d  d S(   s   
        No warnings are emitted for using inside or after a nameless C{with}
        statement a name defined beforehand.
        s   
        from __future__ import with_statement
        bar = None
        with open("foo"):
            bar
        bar
        N(   R   (   R	   (    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pyt   test_withStatementNoNamesa  s    c         C   s   |  j  d  d S(   s   
        No warnings are emitted for using a name defined by a C{with} statement
        within the suite or afterwards.
        st   
        from __future__ import with_statement
        with open('foo') as bar:
            bar
        bar
        N(   R   (   R	   (    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pyt   test_withStatementSingleNamen  s    c         C   s   |  j  d  d S(   sn   
        No warnings are emitted for using an attribute as the target of a
        C{with} statement.
        s   
        from __future__ import with_statement
        import foo
        with open('foo') as foo.bar:
            pass
        N(   R   (   R	   (    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pyt   test_withStatementAttributeNamez  s    c         C   s   |  j  d  d S(   sm   
        No warnings are emitted for using a subscript as the target of a
        C{with} statement.
        s   
        from __future__ import with_statement
        import foo
        with open('foo') as foo[0]:
            pass
        N(   R   (   R	   (    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pyt   test_withStatementSubscript  s    c         C   s   |  j  d t j  d S(   s   
        An undefined name warning is emitted if the subscript used as the
        target of a C{with} statement is not defined.
        s   
        from __future__ import with_statement
        import foo
        with open('foo') as foo[bar]:
            pass
        N(   R   R   R    (   R	   (    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pyt$   test_withStatementSubscriptUndefined  s    c         C   s   |  j  d  d S(   s   
        No warnings are emitted for using any of the tuple of names defined by
        a C{with} statement within the suite or afterwards.
        s   
        from __future__ import with_statement
        with open('foo') as (bar, baz):
            bar, baz
        bar, baz
        N(   R   (   R	   (    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pyt   test_withStatementTupleNames  s    c         C   s   |  j  d  d S(   s   
        No warnings are emitted for using any of the list of names defined by a
        C{with} statement within the suite or afterwards.
        s   
        from __future__ import with_statement
        with open('foo') as [bar, baz]:
            bar, baz
        bar, baz
        N(   R   (   R	   (    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pyt   test_withStatementListNames  s    c         C   s   |  j  d  d S(   sq  
        If the target of a C{with} statement uses any or all of the valid forms
        for that part of the grammar (See
        U{http://docs.python.org/reference/compound_stmts.html#the-with-statement}),
        the names involved are checked both for definedness and any bindings
        created are respected in the suite of the statement and afterwards.
        s   
        from __future__ import with_statement
        c = d = e = g = h = i = None
        with open('foo') as [(a, b), c[d], e.f, g[h:i]]:
            a, b, c, d, e, g, h, i
        a, b, c, d, e, g, h, i
        N(   R   (   R	   (    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pyt#   test_withStatementComplicatedTarget  s    c         C   s   |  j  d t j  d S(   s   
        An undefined name warning is emitted if the name first defined by a
        C{with} statement is used before the C{with} statement.
        su   
        from __future__ import with_statement
        bar
        with open('foo') as bar:
            pass
        N(   R   R   R    (   R	   (    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pyt%   test_withStatementSingleNameUndefined  s    c         C   s   |  j  d t j  d S(   s   
        An undefined name warning is emitted if a name first defined by the
        tuple-unpacking form of the C{with} statement is used before the
        C{with} statement.
        s|   
        from __future__ import with_statement
        baz
        with open('foo') as (bar, baz):
            pass
        N(   R   R   R    (   R	   (    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pyt%   test_withStatementTupleNamesUndefined  s    c         C   s   |  j  d t j  d S(   s   
        A redefined name warning is emitted if a name bound by an import is
        rebound by the name defined by a C{with} statement.
        s|   
        from __future__ import with_statement
        import bar
        with open('foo') as bar:
            pass
        N(   R   R   R   (   R	   (    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pyt%   test_withStatementSingleNameRedefined  s    c         C   s   |  j  d t j  d S(   s   
        A redefined name warning is emitted if a name bound by an import is
        rebound by one of the names defined by the tuple-unpacking form of a
        C{with} statement.
        s   
        from __future__ import with_statement
        import bar
        with open('foo') as (bar, baz):
            pass
        N(   R   R   R   (   R	   (    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pyt%   test_withStatementTupleNamesRedefined  s    c         C   s   |  j  d t j  d S(   s   
        An undefined name warning is emitted if a name is used inside the
        body of a C{with} statement without first being bound.
        sh   
        from __future__ import with_statement
        with open('foo') as bar:
            baz
        N(   R   R   R    (   R	   (    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pyt!   test_withStatementUndefinedInside  s    c         C   s   |  j  d  d S(   s|   
        A name defined in the body of a C{with} statement can be used after
        the body ends without warning.
        sy   
        from __future__ import with_statement
        with open('foo') as bar:
            baz = 10
        baz
        N(   R   (   R	   (    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pyt#   test_withStatementNameDefinedInBody  s    c         C   s*   |  j  d t j  |  j  d t j  d S(   s   
        An undefined name warning is emitted if a name in the I{test}
        expression of a C{with} statement is undefined.
        sa   
        from __future__ import with_statement
        with bar as baz:
            pass
        sa   
        from __future__ import with_statement
        with bar as bar:
            pass
        N(   R   R   R    (   R	   (    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pyt'   test_withStatementUndefinedInExpression  s    i   i   s   Python >= 2.7 onlyc         C   s   |  j  d  d S(   s;   
        Dict comprehensions are properly handled.
        s/   
        a = {1: x for x in range(10)}
        N(   R   (   R	   (    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pyt   test_dictComprehension   s    c         C   s   |  j  d  d S(   s:   
        Set comprehensions are properly handled.
        sB   
        a = {1, 2, 3}
        b = {x for x in range(10)}
        N(   R   (   R	   (    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pyt   test_setComprehensionAndLiteral)  s    c         C   s>   t  d k  r d n d } |  j d |  |  j d |  d  S(   Ni   i   s   , s    as s:   
        try: pass
        except Exception%se: e
        sa   
        def download_review():
            try: pass
            except Exception%se: e
        (   i   i   (   R    R   (   R	   t   as_exc(    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pyt   test_exceptionUsedInExcept3  s
    c         C   s   |  j  d  d S(   s   
        Don't issue false warning when an unnamed exception is used.
        Previously, there would be a false warning, but only when the
        try..except was in a function
        sw   
        import tokenize
        def foo():
            try: pass
            except tokenize.TokenError: pass
        N(   R   (   R	   (    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pyt    test_exceptWithoutNameInFunction@  s    c         C   s   |  j  d  d S(   s   
        Don't issue false warning when an unnamed exception is used.
        This example catches a tuple of exception types.
        s   
        import tokenize
        def foo():
            try: pass
            except (tokenize.TokenError, IndentationError): pass
        N(   R   (   R	   (    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pyt%   test_exceptWithoutNameInFunctionTupleM  s    c         C   s   |  j  d  d S(   st   
        Consider a function that is called on the right part of an
        augassign operation to be used.
        sJ   
        from foo import bar
        baz = 0
        baz += bar()
        N(   R   (   R	   (    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pyt,   test_augmentedAssignmentImportedFunctionCallY  s    c         C   s   |  j  d  d S(   s,   An assert without a message is not an error.s(   
        a = 1
        assert a
        N(   R   (   R	   (    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pyt   test_assert_without_messaged  s    c         C   s   |  j  d  d S(   s)   An assert with a message is not an error.s-   
        a = 1
        assert a, 'x'
        N(   R   (   R	   (    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pyt   test_assert_with_messagek  s    c         C   s   |  j  d t j t j  d S(   s.   An assert of a non-empty tuple is always True.s>   
        assert (False, 'x')
        assert (False, )
        N(   R   R   t   AssertTuple(   R	   (    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pyt   test_assert_tupler  s    c         C   s   |  j  d  d S(   s,   An assert of an empty tuple is always False.s   
        assert ()
        N(   R   (   R	   (    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pyt   test_assert_tuple_emptyy  s    c         C   s   |  j  d  d S(   s,   An assert of a static value is not an error.s.   
        assert True
        assert 1
        N(   R   (   R	   (    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pyt   test_assert_static  s    s   new in Python 3.3c         C   s   |  j  d t j  d S(   s.   
        Test C{yield from} statement
        s9   
        def bar():
            yield from foo()
        N(   R   R   R    (   R	   (    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pyt   test_yieldFromUndefined  s    i   s   new in Python 3.6c         C   s   |  j  d  d S(   s.   Test PEP 498 f-strings are treated as a usage.sI   
        baz = 0
        print(f'{4*baz\N{RIGHT CURLY BRACKET}')
        N(   R   (   R	   (    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pyt   test_f_string  s    (   i   (   i   i   (   i   i   (   i   i   (   i   i   (4   RQ   RR   t   __doc__RT   RU   RV   R   RW   RX   RY   R   R    RZ   R[   R\   R]   R^   R_   R`   Ra   Rb   Rc   Rd   Re   Rf   Rg   Rh   Ri   Rj   Rk   Rl   Rm   Rn   Ro   Rp   Rq   Rr   Rs   Rt   Ru   Rv   Rx   Ry   Rz   R{   R|   R}   R   R   R   R   R   (    (    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pyRS   {  s^   	
	
					
	
	
						
																	
									
t   TestAsyncStatementsc           B   sp  e  Z e e d k  d  d    Z e e d k  d  d    Z e e d k  d  d    Z e e d k  d  d    Z e e d k  d  d    Z e e d k  d  d    Z	 e e d k  d  d	    Z
 e e d k  d  d
    Z e e d k  d  d    Z e e d k  d  d    Z e e d k  d  d    Z e e d k  d  d    Z RS(   i   i   s   new in Python 3.5c         C   s   |  j  d  d  S(   Ns8   
        async def bar():
            return 42
        (   R   (   R	   (    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pyt   test_asyncDef  s    c         C   s   |  j  d  d  S(   NsS   
        async def read_data(db):
            await db.fetch('SELECT ...')
        (   R   (   R	   (    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pyt   test_asyncDefAwait  s    c         C   s   |  j  d t j  d  S(   Ns;   
        async def bar():
            return foo()
        (   R   R   R    (   R	   (    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pyt   test_asyncDefUndefined  s    c         C   s   |  j  d  d  S(   Ns   
        async def read_data(db):
            output = []
            async for row in db.cursor():
                output.append(row)
            return output
        (   R   (   R	   (    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pyt   test_asyncFor  s    c         C   s   |  j  d  |  j  d  d  S(   Ns   
        async def read_data(db):
            output = []
            async for row in db.cursor():
                if row[0] == 'skip':
                    continue
                output.append(row)
            return output
        s   
        async def read_data(db):
            output = []
            async for row in db.cursor():
                if row[0] == 'stop':
                    break
                output.append(row)
            return output
        (   R   (   R	   (    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pyt   test_loopControlInAsyncFor  s    c         C   s*   |  j  d t j  |  j  d t j  d  S(   Ns   
        async def read_data(db):
            output = []
            async for row in db.cursor():
                output.append(row)
            else:
                continue
            return output
        s   
        async def read_data(db):
            output = []
            async for row in db.cursor():
                output.append(row)
            else:
                break
            return output
        (   R   R   R/   R4   (   R	   (    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pyt   test_loopControlInAsyncForElse  s    c         C   s   |  j  d t j  d  S(   Ns   
        async def read_data(db):
            output = []
            async for row in db.cursor():
                try:
                    output.append(row)
                finally:
                    continue
            return output
        (   R   R   R2   (   R	   (    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pyt   test_continueInAsyncForFinally  s    	c         C   s   |  j  d  d  S(   Ns   
        async def commit(session, data):
            async with session.transaction():
                await session.update(data)
        (   R   (   R	   (    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pyt   test_asyncWith  s    c         C   s   |  j  d  d  S(   Ns   
        async def commit(session, data):
            async with session.transaction() as trans:
                await trans.begin()
                ...
                await trans.end()
        (   R   (   R	   (    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pyt   test_asyncWithItem  s    c         C   s   |  j  d  d  S(   Ns9   
        def foo(a, b):
            return a @ b
        (   R   (   R	   (    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pyt   test_matmul  s    i   s   new in Python 3.6c         C   s   |  j  d  d  S(   NsE   
        hi = 'hi'
        mom = 'mom'
        f'{hi} {mom}'
        (   R   (   R	   (    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pyt   test_formatstring  s    c         C   s   |  j  d  |  j  d  |  j  d  |  j  d  |  j  d  |  j  d t j t j t j  |  j  d t j  |  j  d t j  |  j  d	 t j  |  j  d
 t j  |  j  d t j  |  j  d t j  |  j  d t j  d  S(   Ns,   
        name: str
        age: int
        s9   
        name: str = 'Bob'
        age: int = 18
        sE   
        class C:
            name: str
            age: int
        sR   
        class C:
            name: str = 'Bob'
            age: int = 18
        sE   
        def f():
            name: str
            age: int
        sz   
        def f():
            name: str = 'Bob'
            age: int = 18
            foo: not_a_real_type = None
        sH   
        def f():
            name: str
            print(name)
        s&   
        foo: not_a_real_type
        s-   
        foo: not_a_real_type = None
        s;   
        class C:
            foo: not_a_real_type
        sB   
        class C:
            foo: not_a_real_type = None
        sT   
        def f():
            class C:
                foo: not_a_real_type
        s[   
        def f():
            class C:
                foo: not_a_real_type = None
        (   R   R   R   R    (   R	   (    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pyt   test_variable_annotations  s4    (   i   i   (   i   i   (   i   i   (   i   i   (   i   i   (   i   i   (   i   i   (   i   i   (   i   i   (   i   i   (   i   i   (   i   i   (   RQ   RR   R   R    R   R   R   R   R   R   R   R   R   R   R   R   (    (    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pyR     s   

N(   R   t   sysR    t   pyflakesR   R   t   pyflakes.test.harnessR   R   R   R   RS   R   (    (    (    s:   /tmp/pip-build-EndXZ2/pyflakes/pyflakes/test/test_other.pyt   <module>   s       t   