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

Method test_bug_34294

Lib/test/test_re.py:2374–2406  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

2372 self.assertEqual(m2.group(), b'')
2373
2374 def test_bug_34294(self):
2375 # Issue 34294: wrong capturing groups
2376
2377 # exists since Python 2
2378 s = "a\tx"
2379 p = r"\b(?=(\t)|(x))x"
2380 self.assertEqual(re.search(p, s).groups(), (None, 'x'))
2381
2382 # introduced in Python 3.7.0
2383 s = "ab"
2384 p = r"(?=(.)(.)?)"
2385 self.assertEqual(re.findall(p, s),
2386 [('a', 'b'), ('b', '')])
2387 self.assertEqual([m.groups() for m in re.finditer(p, s)],
2388 [('a', 'b'), ('b', None)])
2389
2390 # test-cases provided by issue34294, introduced in Python 3.7.0
2391 p = r"(?=<(?P<tag>\w+)/?>(?:(?P<text>.+?)</(?P=tag)>)?)"
2392 s = "<test><foo2/></test>"
2393 self.assertEqual(re.findall(p, s),
2394 [('test', '<foo2/>'), ('foo2', '')])
2395 self.assertEqual([m.groupdict() for m in re.finditer(p, s)],
2396 [{'tag': 'test', 'text': '<foo2/>'},
2397 {'tag': 'foo2', 'text': None}])
2398 s = "<test>Hello</test><foo/>"
2399 self.assertEqual([m.groupdict() for m in re.finditer(p, s)],
2400 [{'tag': 'test', 'text': 'Hello'},
2401 {'tag': 'foo', 'text': None}])
2402 s = "<test>Hello</test><foo/><foo/>"
2403 self.assertEqual([m.groupdict() for m in re.finditer(p, s)],
2404 [{'tag': 'test', 'text': 'Hello'},
2405 {'tag': 'foo', 'text': None},
2406 {'tag': 'foo', 'text': None}])
2407
2408 def test_MARK_PUSH_macro_bug(self):
2409 # issue35859, MARK_PUSH() macro didn't protect MARK-0 if it

Callers

nothing calls this directly

Calls 6

finditerMethod · 0.80
groupdictMethod · 0.80
assertEqualMethod · 0.45
groupsMethod · 0.45
searchMethod · 0.45
findallMethod · 0.45

Tested by

no test coverage detected