本文整理汇总了Python中locust.stats.RequestStats.get方法的典型用法代码示例。如果您正苦于以下问题:Python RequestStats.get方法的具体用法?Python RequestStats.get怎么用?Python RequestStats.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类locust.stats.RequestStats
的用法示例。
在下文中一共展示了RequestStats.get方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_request_stats_content_length
# 需要导入模块: from locust.stats import RequestStats [as 别名]
# 或者: from locust.stats.RequestStats import get [as 别名]
def test_request_stats_content_length(self):
class MyLocust(Locust):
host = "http://127.0.0.1:%i" % self.port
locust = MyLocust()
locust.client.get("/ultra_fast")
self.assertEqual(RequestStats.get("GET", "/ultra_fast").avg_content_length, len("This is an ultra fast response"))
locust.client.get("/ultra_fast")
self.assertEqual(RequestStats.get("GET", "/ultra_fast").avg_content_length, len("This is an ultra fast response"))
示例2: test_request_connection_error
# 需要导入模块: from locust.stats import RequestStats [as 别名]
# 或者: from locust.stats.RequestStats import get [as 别名]
def test_request_connection_error(self):
class MyLocust(Locust):
host = "http://localhost:1"
locust = MyLocust()
response = locust.client.get("/", timeout=0.1)
self.assertFalse(response)
self.assertEqual(1, RequestStats.get("GET", "/").num_failures)
self.assertEqual(0, RequestStats.get("GET", "/").num_reqs)
示例3: test_request_stats_query_variables
# 需要导入模块: from locust.stats import RequestStats [as 别名]
# 或者: from locust.stats.RequestStats import get [as 别名]
def test_request_stats_query_variables(self):
class MyLocust(Locust):
host = "http://127.0.0.1:%i" % self.port
locust = MyLocust()
locust.client.get("/ultra_fast?query=1")
self.assertEqual(1, RequestStats.get("GET", "/ultra_fast?query=1").num_reqs)
示例4: test_request_stats_named_endpoint
# 需要导入模块: from locust.stats import RequestStats [as 别名]
# 或者: from locust.stats.RequestStats import get [as 别名]
def test_request_stats_named_endpoint(self):
class MyLocust(Locust):
host = "http://127.0.0.1:%i" % self.port
locust = MyLocust()
locust.client.get("/ultra_fast", name="my_custom_name")
self.assertEqual(1, RequestStats.get("GET", "my_custom_name").num_reqs)
示例5: test_request_stats_no_content_length_no_prefetch
# 需要导入模块: from locust.stats import RequestStats [as 别名]
# 或者: from locust.stats.RequestStats import get [as 别名]
def test_request_stats_no_content_length_no_prefetch(self):
class MyLocust(Locust):
host = "http://127.0.0.1:%i" % self.port
l = MyLocust()
path = "/no_content_length"
r = l.client.get(path, prefetch=False)
self.assertEqual(0, RequestStats.get("GET", path).avg_content_length)
示例6: test_request_stats_no_content_length
# 需要导入模块: from locust.stats import RequestStats [as 别名]
# 或者: from locust.stats.RequestStats import get [as 别名]
def test_request_stats_no_content_length(self):
class MyLocust(Locust):
host = "http://127.0.0.1:%i" % self.port
l = MyLocust()
path = "/no_content_length"
r = l.client.get(path)
self.assertEqual(RequestStats.get("GET", path).avg_content_length, len("This response does not have content-length in the header"))
示例7: test_log_request_name_argument
# 需要导入模块: from locust.stats import RequestStats [as 别名]
# 或者: from locust.stats.RequestStats import get [as 别名]
def test_log_request_name_argument(self):
from locust.stats import RequestStats
self.response = ""
class MyLocust(Locust):
tasks = []
host = "http://127.0.0.1:%i" % self.port
@task()
def t1(l):
self.response = l.client.get("/ultra_fast", name="new name!")
my_locust = MyLocust()
my_locust.t1()
self.assertEqual(1, RequestStats.get("GET", "new name!").num_reqs)
self.assertEqual(0, RequestStats.get("GET", "/ultra_fast").num_reqs)
示例8: test_slave_stats_report_median
# 需要导入模块: from locust.stats import RequestStats [as 别名]
# 或者: from locust.stats.RequestStats import get [as 别名]
def test_slave_stats_report_median(self):
import mock
class MyTestLocust(Locust):
pass
with mock.patch("locust.rpc.rpc.Server", mocked_rpc_server()) as server:
master = MasterLocustRunner(MyTestLocust, 10, 10, None)
server.mocked_send(Message("client_ready", None, "fake_client"))
sleep(0)
RequestStats.get("GET", "/").log(100, 23455)
RequestStats.get("GET", "/").log(800, 23455)
RequestStats.get("GET", "/").log(700, 23455)
data = {"user_count":1}
events.report_to_master.fire("fake_client", data)
RequestStats.reset_all()
server.mocked_send(Message("stats", data, "fake_client"))
sleep(0)
s = RequestStats.get("GET", "/")
self.assertEqual(700, s.median_response_time)