MCPcopy Create free account
hub / github.com/python/cpython / test_translate_expressions

Method test_translate_expressions

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

Source from the content-addressed store, hash-verified

276 self.assertEqual(translated, expect, pattern)
277
278 def test_translate_expressions(self):
279 for pattern, expect in [
280 ('[', r'(?s:\[)\z'),
281 ('[!', r'(?s:\[!)\z'),
282 ('[]', r'(?s:\[\])\z'),
283 ('[abc', r'(?s:\[abc)\z'),
284 ('[!abc', r'(?s:\[!abc)\z'),
285 ('[abc]', r'(?s:[abc])\z'),
286 ('[!abc]', r'(?s:[^abc])\z'),
287 ('[!abc][!def]', r'(?s:[^abc][^def])\z'),
288 # with [[
289 ('[[', r'(?s:\[\[)\z'),
290 ('[[a', r'(?s:\[\[a)\z'),
291 ('[[]', r'(?s:[\[])\z'),
292 ('[[]a', r'(?s:[\[]a)\z'),
293 ('[[]]', r'(?s:[\[]\])\z'),
294 ('[[]a]', r'(?s:[\[]a\])\z'),
295 ('[[a]', r'(?s:[\[a])\z'),
296 ('[[a]]', r'(?s:[\[a]\])\z'),
297 ('[[a]b', r'(?s:[\[a]b)\z'),
298 # backslashes
299 ('[\\', r'(?s:\[\\)\z'),
300 (r'[\]', r'(?s:[\\])\z'),
301 (r'[\\]', r'(?s:[\\\\])\z'),
302 ]:
303 with self.subTest(pattern):
304 translated = translate(pattern)
305 self.assertEqual(translated, expect, pattern)
306
307 def test_star_indices_locations(self):
308 from fnmatch import _translate

Callers

nothing calls this directly

Calls 3

translateFunction · 0.90
subTestMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected