def test_escapes_escaped_colon(self):
        '''
        Regression test for issue #836
        '''
        predicate_1 = predicates.SimplePredicate(
            predicates.commonSetElementPredicate, 'col_1')
        predicate_2 = predicates.SimplePredicate(
            predicates.commonSetElementPredicate, 'col_2')
        record = {'col_1': ['foo\\:', 'foo'], 'col_2': ['\\:bar', 'bar']}

        block_val = predicates.CompoundPredicate([predicate_1,
                                                  predicate_2])(record)
        assert len(set(block_val)) == 4
        assert block_val == [
            'foo\\\\::\\\\:bar', 'foo\\\\::bar', 'foo:\\\\:bar', 'foo:bar'
        ]
Beispiel #2
0
    def __init__(self, definition) :
        self.field = definition['field']

        if 'variable name' in definition :
            self.name = definition['variable name'] 
        else :
            self.name = "(%s: %s)" % (self.field, self.type)

        self.predicates = [predicates.SimplePredicate(pred, self.field) 
                           for pred in self._predicate_functions]

        super(FieldType, self).__init__(definition)
Beispiel #3
0
 def test_set(self):
     s1 = predicates.SimplePredicate(predicates.wholeSetPredicate, 'foo')
     colors = set(['red', 'blue', 'green'])
     assert s1({'foo': colors}) == (str(colors), )