def test_bool_delegate(): """Test boolean delegate.""" from Python.Test import BoolDelegate def always_so_negative(): return False d = BoolDelegate(always_so_negative) ob = DelegateTest() ob.CallBoolDelegate(d) assert not d() assert not ob.CallBoolDelegate(d) def always_so_positive(): return 1 bad = BoolDelegate(always_so_positive) with pytest.raises(TypeError): ob.CallBoolDelegate(bad)
def testBoolDelegate(self): """Test boolean delegate.""" def always_so_negative(): return 0 d = BoolDelegate(always_so_negative) ob = DelegateTest() ob.CallBoolDelegate(d) self.assertTrue(not d()) self.assertTrue(not ob.CallBoolDelegate(d))
def test_bool_delegate(): """Test boolean delegate.""" from Python.Test import BoolDelegate def always_so_negative(): return 0 d = BoolDelegate(always_so_negative) ob = DelegateTest() ob.CallBoolDelegate(d) assert not d() assert not ob.CallBoolDelegate(d)