def test_not(): sel1 = mock.Mock(spec=MockEventSelection) sel1.name ='sel1' obj = NotwCount(sel1) event = mock.Mock() obj.begin(event) sel1.return_value = True assert not obj(event) sel1.return_value = False assert obj(event) sel1.return_value = False assert obj(event) obj.end() count = obj.results() assert [ [1, 'MockEventSelection', 'sel1', 1, 3], ] == count._results
def test_not(): sel1 = mock.Mock(spec=MockEventSelection) sel1.name = 'sel1' obj = NotwCount(sel1) event = mock.Mock() obj.begin(event) sel1.return_value = True assert not obj(event) sel1.return_value = False assert obj(event) sel1.return_value = False assert obj(event) obj.end() count = obj.results() assert [ [1, 'MockEventSelection', 'sel1', 1, 3], ] == count._results
def test_standard(self): sel1 = MockEventSelection(name='sel1') obj = NotwCount(selection=sel1) self.assertFalse(sel1.is_begin_called) self.assertFalse(sel1.is_end_called) event = MockEvent() obj.begin(event) self.assertTrue(sel1.is_begin_called) event = MockEvent() sel1.ret = False # 1/1 self.assertTrue(obj(event)) event = MockEvent() sel1.ret = True # 1/2 self.assertFalse(obj.event(event)) obj.end() self.assertTrue(sel1.is_end_called) count = obj.results() self.assertEqual([ [1, 'MockEventSelection', 'sel1', 1, 2], ], count._results)