当前位置: 首页>>代码示例>>Python>>正文


Python ClientSession.options方法代码示例

本文整理汇总了Python中aiohttp.client.ClientSession.options方法的典型用法代码示例。如果您正苦于以下问题:Python ClientSession.options方法的具体用法?Python ClientSession.options怎么用?Python ClientSession.options使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在aiohttp.client.ClientSession的用法示例。


在下文中一共展示了ClientSession.options方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_http_methods

# 需要导入模块: from aiohttp.client import ClientSession [as 别名]
# 或者: from aiohttp.client.ClientSession import options [as 别名]
 def test_http_methods(self, patched):
     session = ClientSession(loop=self.loop)
     add_params = dict(
         headers={"Authorization": "Basic ..."},
         max_redirects=2,
         encoding="latin1",
         version=aiohttp.HttpVersion10,
         compress="deflate",
         chunked=True,
         expect100=True,
         read_until_eof=False)
     run = self.loop.run_until_complete
     # Check GET
     run(session.get(
         "http://test.example.com",
         params={"x": 1},
         **add_params))
     self.assertEqual(
         patched.call_count, 1, "`ClientSession.request` not called")
     self.assertEqual(
         list(patched.call_args),
         [("GET", "http://test.example.com",),
          dict(
             params={"x": 1},
             allow_redirects=True,
             **add_params)])
     # Check OPTIONS
     run(session.options(
         "http://opt.example.com",
         params={"x": 2},
         **add_params))
     self.assertEqual(
         patched.call_count, 2, "`ClientSession.request` not called")
     self.assertEqual(
         list(patched.call_args),
         [("OPTIONS", "http://opt.example.com",),
          dict(
             params={"x": 2},
             allow_redirects=True,
             **add_params)])
     # Check HEAD
     run(session.head(
         "http://head.example.com",
         params={"x": 2},
         **add_params))
     self.assertEqual(
         patched.call_count, 3, "`ClientSession.request` not called")
     self.assertEqual(
         list(patched.call_args),
         [("HEAD", "http://head.example.com",),
          dict(
             params={"x": 2},
             allow_redirects=False,
             **add_params)])
     # Check POST
     run(session.post(
         "http://post.example.com",
         params={"x": 2},
         data="Some_data",
         files={"x": '1'},
         **add_params))
     self.assertEqual(
         patched.call_count, 4, "`ClientSession.request` not called")
     self.assertEqual(
         list(patched.call_args),
         [("POST", "http://post.example.com",),
          dict(
             params={"x": 2},
             data="Some_data",
             files={"x": '1'},
             **add_params)])
     # Check PUT
     run(session.put(
         "http://put.example.com",
         params={"x": 2},
         data="Some_data",
         files={"x": '1'},
         **add_params))
     self.assertEqual(
         patched.call_count, 5, "`ClientSession.request` not called")
     self.assertEqual(
         list(patched.call_args),
         [("PUT", "http://put.example.com",),
          dict(
             params={"x": 2},
             data="Some_data",
             files={"x": '1'},
             **add_params)])
     # Check PATCH
     run(session.patch(
         "http://patch.example.com",
         params={"x": 2},
         data="Some_data",
         files={"x": '1'},
         **add_params))
     self.assertEqual(
         patched.call_count, 6, "`ClientSession.request` not called")
     self.assertEqual(
         list(patched.call_args),
         [("PATCH", "http://patch.example.com",),
#.........这里部分代码省略.........
开发者ID:ttezel,项目名称:aiohttp,代码行数:103,代码来源:test_client_session.py


注:本文中的aiohttp.client.ClientSession.options方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。