社区所有版块导航
Python
python开源   Django   Python   DjangoApp   pycharm  
DATA
docker   Elasticsearch  
aigc
aigc   chatgpt  
WEB开发
linux   MongoDB   Redis   DATABASE   NGINX   其他Web框架   web工具   zookeeper   tornado   NoSql   Bootstrap   js   peewee   Git   bottle   IE   MQ   Jquery  
机器学习
机器学习算法  
Python88.com
反馈   公告   社区推广  
产品
短视频  
印度
印度  
Py学习  »  tornado

pytest tornado:“simpleAsynchHttpClient”不可iterable

sungyong • 6 年前 • 1883 次点击  

尝试在pytest,tornado下为长轮询生成测试代码。

我的测试代码在下面。

混杂的事物

from tornado.httpclient import  AsyncHTTPClient


@pytest.fixture
async def tornado_server():
    print("\ntornado_server()")

@pytest.fixture
async def http_client(tornado_server):
    client = AsyncHTTPClient()
    return client


@pytest.yield_fixture(scope='session')
def event_loop(request):
    loop = asyncio.get_event_loop_policy().new_event_loop()
    yield loop
    loop.close()

TestMy.Py

from tornado.httpclient import HTTPRequest, HTTPError
def test_http_client(event_loop):
    url = 'http://httpbin.org/get'
    resp = event_loop.run_until_complete(http_client(url))
    assert b'HTTP/1.1 200 OK' in resp

我希望这个结果能成功。 但失败了。

def test_http_client(event_loop):
    url = 'http://httpbin.org/get'
    resp = event_loop.run_until_complete(http_client(url))
   assert b'HTTP/1.1 200 OK' in resp E       TypeError: argument of type 'SimpleAsyncHTTPClient' is not iterable

我做错了什么?

Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/31576
 
1883 次点击  
文章 [ 2 ]  |  最新文章 6 年前