MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_translate_wildcards

Method test_translate_wildcards

Lib/test/test_fnmatch.py:250–276  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

248 self.assertFalse(re.match(fatre, 'dabccbad'))
249
250 def test_translate_wildcards(self):
251 for pattern, expect in [
252 ('ab*', r'(?s:ab.*)\z'),
253 ('ab*cd', r'(?s:ab.*cd)\z'),
254 ('ab*cd*', r'(?s:ab(?>.*?cd).*)\z'),
255 ('ab*cd*12', r'(?s:ab(?>.*?cd).*12)\z'),
256 ('ab*cd*12*', r'(?s:ab(?>.*?cd)(?>.*?12).*)\z'),
257 ('ab*cd*12*34', r'(?s:ab(?>.*?cd)(?>.*?12).*34)\z'),
258 ('ab*cd*12*34*', r'(?s:ab(?>.*?cd)(?>.*?12)(?>.*?34).*)\z'),
259 ]:
260 with self.subTest(pattern):
261 translated = translate(pattern)
262 self.assertEqual(translated, expect, pattern)
263
264 for pattern, expect in [
265 ('*ab', r'(?s:.*ab)\z'),
266 ('*ab*', r'(?s:(?>.*?ab).*)\z'),
267 ('*ab*cd', r'(?s:(?>.*?ab).*cd)\z'),
268 ('*ab*cd*', r'(?s:(?>.*?ab)(?>.*?cd).*)\z'),
269 ('*ab*cd*12', r'(?s:(?>.*?ab)(?>.*?cd).*12)\z'),
270 ('*ab*cd*12*', r'(?s:(?>.*?ab)(?>.*?cd)(?>.*?12).*)\z'),
271 ('*ab*cd*12*34', r'(?s:(?>.*?ab)(?>.*?cd)(?>.*?12).*34)\z'),
272 ('*ab*cd*12*34*', r'(?s:(?>.*?ab)(?>.*?cd)(?>.*?12)(?>.*?34).*)\z'),
273 ]:
274 with self.subTest(pattern):
275 translated = translate(pattern)
276 self.assertEqual(translated, expect, pattern)
277
278 def test_translate_expressions(self):
279 for pattern, expect in [

Callers

nothing calls this directly

Calls 3

translateFunction · 0.90
subTestMethod · 0.80
assertEqualMethod · 0.45

Tested by

no test coverage detected