def setUpClass(cls): cls.dec_obs = DecimalViewer() cls.hex_obs = HexViewer() cls.sub = Data('Data') # inherited behavior already tested with TestSubject cls.sub.attach(cls.dec_obs) cls.sub.attach(cls.hex_obs)
def test_one_data_change_notifies_each_observer_once(observable): observable.attach(DecimalViewer()) observable.attach(HexViewer()) with patch('patterns.behavioral.observer.DecimalViewer.update', new_callable=Mock()) as mocked_update: assert mocked_update.call_count == 0 observable.data = 10 assert mocked_update.call_count == 1
def setUpClass(cls): cls.s = Subject() cls.dec_obs = DecimalViewer() cls.hex_obs = HexViewer()