| 157 | |
| 158 | |
| 159 | def test_regex(): |
| 160 | query = Query().val.matches(r'\d{2}\.') |
| 161 | |
| 162 | assert query({'val': '42.'}) |
| 163 | assert not query({'val': '44'}) |
| 164 | assert not query({'val': 'ab.'}) |
| 165 | assert not query({'val': 155}) |
| 166 | assert not query({'val': False}) |
| 167 | assert not query({'': None}) |
| 168 | assert hash(query) |
| 169 | |
| 170 | query = Query().val.search(r'\d+') |
| 171 | |
| 172 | assert query({'val': 'ab3'}) |
| 173 | assert not query({'val': 'abc'}) |
| 174 | assert not query({'val': ''}) |
| 175 | assert not query({'val': True}) |
| 176 | assert not query({'': None}) |
| 177 | assert hash(query) |
| 178 | |
| 179 | query = Query().val.search(r'JOHN', flags=re.IGNORECASE) |
| 180 | assert query({'val': 'john'}) |
| 181 | assert query({'val': 'xJohNx'}) |
| 182 | assert not query({'val': 'JOH'}) |
| 183 | assert not query({'val': 12}) |
| 184 | assert not query({'': None}) |
| 185 | assert hash(query) |
| 186 | |
| 187 | |
| 188 | def test_custom(): |