示例#1
0
  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')
示例#2
0
  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'))
示例#3
0
    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'))