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
|
2018-03-04 08:09:18 +08:00
|
|
|
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):
|
2016-06-26 02:30:31 +08:00
|
|
|
print(item)
|
2015-12-05 05:11:53 +08:00
|
|
|
|
|
|
|
def test_rate_limited_printing(self):
|
2016-06-26 02:30:31 +08:00
|
|
|
print("\nRunning rate-limited print test:")
|
2017-07-20 06:38:55 +08:00
|
|
|
for item in range(1, 11):
|
2015-12-05 05:11:53 +08:00
|
|
|
self.print_item(item)
|