MCPcopy
hub / github.com/msiemens/tinydb / test_regex

Function test_regex

tests/test_queries.py:159–185  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

157
158
159def 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
188def test_custom():

Callers

nothing calls this directly

Calls 3

QueryClass · 0.90
matchesMethod · 0.80
searchMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…