SeleniumBase/examples/rate_limiting_test.py

20 lines
509 B
Python
Raw Normal View History

2017-04-23 11:26:50 +08:00
"""
This test demonstrates the use of the "rate_limited" decorator.
You can use this decorator on any method to rate-limit it.
"""
import unittest
from seleniumbase import decorators
2015-12-05 05:11:53 +08:00
2017-04-23 11:26:50 +08:00
class MyTestClass(unittest.TestCase):
2015-12-05 05:11:53 +08:00
2016-02-03 00:56:59 +08:00
@decorators.rate_limited(3.5) # The arg is max calls per second
2015-12-05 05:11:53 +08:00
def print_item(self, item):
print(item)
2015-12-05 05:11:53 +08:00
def test_rate_limited_printing(self):
print("\nRunning rate-limited print test:")
for item in range(1, 11):
2015-12-05 05:11:53 +08:00
self.print_item(item)