Skip to contentSkip to conversation

tests/color: Fix event register to pass the datastore

PATCH New Richard Purdie 1 participant 1 message Mar 12, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tests/color: Fix event register to pass the datastore

Adding the "if d is None" to the event handling code meant some of these tests stopped working. The reason is that len(d) was zero but not equal to None.

Passing the data object to the register() function in the test correctly registers the event handler and avoids the problem, it just happened to work previously, incorrectly.

---
 lib/bb/tests/color.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/bb/tests/color.py +1 -1
index bf03750c69..88dd278006 100644
@@ -31,7 +31,7 @@ class ColorCodeTests(unittest.TestCase):
     def setUp(self):
         self.d = bb.data.init()
         self._progress_watcher = ProgressWatcher()
-        bb.event.register("bb.build.TaskProgress", self._progress_watcher.handle_event)
+        bb.event.register("bb.build.TaskProgress", self._progress_watcher.handle_event, data=self.d)
 
     def tearDown(self):
         bb.event.remove("bb.build.TaskProgress", None)
Signature · 1 line
2.27.0