def test_factory_type_mismatch(self): context = ExecutionContext() factory = jp.StandardBinaryPredicateFactory( '==', lambda a, b: True, operand_type=basestring) self.assertRaises(TypeError, factory, ['not a string']) pred = factory(lambda x: ['not a string']) self.assertRaises(TypeError, pred, context, 'ok')
def test_factory_type_ok(self): context = ExecutionContext() factory = jp.StandardBinaryPredicateFactory( '==', lambda a, b: True, operand_type=basestring) pred = factory('is a string') self.assertTrue(pred(context, 'ok')) pred = factory(lambda x: 'is a string') self.assertTrue(pred(context, 'ok'))
def test_factory_type_mismatch(self): factory = jp.StandardBinaryPredicateFactory('==', lambda a, b: True, operand_type=basestring) try: self.assertFalse(factory(['not a string']), "Expected type error") except TypeError: pass pred = factory('is a string') self.assertTrue(pred('ok'))