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


Python HttpSession.get方法代码示例

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


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

示例1: test_slow_redirect

# 需要导入模块: from locust.clients import HttpSession [as 别名]
# 或者: from locust.clients.HttpSession import get [as 别名]
 def test_slow_redirect(self):
     s = HttpSession("http://127.0.0.1:%i" % self.port)
     url = "/redirect?url=/redirect?delay=0.5"
     r = s.get(url)
     stats = global_stats.get(url, method="GET")
     assert 1 == stats.num_requests
     assert stats.avg_response_time > 500
开发者ID:sanga,项目名称:locust,代码行数:9,代码来源:test_client.py

示例2: test_slow_redirect

# 需要导入模块: from locust.clients import HttpSession [as 别名]
# 或者: from locust.clients.HttpSession import get [as 别名]
 def test_slow_redirect(self):
     s = HttpSession("http://127.0.0.1:%i" % self.port)
     url = "/redirect?url=/redirect?delay=0.5"
     r = s.get(url)
     stats = global_stats.get(url, method="GET")
     self.assertEqual(1, stats.num_requests)
     self.assertGreater(stats.avg_response_time, 500)
开发者ID:Broadroad,项目名称:locust,代码行数:9,代码来源:test_client.py

示例3: test_streaming_response

# 需要导入模块: from locust.clients import HttpSession [as 别名]
# 或者: from locust.clients.HttpSession import get [as 别名]
 def test_streaming_response(self):
     """
     Test a request to an endpoint that returns a streaming response
     """
     s = HttpSession("http://127.0.0.1:%i" % self.port)
     r = s.get("/streaming/30")
     
     # verify that the time reported includes the download time of the whole streamed response
     self.assertGreater(global_stats.get("/streaming/30", method="GET").avg_response_time, 250)
     global_stats.clear_all()
     
     # verify that response time does NOT include whole download time, when using stream=True
     r = s.get("/streaming/30", stream=True)
     self.assertGreater(global_stats.get("/streaming/30", method="GET").avg_response_time, 0)
     self.assertLess(global_stats.get("/streaming/30", method="GET").avg_response_time, 250)
     
     # download the content of the streaming response (so we don't get an ugly exception in the log)
     _ = r.content
开发者ID:Broadroad,项目名称:locust,代码行数:20,代码来源:test_client.py

示例4: test_get

# 需要导入模块: from locust.clients import HttpSession [as 别名]
# 或者: from locust.clients.HttpSession import get [as 别名]
 def test_get(self):
     s = HttpSession("http://127.0.0.1:%i" % self.port)
     r = s.get("/ultra_fast")
     self.assertEqual(200, r.status_code)
开发者ID:Broadroad,项目名称:locust,代码行数:6,代码来源:test_client.py

示例5: test_connection_error

# 需要导入模块: from locust.clients import HttpSession [as 别名]
# 或者: from locust.clients.HttpSession import get [as 别名]
 def test_connection_error(self):
     s = HttpSession("http://localhost:1")
     r = s.get("/", timeout=0.1)
     self.assertEqual(r.status_code, 0)
     self.assertEqual(None, r.content)
     self.assertRaises(RequestException, r.raise_for_status)
开发者ID:Broadroad,项目名称:locust,代码行数:8,代码来源:test_client.py

示例6: test_connection_error

# 需要导入模块: from locust.clients import HttpSession [as 别名]
# 或者: from locust.clients.HttpSession import get [as 别名]
 def test_connection_error(self):
     s = HttpSession("http://localhost:1")
     r = s.get("/", timeout=0.1)
     assert r.status_code == 0
     assert None == r.content
     raises(RequestException, r.raise_for_status)
开发者ID:sanga,项目名称:locust,代码行数:8,代码来源:test_client.py

示例7: test_get

# 需要导入模块: from locust.clients import HttpSession [as 别名]
# 或者: from locust.clients.HttpSession import get [as 别名]
 def test_get(self):
     s = HttpSession("http://127.0.0.1:%i" % self.port)
     r = s.get("/ultra_fast")
     assert 200 == r.status_code
开发者ID:sanga,项目名称:locust,代码行数:6,代码来源:test_client.py

示例8: test_cookie

# 需要导入模块: from locust.clients import HttpSession [as 别名]
# 或者: from locust.clients.HttpSession import get [as 别名]
 def test_cookie(self):
     s = HttpSession("http://127.0.0.1:%i" % self.port)
     r = s.post("/set_cookie?name=testcookie&value=1337")
     self.assertEqual(200, r.status_code)
     r = s.get("/get_cookie?name=testcookie")
     self.assertEqual('1337', r.content.decode())
开发者ID:alexandrul,项目名称:locust,代码行数:8,代码来源:test_client.py


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