4
0
Эх сурвалжийг харах

Fix teardown error due to a library update.

After updating some pytest related libraries to test another component,
I started to get teardown errors due to a Thread left running.
Since device.py contains a one second debounce Timer on network operations,
with a faked immediate set of the property, when we test this, we need to
wait for the Timer to expire to avoid the teardown error.
Jason Rumney 4 жил өмнө
parent
commit
95d620733e
1 өөрчлөгдсөн 2 нэмэгдсэн , 0 устгасан
  1. 2 0
      tests/test_device.py

+ 2 - 0
tests/test_device.py

@@ -322,6 +322,8 @@ class TestDevice(IsolatedAsyncioTestCase):
         self.subject.set_property("1", False)
         self.subject._cached_state = {"1": True}
         self.assertEqual(self.subject.get_property("1"), False)
+        # wait for the debounce timer to avoid a teardown error
+        sleep(1)
 
     def test_debounces_multiple_set_calls_into_one_api_call(self):
         with patch("custom_components.tuya_local.device.Timer") as mock: