From e62754447980f89594f00fb0e07496679d16bb9a Mon Sep 17 00:00:00 2001 From: Andrea Campi Date: Thu, 14 Dec 2017 04:01:59 +0000 Subject: [PATCH] Always consume the no_throttle keyword argument. (#11126) The current code relies on the assumption that the first invocation will never specify no_throttle=True. However that puts us in a pickle when writing unit tests: if we had a fictitious: def setup_platform(): update() @Throttle(MIN_TIME_BETWEEN_SCANS) def update(): pass Then given multiple tests, the second and some of subsequent tests would be throttled (depending on timing). But we also can't change that code to call `update(no_throttle=True)' because that's not currently accepted. This diff shouldn't change the visibile behavior of any component, but allows this extra flexibility. --- homeassistant/util/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homeassistant/util/__init__.py b/homeassistant/util/__init__.py index 646edcf1c35..cb3ebeb7ee6 100644 --- a/homeassistant/util/__init__.py +++ b/homeassistant/util/__init__.py @@ -299,7 +299,7 @@ class Throttle(object): return None # Check if method is never called or no_throttle is given - force = not throttle[1] or kwargs.pop('no_throttle', False) + force = kwargs.pop('no_throttle', False) or not throttle[1] try: if force or utcnow() - throttle[1] > self.min_time: