本文整理汇总了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
示例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)
示例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
示例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)
示例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)
示例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)
示例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
示例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())