- Notifications
You must be signed in to change notification settings - Fork 1.3k
/
Copy pathrate_limiting_test.py
21 lines (18 loc) · 842 Bytes
/
rate_limiting_test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
"""This test demonstrates the use of the "rate_limited" decorator.
You can use this decorator on any method to rate-limit it."""
fromseleniumbaseimportBaseCase
fromseleniumbaseimportdecorators
classRateLimitingTests(BaseCase):
@decorators.rate_limited(4.2) # The arg is max calls per second
defprint_item(self, item):
print(item)
deftest_rate_limited_printing(self):
ifself._multithreadedorself.recorder_mode:
self.open_if_not_url("about:blank")
print("\n Unsupported mode for this test.")
self.skip("Unsupported mode for this test.")
message="Running rate-limited print() on the command line"
self.open("data:text/html,<p>%s</p>"%message)
print("\n%s:"%message)
foriteminrange(1, 11):
self.print_item(item)