def test_about_pack_settings_signal(self): handler = ContextHandler() handler.bind(SimpleWidget) widget = SimpleWidget() handler.initialize(widget) fn = Mock() widget.settingsAboutToBePacked.connect(fn) handler.pack_data(widget) self.assertEqual(1, fn.call_count) handler.update_defaults(widget) self.assertEqual(2, fn.call_count)
def test_write_defaults_stores_version(self): handler = ContextHandler() handler.bind(SimpleWidget) widget = SimpleWidget() widget.current_context = None widget.context_settings = [DummyContext() for _ in range(3)] handler.update_defaults(widget) f = BytesIO() f.close = lambda: None with patch("builtins.open", Mock(return_value=f)): handler.write_defaults() f.seek(0) pickle.load(f) # settings contexts = pickle.load(f) for c in contexts: self.assertEqual(c.values.get("__version__", 0xBAD), 1)