コード例 #1
0
 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)
コード例 #2
0
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
コード例 #3
0
 def setUpClass(cls):
     cls.s = Subject()
     cls.dec_obs = DecimalViewer()
     cls.hex_obs = HexViewer()