from collections import OrderedDict

import pytest

from . import analyzer


fixtures = OrderedDict([
    ('empty', ('def a(): pass', False)),
    ('arg', ('def a(b): return b', False)),
    ('simple', ('def a(c): return c.Response()', True)),
    ('body', ('def a(c): return c.Response(body="abc")', True)),
    ('wrongattr', ('def a(d): return d.R()', False)),
    ('extracall', (
        '''
def a(b):
    d()
    return b.Response()

def d():
    pass
        ''', False)),
    ('expressions', (
        '''
def a(b):
    c = "Hey!"
    d = "Dude"
    return b.Response(json={c: d})
        ''', True))
])
params = fixtures.values()
ids = list(fixtures.keys())


@pytest.mark.parametrize('code,simple', params, ids=ids)
def test_analyzer(code, simple):
    module = compile(code, '?', 'exec')
    fun_code = module.co_consts[0]

    assert analyzer.is_simple(fun_code) == simple

@@ -70,16 +70,23 @@
 lyzer%0A%0A%0A
+simple_
 fixtures
@@ -614,17 +614,62 @@
 %0A%5D)%0A
-params = 
+%0A%0A@pytest.mark.parametrize(%0A    'code,simple', simple_
 fixt
@@ -685,20 +685,26 @@
 es()
-%0Aids = 
+, ids=
 list(
+simple_
 fixt
@@ -715,18 +715,418 @@
 .keys())
-%0A%0A
+)%0Adef test_is_simple(code, simple):%0A    module = compile(code, '?', 'exec')%0A    fun_code = module.co_consts%5B0%5D%0A%0A    assert analyzer.is_simple(fun_code) == simple%0A%0A%0Apointless_fixtures = OrderedDict(%5B%0A    ('empty', ('async def a(): pass', True)),%0A    ('simple', ('async def a(): return 1', True)),%0A    ('yieldfrom', ('def a(b): yield from b', False)),%0A    ('await', ('async def a(b): await b', False))%0A%5D)
 %0A@pytest
@@ -1147,70 +1147,138 @@
 ize(
+%0A    
 'code,
-simple', params, ids=ids)%0Adef test_analyzer(code, simple
+pointless', pointless_fixtures.values(),%0A    ids=list(pointless_fixtures.keys()))%0Adef test_is_pointless(code, pointless
 ):%0A 
@@ -1367,37 +1367,50 @@
 ert analyzer.is_
-simpl
+pointless_coroutin
 e(fun_code) == s
@@ -1396,27 +1396,30 @@
 outine(fun_code) == 
-simple
+pointless
 %0A

add a test for is_pointless_coroutine