File: test_groups.py

package info (click to toggle)
python-pcre2 0.4.0%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 284 kB
  • sloc: python: 288; makefile: 31
file content (14 lines) | stat: -rw-r--r-- 486 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import pytest
import pcre2
from pcre2.exceptions import CompileError, MatchError, LibraryError

def test_match_groups():
    assert pcre2.match('a', 'a').groups() == ()
    assert pcre2.match('(a)', 'a').groups() == ('a',)

    assert pcre2.match(b'a', b'a').groups() == ()
    assert pcre2.match(b'(a)', b'a').groups() == (b'a',)

    for a in ("\xe0", "\u0430", "\U0001d49c"):
        assert pcre2.match(a, a).groups() == ()
        assert pcre2.match('(%s)' % a, a).groups() == (a,)