Fix throttle applied to methods

This commit is contained in:
Paulus Schoutsen 2015-10-11 10:42:42 -07:00
parent c2117b3eaf
commit dcfc91e71c
2 changed files with 29 additions and 4 deletions

View file

@ -229,3 +229,16 @@ class TestUtil(unittest.TestCase):
self.assertTrue(Tester().hello())
self.assertTrue(Tester().hello())
def test_throttle_on_method(self):
""" Test that throttle works when wrapping a method. """
class Tester(object):
def hello(self):
return True
tester = Tester()
throttled = util.Throttle(timedelta(seconds=1))(tester.hello)
self.assertTrue(throttled())
self.assertIsNone(throttled())