import functools
from tornado import gen
from tornado.httpclient import AsyncHTTPClient


@gen.coroutine
def fetch_coroutine(url):
    http_client = AsyncHTTPClient()
    response = yield http_client.fetch(url)
    raise gen.Return(response.code)


def test_explicit_start_and_stop(io_loop):
    f = fetch_coroutine('http://google.com')
    f.add_done_callback(lambda future: io_loop.stop())
    io_loop.start()
    assert f.result() == 200


def test_run_sync(io_loop):
    fetch = functools.partial(fetch_coroutine, 'http://google.com')
    response = io_loop.run_sync(fetch)
    assert response == 200

@@ -38,55 +38,8 @@
 gen%0A
-from tornado.httpclient import AsyncHTTPClient%0A
 %0A%0A@g
@@ -55,21 +55,21 @@
 ine%0Adef 
-fetch
+dummy
 _corouti
@@ -75,92 +75,57 @@
 ine(
-url):%0A    http_client = AsyncHTTPClient()%0A    response = yield http_client.fetch(url
+io_loop):%0A    yield gen.Task(io_loop.add_callback
 )%0A  
@@ -147,20 +147,11 @@
 urn(
-response.cod
+Tru
 e)%0A%0A
@@ -203,53 +203,51 @@
    f
- = fetch_coroutine('http://google.com'
+uture = dummy_coroutine(io_loop
 )%0A    f
+uture
 .add
@@ -268,22 +268,21 @@
 (lambda 
-future
+*args
 : io_loo
@@ -323,16 +323,21 @@
 assert f
+uture
 .result(
@@ -337,23 +337,16 @@
 result()
- == 200
 %0A%0A%0Adef t
@@ -372,21 +372,21 @@
 p):%0A    
-fetch
+dummy
  = funct
@@ -398,21 +398,21 @@
 partial(
-fetch
+dummy
 _corouti
@@ -419,41 +419,29 @@
 ne, 
-'http://google.com')%0A    response
+io_loop)%0A    finished
  = i
@@ -460,13 +460,13 @@
 ync(
-fetch
+dummy
 )%0A  
@@ -478,20 +478,13 @@
 ert 
-response == 200
+finished
 %0A

remove an http call from tests ;)