Uname: Linux web3.us.cloudlogin.co 5.10.226-xeon-hst #2 SMP Fri Sep 13 12:28:44 UTC 2024 x86_64
Software: Apache
PHP version: 8.1.31 [ PHP INFO ] PHP os: Linux
Server Ip: 162.210.96.117
Your Ip: 3.17.77.29
User: edustar (269686) | Group: tty (888)
Safe Mode: OFF
Disable Function:
NONE

name : test_re.cpython-310.pyc
o

ab4��@s�ddlmZmZmZmZmZmZddlZddlZddl	Z	ddl
Z
ddlZddlZddlm
Z
ddlmZGdd�de�ZGdd�de�ZGd	d
�d
ej�ZGdd�dej�ZGd
d�dej�ZGdd�dej�Zedkrre��dSdS)�)�
gc_collect�
bigmemtest�_2G�cpython_only�captured_stdout�check_disallow_instantiationN)�Scanner)�proxyc�eZdZ�fdd�Z�ZS)�Sc�tt��|��S�N)r�super�__getitem__��self�index��	__class__��5/usr/local/python-3.10/lib/python3.10/test/test_re.pyr�z
S.__getitem__��__name__�
__module__�__qualname__r�
__classcell__rrrrr�rcr
)�Bcrr
)rrrrrrrrrz
B.__getitem__rrrrrrrrc@seZdZd�dd�Zd�dd�Zd�dd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�Zd2d3�Zd4d5�Zd6d7�Zd8d9�Zd:d;�Zd<d=�Z d>d?�Z!d@dA�Z"dBdC�Z#dDdE�Z$dFdG�Z%dHdI�Z&dJdK�Z'dLdM�Z(dNdO�Z)dPdQ�Z*dRdS�Z+dTdU�Z,dVdW�Z-dXdY�Z.dZd[�Z/d\d]�Z0e1d^d_��Z2d`da�Z3dbdc�Z4ddde�Z5dde6j7fdfdg�Z8e9j:e9j;dhZ<didj�Z=dkdl�Z>dmdn�Z?dodp�Z@dqdr�ZAdsdt�ZBdudv�ZCdwdx�ZDdydz�ZEd{d|�ZFd}d~�ZGdd��ZHd�d��ZId�d��ZJd�d��ZKd�d��ZLd�d��ZMd�d��ZNd�d��ZOd�d��ZPd�d��ZQd�d��ZRd�d��ZSd�d��ZTd�d��ZUd�d��ZVd�d��ZWd�d��ZXd�d��ZYd�d��ZZd�d��Z[d�d��Z\d�d��Z]d�d��Z^d�d��Z_d�d��Z`d�d��Zad�d��Zbd�d��Zcd�d��Zdd�d��Zed�d��Zfd�d��Zgeheid�d��d�d„�Zjeheid�d��d�dń�Zkd�dDŽZld�dɄZme1d�d˄�Znd�d̈́Zod�dτZpd�dфZqd�dӄZrd�dՄZsd�dׄZte1d�dل�Zud�dۄZvd�d݄Zwd�d߄Zxd�d�Zyd�d�Zzd�d�Z{d�d�Z|d�d�Z}d�d�Z~d�d�Zd�d�Z�d�d�Z�d�d�Z�dS)��ReTestsNcs,��||�����fdd���||�dS)NcsJt|ttf�rt||�D]	\}}�||�qdS��t|�t|���dSr
)�
isinstance�tuple�list�zip�assertIs�type)�actual�expect�x�y��msg�recurserrrr,s
�z)ReTests.assertTypedEqual.<locals>.recurse)�assertEqual)rr&r'r+rr*r�assertTypedEqualszReTests.assertTypedEqualcCs�|�tj��
}t�|�Wd�n1swY|j|d��&|j}|�|j|�|dur?|�|j|�Wd�dSWd�dS1sJwYdS)N)�pattern)	�assertRaises�re�error�compile�subTest�	exceptionr-r+�pos)rr/�errmsgr6�cm�errrrr�checkPatternError's��"�zReTests.checkPatternErrorcCs�|�tj��}t�|||�Wd�n1swY|j||d��&|j}|�|j|�|durB|�|j|�Wd�dSWd�dS1sMwYdS)N)r/�repl)	r0r1r2�subr4r5r-r+r6)rr/r;�stringr7r6r8r9rrr�checkTemplateError0s��"�zReTests.checkTemplateErrorcCsftd�}t�d|�}|�t��
|�d�Wd�n1swYt|�~t�|�d�dS)N�x�as�xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx)�	bytearrayr1�finditerr0�BufferError�extendr"r)r�b�itrrr�test_keep_buffer9s�zReTests.test_keep_buffercCs2d}t�d�}t|�}|�|�d�|�d��dS)NZQabbbcRzab+c)r1r3r	r-�findall)r�sr(r)rrr�test_weakrefDs
zReTests.test_weakrefcCs�|�t�dd��d�d�|�t�dd���d�|�t�dd��d�d�|�t�dd���d�|�t�dd��|�t�d	d
��d�d�|�t�d	d
���d�|�t�dd��d�d�|�t�dd���d�|�t�d
d
��dS)Nzx*Zaxxr�rrzx+���r(Zaaaza*�xxxZxxxa�rrN�a+)r-r1�search�span�assertIsNone�match�rrrr�test_search_star_plusJszReTests.test_search_star_pluscCst|�d��}t|d�S)NrrM)�int�group�str)rZmatchobjZ	int_valuerrr�bump_numVszReTests.bump_numc
s|�t�ddd�d�|�t�dtd�td��d�|�t�ddd�d�|�t�dtd�td��d�|�t�dtd�td��d�|�t�dtd�td��d�d	D]}|�t�|dd
|�d�qT|�t�ddd
�d�|�t�d|jd�d�|�t�d|jdd�d�|�tjd|jddd�d�|�t�ddd�d�d�|�t�ddd�d�d�|�t�d�d�d�|�t�d��	dd�d���|�t�d�fdd�d���|�t�d d!d�d"�|�t�d d#d�d"�|�t�d$d%d�d"�|�t�d$d&d�d"�|�t�dd'd�d(�|�t�dd(d�d(�|�t�dd(d�t
d)�t
d*�t
d+�t
d,�t
d-�t
d.�t
d/��d0D]?}|�|��.|�tj
��|�t�dd|d�d|�Wd�n	1�skwYWd�n	1�s{wY�qB|�t�d1d2d3�d4�dS)5Nr)�a�xyzZxaz�yr@�xyzsxaz��àuаu𝒜zx%sz�(?i)b+r(�	bbbb BBBB�x x�\d+z08.2 -2 23x99yz9.3 -3 24x100yrNz
9.3 -3 23x99y��count�.cS�dS)N�\nr��mrrr�<lambda>l�z+ReTests.test_basic_re_sub.<locals>.<lambda>rj�
z\1\1z(.)�xx�\�\\cs�Sr
rrk�rIrrrmrrn�(?P<a>x)z
\g<a>\g<a>Zxxxxz
\g<a>\g<1>�
(?P<unk>x)z\g<unk>\g<unk>z
\g<1>\g<1>z\t\n\v\r\f\a\bz	

�	�
��
���Z,cdehijklmopqsuwxyzABCDEFGHIJKLMNOPQRSTUVWXYZz^\s*�X�testZXtest)r.r1r<rrrA�
memoryviewr-r[�replace�chrr4r0r2)rr)�crrsr�test_basic_re_subZsT���6� ����zReTests.test_basic_re_subcC�|�t�ddd�d�dS)Nruz\g<1>\g<1>\brpzxxxx�r-r1r<rVrrr�test_bug_449964�s�zReTests.test_bug_449964cCs\|�t�ddd�d�|�t�ddd�d�|�t�ddd�d�|�t�ddd�d�dS)Nz\r\nrjz
abc
def
zabc
def
z
ror�rVrrr�test_bug_449000�s����zReTests.test_bug_449000cCsdt�d�}|�ttj|dtj�|�ttj|dtj�|�ttj|dtj�|�ttj|tj�dS)Nrh�A)r1r3r0�
ValueErrorrU�IrRrH�rr/rrr�
test_bug_1661�s

zReTests.test_bug_1661cCst�d�dS)Nz(?P<quote>)(?(quote)))r1r3rVrrr�
test_bug_3629�szReTests.test_bug_3629cCs�|�t�ddd�d�|�t�ddd�d�|�t�ddd�d�|�t�ddd�d�|�t�dd	d�d
�|�t�ddd�d�|�t�dd
d�d�|�t�ddd�d�|�t�ddd�d�|�t�ddd�d�|�t�ddd�d�|�t�ddd�d�|�t�ddd�d�|�t�ddd�d
�|�t�ddd�d�|�ddddd�|�ddddd�|�dddd d!�|�dd"dd#d!�|�dd$dd%d!�|�dd&dd'd!�|�dd(dd)d!�|�dd*dd d!�|�dd+dd,d!�|�dd-dd.d!�|�dd/dd'd!�|�dd0dd'd!�|�dd1dd)d!�|�dd2dd3d!�|�dd"d4d#d!�|�t�d5d&d�d�|�t�d6d/d7�d8�|�t�d6d0d7�d9�dS):Nr(�\0�z\000z\001�z\008�8z\009z9z\111r�z\117�Oz\377�ÿz\1111ZI1z\00z\07��\08z\09z\0azaz\400z0octal escape value \400 outside of range 0-0o377rz\777z0octal escape value \777 outside of range 0-0o377z\1zinvalid group reference 1rMz\8zinvalid group reference 8z\9zinvalid group reference 9z\11zinvalid group reference 11z\18zinvalid group reference 18z\1az\90zinvalid group reference 90z\99zinvalid group reference 99z\118z\11az\181z\800zinvalid group reference 80�z(((((((((((x)))))))))))z((((((((((y))))))))))(.)r]Zxz8Zxza)r-r1r<r>rVrrr� test_sub_template_numeric_escape�sV
�
���z(ReTests.test_sub_template_numeric_escapecCsL|�t�ddd�d�|�t�dddd�d�|�tjddddd�d�dS)Nr\rEZaaaaaZbbbbbrMZbaaaarfr�rVrrr�test_qualified_re_sub�szReTests.test_qualified_re_subcCr�)Nz(\S)\s+(\S)z\1 \2zhello  therezhello therer�rVrrr�test_bug_114660�s�zReTests.test_bug_114660cCs�t�d�t�d�t�d�|�dd�|�ddd�|�d	d
�|�ddd
�|�ddd�|�ddd�|�ddd�|�dd�|�dd�|�ddd�|�ddd�|�ddd�|�ddd�|�ddd�|�ddd�|�d dd�|�d!dd"�|�d#dd"�|�d$dd"�|�d%d&d"�|�d'd(d"�|�d)dd"�t�d*�t�d+�|�d,d-d�d.�d/d0�td1d2�D��}d3|}|�t�|d4���d5�dS)6Nz(?P<a>x)(?P=a)(?(a)y)z(?P<a1>x)(?P=a1)(?(a1)y)z(?P<a1>x)\1(?(1)y)z(?P<a>)(?P<a>)z6redefinition of group name 'a' as group 2; was group 1z
(?P<a>(?P=a))�cannot refer to an open grouprwz(?Pxy)zunknown extension ?Pxz(?P<a>)(?P=azmissing ), unterminated namerxz(?P=�missing group name�z(?P=)z(?P=1)zbad character in group name '1'z(?P=a)zunknown group name 'a'z(?P=a1)zunknown group name 'a1'z(?P=a.)z bad character in group name 'a.'z(?P<)�missing >, unterminated namez(?P<az(?P<z(?P<>)z(?P<1>)z(?P<a.>)z(?(rNz(?())z(?(a))z(?(-1))� bad character in group name '-1'z(?(1a))z bad character in group name '1a'z(?(a.))u(?P<µ>x)(?P=µ)(?(µ)y)uf(?P<𝔘𝔫𝔦𝔠𝔬𝔡𝔢>x)(?P=𝔘𝔫𝔦𝔠𝔬𝔡𝔢)(?(𝔘𝔫𝔦𝔠𝔬𝔡𝔢)y)u	(?P<©>x)� bad character in group name '©'�|cs��|]	}d||fVqdS�z
x(?P<a%d>%x)yNr��.0�irrr�	<genexpr>���z/ReTests.test_symbolic_groups.<locals>.<genexpr>rM��z(?:%s)(?(200)z|t)�xc8yz�r�)r1r3r:�join�ranger-rUrS�r�patrrr�test_symbolic_groups�sF


��

zReTests.test_symbolic_groupscCsz|�ddddd�|�ddddd�|�dddd	d
�|�ddddd�|�dd
ddd�|�ddddd�|�ddddd�|�ddddd�|�td��t�ddd�Wd�n1s`wY|�t�ddd�d�|�t�ddd�d�|�ddddd�|�t�ddd�d�|�t�ddd�d�|�dddd d�d!�d"d#�tdd$�D��}|�t�|d%d&�d'�dS)(Nrtz\g<arpr�rNz\g<r�z\gz	missing <�z\g<a a>z!bad character in group name 'a a'z\g<>z\g<1a1>z!bad character in group name '1a1'z\g<2>zinvalid group reference 2z\2rMzunknown group name 'ab'z\g<ab>z(?P<a>x)|(?P<b>y)z\g<b>r�z\g<-1>r�u	(?P<µ>x)u\g<µ>u#(?P<𝔘𝔫𝔦𝔠𝔬𝔡𝔢>x)u \g<𝔘𝔫𝔦𝔠𝔬𝔡𝔢>u\g<©>r�r�csr�r�rr�rrrr�r�z-ReTests.test_symbolic_refs.<locals>.<genexpr>r�z\g<200>Z	xc8yzxc8yZc8zc8)r>�assertRaisesRegex�
IndexErrorr1r<r-r�r�r�rrr�test_symbolic_refs�sJ
�
�
�
�
�
�
��
�
�zReTests.test_symbolic_refscCs�|�t�ddd�d�|�t�ddd�d�|�t�ddd�d�|�t�d	dd�d
�|�t�d	ddd�d�|�tjd	dddd
�d�dS)Nrbr(rc)rdr�zb+)zx BBBBrMr])r]rzb*)Zxxxyxzxr�r�)Zxxxyzr�rf)r-r1�subnrVrrr�test_re_subnszReTests.test_re_subncCs�dtd�fD]&}|�t�d|�gd��|�t�d|�gd��|�t�d|�gd��qdtd�td�td�fD]&}|�t�d	|�gd
��|�t�d|�gd��|�t�d
|�gd��q9dD]:\}}}d|||f}|�t�d|�d||d|g�|�t�d|�d|||g�|�t�d|�dd|d|d|g�qb|�t�dd�gd��|�t�dd�gd��|�t�dd�gd��|�t�dd�gd��|�t�dd�gd��dgd�fdgd�fdgd �fd!gd"�ffD]%\}}|j|d#��|�t�|d�|�Wd�n	1�swYq�dgd$�fd%gd&�fd'gd(�fd)gd*�ffD]&\}}|j|d#��|�t�|d�|�Wd�n	1�sKwY�q+dS)+N�:a:b::c�:)r�r\rEr�r��:+)r�r\rEr��(:+))r�r�r\r�rE�::r�s:a:b::c�:)�r@�br��c�:+)r�r@r�r��(:+))r�r�r@r�r��::r�)uàßçuабвu𝒜𝒞𝒵z
:%s:%s::%sr�r�z(?::+)z(:)+)r�r�r\r�rEr�r�z([b:]+))r�r�r\z:b::r�z(b)|(:+))
r�Nr�r\Nr�r�rENr�Nr�r�z(?:b)|(?::+))r�r\r�r�r�z:*)r�r�r\r�rEr�r�r�z(?::*)�(:*))r�r�r�r�r\r�r�r�rEr�r�r�r�r�r�z(:)*)r�r�r�Nr\r�r�NrEr�r�Nr�Nr�)�sep)	r�r�r\r�rEr�r�r�r��\b)r�r\r�rEr�r�r�z(?=:))r�z:az:br�z:cz(?<=:))r��a:zb:r�r�)	rr.r1�splitrrArr-r4)rr=r\rEr�r��expectedrrr�
test_re_split&sz������������



���



����zReTests.test_re_splitcCs�|�t�ddd�gd��|�tjdddd�gd��|�tjdddd�gd��|�tjdddd�gd	��|�tjd
ddd�gd	��|�tjdddd�gd��dS)
Nr�r�r�)r�r\�b::c)�maxsplitza:b:c:d)r\rEzc:dz(:))r�r�r\r�r�r�r�)r�r�r�r�za:b::c)r-r1r�rVrrr�test_qualified_re_split[s���zReTests.test_qualified_re_splitcCsj|�t�dd�g�dtd�fD]&}|�t�d|�gd��|�t�d|�gd��|�t�d|�gd��qdtd�td�td�fD]&}|�t�d	|�gd
��|�t�d|�gd
��|�t�d|�gd
��qCdD]F}|d}|d}d|||f}|�t�d||�|||g�|�t�d||�|||g�|�t�d||f|�|df||f||fg�qldS)Nr��abc�
a:b::c:::d�r�r�z:::r�z(:)(:*)))r�r�)r�r�)r�r�s
a:b::c:::dr�)r�r�s:::r�s(:)(:*)))r�r�)r�r�)r�r�r`r�rNz
a%sb%sc%sdz%s+z(%s+)z	(%s)(%s*)r�)r-r1rHrr.rrAr)rr=r(rprOrrr�test_re_findallfsB���������zReTests.test_re_findallcCs|�t�dd�gd��dS)Nz(a|(b))�aba)�r\r�)rErEr�)r-r1rHrVrrr�test_bug_117612�s�zReTests.test_bug_117612cCs�dtd�fD]B}|�t�d|���d�|�t�d|���d�|�t�d|��d�d�|�t�d|��d�d�|�t�d|��dd�d�qdtd�td�td�fD]B}|�t�d|���d�|�t�d	|���d
�|�t�d	|��d�d�|�t�d	|��d�d�|�t�d	|��dd�d�qUdD]M}|�t�||���d�|�t�d
||���|f�|�t�d
||��d�|�|�t�d
||��d�|�|�t�d
||��dd�||f�q�t�	d�}|�|�d���d�|�|�d���d�|�|�d���d�|�|�d���d�|�|�d��d�d�t�	d�}|�|�d��ddd�d�|�|�d��ddd�d�|�|�d��ddd�d �dS)!Nr\r�(a))r\rrM�r\r\r@s(a))r@)r@r@r`z(%s)z
((a)|(b))(c)?)r\r\NNrE)rENrEN�ac)r\r\Nr��bc)rENrEr�r�)rEr�rEr��!(?:(?P<a1>a)|(?P<b2>b))(?P<c3>c)?r�rN�r\NN�a1�b2�c3)NrEN)r\Nr�)
rr-r1rU�groupsrYrrArr3)rr=r\r�rrr�
test_re_match�s<&

� zReTests.test_re_matchcCs�Gdd�d�}t�dd�}|�|��d�|�|�d�d�|�|�d�d�|�|�|d��d�|�t|jd�|�t|jd	�|�t|jdd
>�|�t|j|dd
>��|�t|jd�|�|�dd�d
�|�|�|d�|d��d
�dS)Nc@�eZdZdd�Zdd�ZdS)z!ReTests.test_group.<locals>.IndexcSs
||_dSr
��value)rr�rrr�__init__�s
z*ReTests.test_group.<locals>.Index.__init__cSs|jSr
r�rVrrr�	__index__�sz+ReTests.test_group.<locals>.Index.__index__N)rrrr�r�rrrr�Index�sr�z(a)(b)�abrrMr\���rN��r(r��rEr\)r1rUr-rYr0r�)rr�rlrrr�
test_group�s zReTests.test_groupcCs�t�d�}|�d�}|�|dd�|�|dd�|�|dd�|�d�|�d�|�|dd�|�|d	d�|�|d
d�|�|dd�|�td��|d
Wd�n1s`wY|�td��|dWd�n1szwY|�td��|dWd�n1s�wY|�td��|dWd�n1s�wY|�td��|dWd�n1s�wY|�td��|dWd�n1s�wY|�td��
d�|�Wd�n1s�wY|�d�}|�|dd�|�|dd�|�|dd�|�d�|�d�|�|dd�|�|d	d�|�|d
d�|�|dd�|�t��d	|d<Wd�n	1�s]wY|�tt	|�dS)Nr�r\r�r�r�za1={a1} b2={b2} c3={c3}za1=a b2=None c3=NonerrMr�rNz
no such groupr}r�r��rrM�rza1={a2}r�r�za1=a b2=None c3=c)
r1r3rUr-�
format_mapr�r�r0�	TypeError�len)rr�rlrrr�test_match_getitem�sX


�
�
�
�
�
��

�zReTests.test_match_getitemcCs$|�t�dd���d�dtd�fD]}|�t�d|���d�qdtd�td�td�fD]}|�t�d|���d�q-dD]\}}d	|||f}|�t�|||���d�q>|�t�d
d���d�|�t�d
d���d�|�t�dd���d�|�t�dd���d�|�t�dd���d�|�t�dd��|�t�dd��|�t�dd��|�t�dd��|�t�dd���d�|�t�dd���d�|�t�dd���d�|�t�	d�jdddd���d�|�t�	d
�jdddd���d�|�t�	d
�jdddd���d�dS) Nr\r�r�za|ab�rr�sabsa|ab)uàßuабu𝒜𝒞z%s|%sz.*?$r�rPz.*?za.*?b�abbZaxxb�rr�rQzabc$zabc
zabc\Zz(?m)abc$z	ab(?=c)cd�abcdz
ab(?<=b)cdz
(?=a|ab)abr�rMrN�r6�endposrL)
r-r1�	fullmatchrSrrrArrTr3)rr=r\rE�rrrr�test_re_fullmatch�s:���zReTests.test_re_fullmatchcCsr|�t�dd���d�|�t�dd���d�|�t�dd��|�t�dd��|�t�dd	���d
�|�t�dd���d�|�t�d
d���d�|�t�d
d���d�t�d�}|�|�d���d�|�|�d���d�|�|�d��|�|�d��d�dd�tdd�D��}d|}|�t�|d���d�|�	ddd �|�	d!d"d#�|�	d$d%d �dS)&Nz^(\()?([^()]+)(?(1)\))$r�)�(r\r\�Nr\za)z(az^(?:(a)|c)((?(1)b|d))$r��r\rE�cd)N�dz^(?:(a)|c)((?(1)|d))$r�z(?P<g1>a)(?P<g2>b)?((?(g2)c|d))r��r\rEr�Zad)r\Nr�Zabdr�r�csr�r�rr�rrrr�r�z2ReTests.test_re_groupref_exists.<locals>.<genexpr>rMr�z(?:%s)(?(200)z)r�r�z
(?P<a>)(?(0))zbad group numberrwz
()(?(1)a|b�"missing ), unterminated subpatternr�z
()(?(1)a|b|c)z/conditional backref with more than two branches)
r-r1rUr�rTr3r�r�rSr:)r�pr�rrr�test_re_groupref_existssP������
����zReTests.test_re_groupref_existscCs@ddlm}|�dd|dd|d�|�d|d|d	�dS)
Nr)�	MAXGROUPSz()z\g<%s>rpzinvalid group reference %drNz(?P<a>)(?(%d))rw)�
sre_constantsrr>r:)rrrrr�test_re_groupref_overflow)s�
�z!ReTests.test_re_groupref_overflowcCs�|�t�dd���d�|�t�dd���d�|�t�dd��|�t�dd��|�t�d	d
���d�|�t�dd
���d�|�ddd�dS)Nz^(\|)?([^()]+)\1$z|a|)r�r\z^(\|)?([^()]+)\1?$r\r�za|z|az^(?:(a)|c)(\1)$Zaar�z^(?:(a)|c)(\1)?$r��NNz(abc\1)r�r�)r-r1rUr�rTr:rVrrr�test_re_groupref0s����zReTests.test_re_grouprefcCs"|�t�dd���ddd��dS)N�#(?P<first>first) (?P<second>second)�first second�first�second)r	r
)r-r1rU�	groupdictrVrrr�test_groupdict>s
��zReTests.test_groupdictcCs8|�t�dd��d�d�|�t�dd��d�d�dS)	Nrrz\2 \1 \g<second> \g<first>zsecond first second firstz#(?P<first>first)|(?P<second>second)r	z
\2 \g<second>� )r-r1rU�expandrVrrr�test_expandCs
��
��zReTests.test_expandcCs8|�t�dd��|�t�dd��|�t�dd��|�t�dd��|�t�dd��d�d�|�t�d	d��d�d�|�t�d
d��d�d�|�t�dd��d�d�|�t�dd��d�d�|�t�d
d��d�d�|�t�dd��d�d�|�t�dd��d�d�|�t�dd��|�t�dd��|�t�dd��|�t�dd��|�t�dd��|�t�dd��|�t�dd��|�t�dd��|�t�dd��|�t�dd��|�t�dd��|�t�dd��|�t�dd��|�t�dd��|�t�dd��|�ddd �dS)!Nz	^(\w){1}$r�z
^(\w){1}?$z^(\w){1,2}$z^(\w){1,2}?$z	^(\w){3}$rMr�z^(\w){1,3}$z^(\w){1,4}$z^(\w){3,4}?$z
^(\w){3}?$z^(\w){1,3}?$z^(\w){1,4}?$z^x{1}$rOz^x{1}?$z^x{1,2}$z	^x{1,2}?$z^x{3}$z^x{1,3}$z^x{3,3}$z^x{1,4}$z	^x{3,4}?$z^x{3}?$z	^x{1,3}?$z	^x{1,4}?$z^x{}$zx{}zx{2,1}z"min repeat greater than max repeatr�)rTr1rUr-rY�
assertTruer:rVrrr�test_repeat_minmaxMs<�zReTests.test_repeat_minmaxcCsZ|�t�d�jd�|�t�d�jtjtjB�|�t�d�jd�|�t�d�ji�|�t�d�jddd��|�t�	dd�j
d�|�t�	dd�jd�|�t�	dd�jd�|�t�	dd�j
d	�|�t�	dd�j�t�d�}|�t|j�d
dg�|�|jdd�|�t��
d|jd<Wd�n1s�wY|�|jdd�dS)Nz
(?i)(a)(b)r�z(?i)(?P<first>a)(?P<other>b)rM)r	�otherr�r\r)r�r�r	r)r-r1r3r/�flagsr��Ur��
groupindexrUr6r�r=�regsr�sortedr0r�)rrrrr�test_getattrqs&�
�zReTests.test_getattrcCs�|�t�dd��d�d�|�t�dd��d�d�|�t�ddtj��d�d�|�t�ddtj��d�d�|�t�ddtj��d	�d
�|�t�dd
tj��d	�d
�|�t�ddtj��|�t�dd
��d�d�|�t�dd��d�d�|�t�dd
tj��d�d�|�t�ddtj��d�d�|�t�ddtj��d	�d�|�t�ddtj��d	�d�|�t�ddtj��|�t�dd��d	�d�|�t�dd��d	�d�|�t�ddtj��d	�d�|�t�ddtj��d	�d�dS)Nz\b(b.)\bzabcd abc bcd bxrM�bxz\B(b.)\Bzabc bcd bc abxdz^abc$z
abc
rr�z	^\Aabc\Z$s\b(b.)\bsabcd abc bcd bxsbxs\B(b.)\Bsabc bcd bc abxds^abc$s
abc
�abcs	^\Aabc\Z$z\d\D\w\W\s\Sz1aa! as\d\D\w\W\s\Ss1aa! a)r-r1rRrY�ASCII�MrT�LOCALErVrrr�test_special_escapes�s�
��
��
��
��
��
��
��
��
��
��
��
��zReTests.test_special_escapesc	Csn|�ddd�|�t�dd���d�|�t�dd��|�t�dd���d�|�t�dd	���d	�|�t�dd
��|�t�dd���d�|�t�dd
��|�t�dd���d�|�t�dd
��t��dD]"}|�|��|�tj	tj
d|�Wd�n1s�wYqmdD]"}|�|��|�tj	tj
d|�Wd�n1s�wYq�dS)Nrqzbad escape (end of pattern)rz\(r��)rrz[\]]�]�[z[a\-c]�-rEz[\^a]+za^Z!ceghijklmopqyzCEFGHIJKLMNOPQRTVXYz\%cZ$ceghijklmopqyzABCEFGHIJKLMNOPQRTVXYZz[\%c])r:r-r1rUrYrT�purger4r0r2r3)rr�rrr�test_other_escapes�s,�����zReTests.test_other_escapescCsT|�t�dd��|�t�dd��|�t�dd��|�t�dd��|�t�dd��|�t�d	d
��|�t�d	d��|�dd
d�|�dd
d�|�ddd�|�ddd�|�ddd�|�ddd�|�dd
d�|�dd
d�|�ddd�|�ddd�|�ddd�|�dd d!�|�d"d d�|�d#d$d!�|�d%d$d�dS)&Nz\N{LESS-THAN SIGN}�<z\N{less-than sign}�>z	\N{SNAKE}u🐍zW\N{ARABIC LIGATURE UIGHUR KIRGHIZ YEH WITH HAMZA ABOVE WITH ALEF MAKSURA ISOLATED FORM}uﯹz*[\N{LESS-THAN SIGN}-\N{GREATER-THAN SIGN}]�=�;z\Nz	missing {r�z[\N]rNz\N{zmissing character namez[\N{r�z\N{}z[\N{}]z\NSNAKE}z
[\NSNAKE}]z\N{SNAKEzmissing }, unterminated namez
[\N{SNAKE]z[\N{SNAKE]}z!undefined character name 'SNAKE]'rMz\N{SPAM}zundefined character name 'SPAM'rz
[\N{SPAM}]s\N{LESS-THAN SIGN}z
bad escape \Ns[\N{LESS-THAN SIGN}])rr1rUrTr:rVrrr�test_named_unicode_escapes�sL
�
�
������z"ReTests.test_named_unicode_escapescCs�|�t�dd��d�d�|�t�dd��|�t�dd��|�t�dd��|�t�dd��|�t�dd��|�tt�	dd��d�|�tt�	dd��d	�|�tt�	dd
��d	�|�tt�	dd��d	�|�tt�	dd
��d�dS)Nz	\b(abc)\br�rMr��\Br�r\r�rr
z   )
r-r1rRrYrrU�assertFalserTr�rHrVrrr�test_string_boundaries�s�zReTests.test_string_boundariesc	CsR|�t�dd��d�d�dd�tttddd���}|�t�|d	���d	�dS)
Nu
([∢∣])u∢rMz[%s]r����u!)r-r1rUrYr��mapr�r��rr�rrr�test_bigcharset�s
��zReTests.test_bigcharsetcCsBt�d�dd�td�D���}|�|�d��|�|�d��dS)Nr�css�|]}d|VqdS)z%dNr)r�r(rrrr���z,ReTests.test_big_codesize.<locals>.<genexpr>�'Z1000Z9999)r1r3r�r�rrUr1rrr�test_big_codesize�szReTests.test_big_codesizecCs@|�t�ddtj��d�d�|�t�ddtj��d�d�dS)Nza.bza
brza.*bza

b)r-r1rU�DOTALLrYrVrrr�test_anyalls��zReTests.test_anyallcCs�|�t�dd��d�d�|�t�dd��d�d�|�t�dd��d�d�|�t�dd��d�d�|�t�d	d
��d�d�|�t�dd��d�d�|�t�d
d
��d�d�|�t�dd
��d�d�|�t�dd��d�d�|�t�dd��d�d�|�t�dd��d�d�|�t�dd��|�t�dd��|�t�dd��|�t�dd��|�t�dd��|�t�dd��|�t�dd��|�t�dd��|�t�dd��|�t�dd��dS)Nz
(a(?=\s[^a]))�a brMr\z(a(?=\s[^a]*))z(a(?=\s[abc]))z(a(?=\s[abc]*))za bcz(a)(?=\s\1)�a az(a)(?=\s\1*)�a aaz(a)(?=\s(abc|a))z
(a(?!\s[^a]))z(a(?!\s[abc]))za dz(a)(?!\s\1)z(a)(?!\s(abc|a))z(a)b(?=\1)ar�z(a)b(?=\1)cZabacz(?:(a)|(x))b(?=(?(2)x|c))cr�z(?:(a)|(x))b(?=(?(2)c|x))cz(?:(a)|(x))b(?=(?(1)b|x))cz(?:(a)|(x))b(?=(?(1)c|x))cz(a)b(?=(?(2)x|c))(c)z(a)b(?=(?(2)b|x))(c)z(a)b(?=(?(1)c|x))(c))r-r1rUrYrrTrVrrr�test_lookahead
s*zReTests.test_lookaheadcCsl|�t�dd��|�t�dd��|�t�dd��|�t�dd��|�t�dd��|�t�dd	��|�t�d
d��|�t�dd	��|�t�dd��|�t�d
d��|�t�dd��|�t�dd��|�t�dd��|�tjtjd�|�t�dd��|�t�dd��|�tjtjd�|�tjtjd�|�tjtjd�|�tjtjd�dS)Nz	ab(?<=b)cr�z	ab(?<=c)cz	ab(?<!b)cz	ab(?<!c)cz(a)a(?<=\1)cZaacz(a)b(?<=\1)aZabaaz(a)a(?<!\1)cz(a)b(?<!\1)az(?:(a)|(x))b(?<=(?(2)x|c))cz(?:(a)|(x))b(?<=(?(2)b|x))cz(?:(a)|(x))b(?<=(?(2)x|b))cz(?:(a)|(x))b(?<=(?(1)c|x))cz(?:(a)|(x))b(?<=(?(1)b|x))cz(a)b(?<=(?(2)b|x))(c)z(a)b(?<=(?(1)c|x))(c)z(a)b(?<=(?(1)b|x))(c)z(a)b(?<=(.)\2)(c)z(a)b(?<=(?P<a>.)(?P=a))(c)z(a)b(?<=(a)(?(2)b|x))(c)z(a)b(?<=(.)(?<=\2))(c))rr1rUrTr0r2r3rVrrr�test_lookbehind&s(zReTests.test_lookbehindcCsT|�t�ddtj��d�d�|�t�ddtj��d�d�|�t�ddtj��d�d�|�t�d	d
tj��d�d
�|�t�ddtj��d�d�|�t�dd
tj��d�d
�|�t�d
dtj��d�d�|�t�ddtj��d�d�|�t�ddtj��d�d�|�t�ddtj��d�d�d��dks�J�|�t�ddtj��|�t�ddtj��|�t�ddtj��|�t�ddtj��d��dks�J�|�t�ddtj��|�t�ddtj��|�t�ddtj��|�t�ddtj��d��d��k�rdk�sJ�J�|�t�ddtj��|�t�ddtj��dS) Nr��ABCrrsABCz	(a\s[^a])r8rMz
(a\s[^a]*)za bbz
(a\s[abc])z(a\s[abc]*)z	((a)\s\2)r9z
((a)\s\2*)r:z((a)\s(abc|a))z((a)\s(abc|a)*)�K�k�Kz\u212a�ſrrIz\u017f�ſt�st�STz\ufb05z\ufb06)r-r1rUr�rY�lowerr�upperrVrrr�test_ignore_case@s.(zReTests.test_ignore_casecCs�|�t�ddtj��|�t�ddtj��|�t�ddtj��|�t�ddtj��|�t�ddtj��|�t�ddtj��|�t�ddtj��|�t�ddtj��d	��d
ks`J�|�t�dd	tj��|�t�dd	tj��|�t�d
dtj��|�t�d
d
tj��d��dks�J�|�t�ddtj��|�t�ddtj��|�t�ddtj��|�t�ddtj��d��d��kr�dks�J�J�|�t�ddtj��|�t�ddtj��dS)Nz[19A]r�z[19a]r\s[19A]�As[19a]r@r>r?z[19K]z[19k]z
[19\u212a]r@rArz[19S]z[19s]z
[19\u017f]rIrBrCrDz
[19\ufb05]z
[19\ufb06])rr1rUr�rErFrVrrr�test_ignore_case_setZs*$zReTests.test_ignore_case_setcCs�|�t�ddtj��|�t�ddtj��|�t�ddtj��|�t�ddtj��|�t�ddtj��|�t�dd	tj��|�t�d
d	tj��|�t�d
dtj��|�t�ddtj��|�t�dd
tj��|�t�ddtj��|�t�dd
tj��|�t�ddtj��|�t�ddtj��|�t�ddtj��|�t�ddtj��d��dks�J�|�t�ddtj��|�t�ddtj��|�t�ddtj��|�t�ddtj��d��dks�J�|�t�ddtj��|�t�ddtj��|�t�ddtj��|�t�ddtj��d��d ��k�r)d!k�s,J�J�|�t�d"d tj��|�t�d#dtj��dS)$Nz[9-a]�_z[9-A]s[9-a]�_s[9-A]z[\xc0-\xde]�×�÷z[\xe0-\xfe]z[\u0430-\u045f]uѐuЀz[\u0400-\u042f]z[\U00010428-\U0001044f]u𐐨u𐐀z[\U00010400-\U00010427]r>r?z[J-M]z[j-m]z[\u2129-\u212b]r@rArz[R-T]z[r-t]z[\u017e-\u0180]rIrBrCrDz[\ufb04-\ufb05]z[\ufb06-\ufb07])rr1rUr�rTrErFrVrrr�test_ignore_case_rangeqs:(zReTests.test_ignore_case_rangecCs|�t�dd��d�d�dS)Nz(\s)r
rM�r-r1rUrYrVrrr�
test_category�szReTests.test_categorycCsnddl}td�D]5}t|�}t|���}|�|�|�|�|�|�|�|�|tj	v}|�|�
|�|�|�|�|�|�qttdd��ddgD]G}t|�}|�|�|�|�|dkri|�|�|�t|����||��kpt||�
�k}|�|�
|��|�|�|�||��kp�||�
�k�qI|�|�d�d�|�|�d�td��|�|�
d��|�|�d��dS)Nr�iii(i0r�)�_srer�r��ordrEr-�
ascii_tolower�unicode_tolowerr=�
ascii_letters�
ascii_iscased�unicode_iscasedr"rFr+r)rrRr�r��lo�iscasedrrr�test_case_helpers�s.
�zReTests.test_case_helperscCs8|�t�dd��d�d�|�t�dd��d�d�dS)Nz\s([^a])� brMrEz	\s([^a]*)z bbZbb�r-r1rRrYrVrrr�test_not_literal��zReTests.test_not_literalcCs�ttd����}|�t��
t�d�}Wd�n1swY|�|�|�t	d��|�t�d|�t	d��|�t��
t�d�}Wd�n1sNwY|�|�|�t	d��|�t��
t�d�}Wd�n1sswY|�|�|�t	d	��|�t��
t�d
�}Wd�n1s�wY|�|�|�t	d��|�t��
t�d�}Wd�n1s�wY|�|�|�t	d��|�t�d
|�t	d��|�t��
t�d�}Wd�n1s�wY|�|�|�t	d��|�t��
t�d�}Wd�n	1�swY|�|�|�t	d��|�t�d|�t	d��|�t��
t�d�}Wd�n	1�sFwY|�|�|�t	d��|�t��
t�d�}Wd�n	1�slwY|�|�|�t	d��|�t�d|�t	d��|�t��
t�d�}Wd�n	1�s�wY|�|�|�t	d��|�t��
t�d�}Wd�n	1�s�wY|�|�|�t	d��dS)NrQz[0-9--1]z
-./0123456789z[--1]z-./01z[%--1]z
%&'()*+,-1z[%--]z	%&'()*+,-z[0-9&&1]z&0123456789z[\d&&1]z[&&1]z&1z[0-9||a]z0123456789a|z[\d||a]z[||1]z1|z[0-9~~1]z0123456789~z[\d~~1]z[~~1]z1~z[[0-9]|]z0123456789[]z[[:digit:]|]z:[]dgit)
�bytesr��decode�assertWarns�
FutureWarningr1r3r-rHr"�rrIrrrr�test_possible_set_operations�sb�����������z$ReTests.test_possible_set_operationscCs8|�t�dd��d�d�|�t�dd��d�d�dS)Nz\s(b)r\rMrEza\sza rr]rVrrr�test_search_coverage�r_zReTests.test_search_coveragecCsr|dur|dur|}dt|�f}n|dus|durtd��|||�}|�|�|�|��|�|�|��|�dS)Nrz@If match is not None, span should be specified (and vice versa).)r�r�rr-rYrS)rr/�textrUrSZmatcherrlrrr�assertMatch�s

zReTests.assertMatchz!"%',/:;<=>@_`cCs�d�dd�td�D��}|D]#}|�t�|�|�|�dt�|�d|�|�dt�|�|�q|�t�|�|�dD]}|�t�|�dd	�d
�q=|j}|�t�|�|�dS)Nr�css�|]}t|�VqdSr
)r�r�rrrr��r3z)ReTests.test_re_escape.<locals>.<genexpr>r-r!r z(?x)z-.]{}rMrq)r�r�rhr1�escaper-�
LITERAL_CHARS)rrr��
literal_charsrrr�test_re_escape�szReTests.test_re_escapecCs�ttd��}|D](}t|g�}|�t�|�|�|�dt�|�d|�|�dt�|�|�q|�t�|�|�dD]}t|g�}|�t�|�dd�d�q<|j�d�}|�t�|�|�dS)	Nr-�[�]s(?x)s-.]{}rM�\�ascii)r`r�rhr1rir-rj�encode)rrr�rErkrrr�test_re_escape_bytess

zReTests.test_re_escape_bytescCsHd}t�|�}|�||�|�||�|�dt�d�|ddtj�dS)Nuxxx☠☠☠xxxz.%s+.�☠ux☠☠☠x)r�r{)r1rir-rhrR)rrIZ	s_escapedrrr�test_re_escape_non_asciis
�z ReTests.test_re_escape_non_asciicCsXd�d�}t�|�}|�||�|�||�t�t�d�d��|�}|�t|�d�dS)Nu	y☠y☠yzutf-8rsr�)rqr1rir-rhrHr�)rrEZ	b_escaped�resrrr�test_re_escape_non_ascii_bytess

z&ReTests.test_re_escape_non_ascii_bytescCs\ddl}t�dtj�}t|jd�D]}|�||�}|�|�}|�||�qddlm	}dS)Nrza(?:b|(c|e){1,2}?|d)+?(.)rM)�_compile)
�pickler1r3�UNICODEr��HIGHEST_PROTOCOL�dumps�loadsr-rw)rrxZoldpat�protoZpickledZnewpatrwrrr�
test_picklings
zReTests.test_picklingcCshddl}t�d�}|�|�|�|�|�|�|�|�|�d�}|�|�|�|�|�|�|�|�dS)Nrz (?P<int>\d+)(?:\.(?P<frac>\d*))?z12.34)�copyr1r3r$�deepcopyrU)rrrrlrrr�test_copying)s

zReTests.test_copyingcCsT|�tjtj�|�tjtj�|�tjtj�|�tjtj	�|�tj
tj�dSr
)r-r1r��
IGNORECASE�Lrr�	MULTILINErr6r}�VERBOSErVrrr�test_constants2s
zReTests.test_constantscCsltjtjtjtjtjtjfD]}|�t�d|��qtjtjtjtjtjtj	fD]}|�t�d|��q(dS)Nz	^pattern$s	^pattern$)
r1r�rr}rr�rrr3r�)r�flagrrr�
test_flags9s
  �zReTests.test_flagscCs<dD]�}|dkr^|�t�d|t|���|�t�d|t|�d��|�t�d|t|�d��|�t�d|t|���|�t�d	|t|�d��|�t�d
|t|�d��|dkr�|�t�d
|t|���|�t�d|t|�d��|�t�d|t|�d��|�t�d|t|���|�t�d|t|�d��|�t�d|t|�d��q|�t�dd��|�t�dd��|�t�dd��|�t�dd��|�ddd�|�ddd �|�d!d"d�|�d#d"d�|�d$d%d�|�d&d%d�|�d'd(d�|�d)d(d�|�d*d+d�dS),N�rr|�� �@�rQr/r-�r.i��r-�\%03o�\%03o0�0�\%03o8�8�\x%02x�\x%02x0�\x%02xz�zr.z\u%04xz\u%04x0z\u%04xzz\U%08xz\U%08x0z\U%08xzr�r�r�r�z\01r�z\018z8z\567�0octal escape value \567 outside of range 0-0o377rz\911�invalid group reference 91rMz\x1�incomplete escape \x1z\x1zz\u123�incomplete escape \u123z\u123zz	\U0001234�incomplete escape \U0001234z
\U0001234zz
\U00110000�bad escape \U00110000�rr1rUr�r:�rr�rrr�test_sre_character_literals?s> �z#ReTests.test_sre_character_literalscCs�dD]�}|dkrp|�t�d|t|���|�t�d|t|���|�t�d|t|���|�t�d|t|���|�t�d|t|���|�t�d|t|���|�t�d	|t|���|�t�d
|t|���|dkr�|�t�d|t|���|�t�d
|t|���|�t�d|t|���|�t�d|t|���|�t�d|t|�d��|�t�d|t|�d��q|�ddd�|�ddd�|�ddd�|�ddd�|�ddd�|�dd d�|�t�d!d"��dS)#Nr�r-�[\%o]�[\%o8]�[\%03o]�[\%03o0]�[\%03o8]�[\x%02x]�	[\x%02x0]�	[\x%02xz]r.z[\u%04x]z	[\u%04x0]z	[\u%04xz]z[\U%08x]z	[\U%08x0]r�z	[\U%08xz]r�z[\567]r�rMz[\911]�
bad escape \9z[\x1z]r�z[\u123z]r�z[\U0001234z]r�z[\U00110000]r�z[\U0001d49c-\U0001d4b5]u𝒞r�r�rrr�!test_sre_character_class_literals_s6 �z)ReTests.test_sre_character_class_literalscCs�dD]j}|�t�d|��t|g���|�t�d|��t|g�d��|�t�d|��t|g�d��|�t�d|��t|g���|�t�d|��t|g�d��|�t�d	|��t|g�d
��q|�tjtjd�|�tjtjd�|�t�d
d��|�t�dd��|�t�dd��|�t�dd��|�ddd�|�ddd�|�ddd�|�ddd�dS)N�rr|r�r�r�r�rQr/r�r��0r��8r�r�r��zs\u1234s
\U00012345s\0�s\08s8s\01�s\018s8s\567r�rs\911r�rMs\x1r�s\x1z�	rr1rUrqr`r0r2r3r:r�rrr�test_sre_byte_literals{s( $$ $&�zReTests.test_sre_byte_literalscCs\dD]�}|�t�d|��t|g���|�t�d|��t|g���|�t�d|��t|g���|�t�d|��t|g���|�t�d|��t|g���|�t�d|��t|g���|�t�d|��t|g���|�t�d	|��t|g���q|�tjtjd
�|�tjtjd�|�dd
d�|�ddd�|�ddd�dS)Nr�r�r�r�r�r�r�r�r�s[\u1234]s[\U00012345]s[\567]r�rMs[\911]r�s[\x1z]r�r�r�rrr�test_sre_byte_class_literals�s"       "�z$ReTests.test_sre_byte_class_literalscCsf|�ddd�|�ddd�|�ddd�|�ddd�|�ddd	�|�d
dd	�|�dd
d	�dS)Nr!zunterminated character setrz[^z[az[a-z[\w-b]zbad character range \w-brMz[a-\w]zbad character range a-\wz[b-a]zbad character range b-a�r:rVrrr�test_character_set_errors�sz!ReTests.test_character_set_errorscCsR|�t�dd��d�d�|�t�dd��d�d�|�t�dd��d�d�dS)Nz(a)|(b)rErMr�)r�r�)r-r1rU�start�endrSrVrrr�test_bug_113254�szReTests.test_bug_113254cCsp|�t�dd�j�|�t�dd�jd�|�t�dd�jd�|�t�dd�jd�|�t�dd�jd�dS)	Nz(a)?ar\z(a)(b)?br�rMz(?P<a>a)(?P<b>b)?bz(?P<a>a(b))z((a)))rTr1rU�	lastindexr-�	lastgrouprVrrr�test_bug_527371�s
zReTests.test_bug_527371cCs�|�t�dddd��d�d�|�t�dddd	ddd
��d�d�|�t�ddd
d��d�d�|�t�dddd��d�d�dS)Nz.*?cr4r�r�ri!Nz.*?cdi�r�Zcdei#Ni Nr��deia�z(a|b)*?c)r-r1rUr�rRrVrrr�test_bug_418626�s"(�"&zReTests.test_bug_418626cCs,dt�d�d}|�t�|�odd�dS)Nr!u‹r rM)r1rir-r3r�rrr�test_bug_612074�szReTests.test_bug_612074cCsf|�t�ddd��d�d�|�t�dddd��d�d�|�t�dddd��d�d�dS)Nz(x)*iP�r(rMz(x)*yr)z(x)*?yrOrVrrr�test_stack_overflow�s"&zReTests.test_stack_overflowcCsDdD]}dD]}|�d||fdd�|�d||fdd�qqdS)N��*�+�?�{1,2}�r�r�z%s%sznothing to repeatrz(?:%s%s)rNr�)r�reps�modrrr�test_nothing_to_repeat�s����zReTests.test_nothing_to_repeatcCsZdD](}dD]#}||}dD]}dD]}||}|�d||fddt|��qqqqdS)N)r�r�r�r�r�zx%s%szmultiple repeatrM)r:r�)rZ
outer_repsZ	outer_mod�outer_opZ
inner_repsZ	inner_mod�inner_oprrr�test_multiple_repeat�s�����zReTests.test_multiple_repeatcCsp|�t�dd��|�t�dd��|�t�dd��|�t�dd��|�t�dd��|�t�dd��dS)Nz(?:a?)*yr�z(?:a?)+yz(?:a?){2,}yz	(?:a?)*?yz	(?:a?)+?yz(?:a?){2,}?y)rTr1rUrVrrr� test_unlimited_zero_width_repeat�sz(ReTests.test_unlimited_zero_width_repeatcCstdd�}dd�}dd�}dd�}td	|fd
|fd|fd|fd
g�}|�|j�d�j�|�|�d�gd�df�dS)NcSs|Sr
r��scanner�tokenrrr�s_ident�rnz%ReTests.test_scanner.<locals>.s_identcSsd|S)Nzop%srr�rrr�
s_operator��z(ReTests.test_scanner.<locals>.s_operatorcS�t|�Sr
)�floatr�rrr�s_float�r�z%ReTests.test_scanner.<locals>.s_floatcSr�r
)rXr�rrr�s_int�r�z#ReTests.test_scanner.<locals>.s_intz[a-zA-Z_]\w*z\d+\.\d*rez=|\+|-|\*|/)z\s+Nr�zsum = 3*foo + 312.50 + bar)	�sumzop=rNzop*�foo�op+g�s@r�Zbar)rrr�r/r-�scan)rr�r�r�r�r�rrr�test_scanner�s"���zReTests.test_scannercCsFdD]}|�t�d|d���d�|�t�d|d���d�qdS)N)r�r�r�z
((.%s):)?zr�rza:z)r�r\�r-r1rUr�)r�oprrr�test_bug_448951s���zReTests.test_bug_448951cCs�|�t�dd���d�|�t�dd���d�|�t�dd���d�|�t�dd���d�|�t�d	d���d�|�t�d
d���d�|�t�dd���d�|�t�d
d���d�dS)Nz	^((a)|b)*r�r�z^(([ab])|c)*)r�rEz^((d)|[ab])*�rENz
^((a)c|[ab])*z^((a)|b)*?cz^(([ab])|c)*?dr�z^((d)|[ab])*?cz^((a)c|[ab])*?cr�rVrrr�test_bug_725106	s0��������zReTests.test_bug_725106cCs4|�t�dd���d�|�t�dd���d�dS)Nz(a)(?:(?=(b)*)c)*r�)r\Nz(a)((?!(b)*))*r�r�rVrrr�test_bug_725149s��zReTests.test_bug_725149cCs2Gdd�dt�}t�|d��}|�|�d��dS)Nc@seZdZdS)z+ReTests.test_bug_764548.<locals>.my_unicodeN)rrrrrrr�
my_unicode%sr�r�r])rZr1r3rTrU)rr�r�rrr�test_bug_764548#szReTests.test_bug_764548cCs�t�dd�}|�dd�|D�gd��t�d�}|�ddd�}|�dd�|D�gd��t�d�}|jdddd	�}|�d
d�|D�gd��t�d�}|jdddd�}|�dd�|D�gd��t�d�}|jdd
dd	�}|�dd�|D�ddg�dS)Nr�r�cS�g|]}|�d��qSr��rY�r��itemrrr�
<listcomp>+�z)ReTests.test_finditer.<locals>.<listcomp>r�rMrwcSr�r�r�r�rrrr�0r�r�cSr�r�r�r�rrrr�5r�)r�r6cSr�r�r�r�rrrr�:r�rNr|cSr�r�r�r�rrrr�?r�r�)r1rBr-r3)r�iterr�rrr�
test_finditer)s0�
�
�
�
�zReTests.test_finditercCs|�t�d�t�d��dS)NZ
bug_926075s
bug_926075)ZassertIsNotr1r3rVrrr�test_bug_926075Bs�zReTests.test_bug_926075cCs$d}|�t�|��d�gd��dS)Nu[.。.。]za.b.cr�)r-r1r3r�r�rrr�test_bug_931848Fs�zReTests.test_bug_931848cCsdt�dd�}|�t|���d�|�tt|�t�d��d�}|�|�	���d�|�
|�	��dS)Nz\sr8)rMr�)r1rBr-�nextrSr0�
StopIterationr3r�rRrT)rr�r�rrr�test_bug_581080KszReTests.test_bug_581080cCsFt�dd�}|�t|���d�|�t|���d�|�tt|�dS)Nz.*Zasdfr�)r�r�)r1rBr-r�rSr0r�)rr�rrr�test_bug_817234TszReTests.test_bug_817234cCsTgd�}|D]}|�t�d|��d�|�qgd�}|D]}|�t�d|��qdS)N)�7u๘u0z^\d$r)uⅥu〹u₂u㊴)r-r1rUrYrT)rZdecimal_digitsr(Znot_decimal_digitsrrr�
test_bug_6561Zs�zReTests.test_bug_6561cCsRddl}dD] }|�|�}|�t�d��|��|�t�d��|���d�qdS)NrZbBuhHiIlLfdsblar�r)�arrayrTr1r3rUr-r�)rr��typecoder\rrr�test_empty_arrayos
�zReTests.test_empty_arrayc	Csd}d}t�d|tjtjB�}|�d|�}|�|�t�d|tjtjB�}|�d|�}|�|�t�d|tj�}|�d|�}|�|�t�d|tj�}|�d|�}|�|�t�d|�}|�d|�}|�|�t�d|�}|�d|�}|�|�t�d|�}|�d|�}|�|�t�d|�}|�d|�}|�|�|�t�d||��|�t�d||��|�t�d	||tj��|�t�d
||��|�t�d||tj��|d}|�t��}|�t�||��Wd�n	1�swY|�	t
|jd
j�d|�|�	|jd
j
t�|dd}|�t��}|�t�||��Wd�n	1�s@wY|�	t
|jd
j�d|dd��|�	|jd
j
t�t���Gt�dt�d}|�t��}|�t�|d��Wd�n	1�s�wY|�	t
|jd
j�d|�|�	|jd
j
t�Wd�n	1�s�wY|�t��|�t�d|d|��Wd�n	1�s�wY|�t��|�t�d|d|��Wd�n	1�s�wY|�t��|�t�d||��Wd�n	1�swY|�t��|�t�d||��Wd�n	1�s8wY|�t��|�t�d||��Wd�n	1�sYwY|�t��}|�t�d|d|��Wd�n	1�s|wY|�t
|jd
j�d�|�	|jd
j
t�|�t��}|�t�d|d|��Wd�n	1�s�wY|�t
|jd
j�d�|�	|jd
j
t�|�t��}|�t�d|d|��Wd�n	1�s�wY|�t
|jd
j�d�|�	|jd
j
t�dS) NuẠuạrhroz(?i).z(?is).z	(?s)(?i).z(?ix) z (?i) z
(?x) (?i) z (?x) (?i) z(?i)rz+Flags not at the start of the expression %rz(?i)%sz�.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?.?z7Flags not at the start of the expression %r (truncated)�r2sA(?i)r@z	(?s).(?i)z(?i) z (?x)z^(?i)z$|(?i)z(?:(?i)rzFlags not at the startz
(^)?(?(1)(?i)z($)?(?(1)|(?i))r1r3r�rrUrr}rb�DeprecationWarningr-rZ�warnings�message�filename�__file__�catch_warnings�simplefilter�BytesWarning�assertRegexr�)rZ
upper_charZ
lower_charr�qZwarnsrrr�test_inline_flagsws�







����
����������������zReTests.test_inline_flagscCs�t�d�}|�|�dd�d�|�|�dd�d�|�|�dd�d�t�dtj�}|�|�dd�d	�|�|�dd�d
�|�|�dd�d�dS)z>$ matches the end of string, and just before the terminating 
�$�#za
b
za
b#
#za
b
cza
b
c#roz#
#za#
b#
#za#
b#
c#N)r1r3r-r<r�r�rrr�test_dollar_matches_twice�s
z!ReTests.test_dollar_matches_twicecCs�t�d�}t�d�}|�t|jd�|�t|jd�|�t|jdd�|�t|jdd�|�t|jdd�|�t|jdd�|�t|jdd�|�t|jdd�dS)Nrh�.r�rEr�r�)r1r3r0r�rUr<)rr��bpatrrr�test_bytes_str_mixing�s

zReTests.test_bytes_str_mixingcCs�dtjfD]!}t�d|tjB�}|�|�d��t�d|�}|�|�d��qt�dtjtjB�}|�|�d��t�dtj�}|�|�d��t�dtj�}|�|�d��t�d�}|�|�d��dtjfD]!}t�d|tjB�}|�|�d��t�d	|�}|�|�d��qi|�t	tjd	tj�|�tj
tjd
�|�t	tjdtjtjB�|�t	tjdtj�|�t	tjdtj�|�tj
tjd�dS)
Nr�Àraz\wu(?a)Àz(?a)\w�����\ws(?u)\wz(?u)\wz(?au)\w)r1ryr3r�rrUrrTr0r�r2)rrr�rrr�test_ascii_and_unicode_flag�s0
z#ReTests.test_ascii_and_unicode_flagc
Cs�t��}tdd�D]@}z3t|g��|�}|��}||krWq	|�|�}t|�dkr+Wq	|�|�|kr4Wq	t�	t|g��}WqNt
tfyIYq	wd}d}t�|tj
tjB�}|rb|�|�|��t�d|tj�}|ru|�|�|��t�|tj�}|r�|�|�|��t�dtj
�}|r�|�|�|��t�d�}|r�|�|�|��t�d�}|r�|�|�|��|�ttjdtj
�|�tjtjd	�|�ttjd
tj
tjB�|�ttjdtj�|�ttjdtj
�|�tjtjd�dS)
NrQr-rMrHs(?L)rs(?L)\wr�z(?L)r�s(?a)s(?aL))�locale�getpreferredencodingr�r`rarErqr�r1ri�UnicodeErrorr�r3rr�rrUrTr0r�r2r)r�encr�r�ZsletterZbletterrr�rrr�test_locale_flagsP
�

zReTests.test_locale_flagcCs�|�t�dd��|�t�dd��|�t�ddtj��|�t�ddtj��|�t�dd��|�t�dd��|�t�dd��|�t�dd��|�t�d	d
tj��|�t�d	dtj��|�t�dd
��|�t�dd
��|�t�dd
tj��|�ddd�|�ddd�|�ddd�|�ddd�|�ddd�|�ddd�|�ddd�|�d d!d�|�d"d!d�|�d#d!d�|�d$dd�|�d%d&d'�|�d(d)d�|�d*d)d�|�d+dd�dS),Nz(?i:a)bZAbZaBz(?-i:a)bz
(?i:(?-i:a)b)z	(?x: a) br8z a bz
(?-x: a) bz abr�z\w(?a:\W)\wuàààz(?a:\W(?u:\w)\W)z\W(?u:\w)\Wz(?a)(?-a:\w)z8bad inline flags: cannot turn off flags 'a', 'u' and 'L'r|z(?i-i:a)z(bad inline flags: flag turned on and offr�z(?au:a)z9bad inline flags: flags 'a', 'u' and 'L' are incompatibler�s(?aL:a)z(?-zmissing flagrNz(?-+z(?-z�unknown flagz(?-iz	missing :z(?-i)z(?-i+z(?-izz(?i:r�r�(?i�missing -, : or )z(?i+z(?iz)rr1rUrTr�r�rr:rVrrr�test_scoped_flags@sH����zReTests.test_scoped_flagscCs�t�d�}|�|�dd�d�t�d�}|�|�dd�d�t�d�}|�|�d	d
�d�d�t�d
�}|�|�dd�d�t�d�}|�|�dd�d�t�d�}|�|�dd
�d�d�dS)Nza(\w)zb\1r�r�za(.)uaሴubሴz..cSri)NrZrrkrrrrmnrnz'ReTests.test_bug_6509.<locals>.<lambda>Za5rZsa(\w)sb\1sacsbcsa(.)sa�sb�s..cSri)N�bytesrrkrrrrmvrnsa5r)r1r3r-r<r�rrr�
test_bug_6509fs





zReTests.test_bug_6509c	Cs�ddl}dd}|�ttjdi�|�t��|�dd|gdid�Wd�n1s,wY|�t��|�idgdgg�Wd�dS1sLwYdS)Nrr�rQr\r�r)rRr0r�r1rB�
OverflowErrorr3)rrRZ
long_overflowrrr�test_deallocxs�"�zReTests.test_dealloccCs^|�t�dd��|�t�dd��|�t�dd��|�t�dd��|�t�dd��dS)Nz123.*-z123abc-u123é-u123€-u123􏿿-u
123é€􏿿-)rr1rRrVrrr�test_search_dot_unicode�s
zReTests.test_search_dot_unicodecCsPt�d�}|�|tj�t�|�}|�|tj�|�||�|�ttjd�dS)N�random patternr)r1r3�assertIsInstance�Patternr$r0r�)rr/Zsame_patternrrr�test_compile�s

zReTests.test_compilerM)�sizeZmemusecCsBd|}t�d|�}|�|�|�|��|�|�|��|�dS)Nr\r)r1rRZassertIsNotNoner-r�r�)rr rIrlrrr�test_large_search�s

zReTests.test_large_search�cCs:d|}t�dd|�\}}|�||�|�||d�dS)Nr\r�rM)r1r�r-)rr rIr��nrrr�test_large_subn�szReTests.test_large_subncCs2|�t�dd�dg�|�t�dd���d�dS)Nz	(?i)(a)\1uaa Ār\z
(?s).{1,3}uĀĀr�)r-r1rHrUrSrVrrr�test_bug_16688�szReTests.test_bug_16688cCsdd}|�t�d|���d�|�t�d|���d�|�t�d|���d�|�t�d|���d�|�t�d	|���d�|�t�d
|���d�|�ttjddd
�|�ttjddd
�|�ttjddd
�|�ttjddddd
f�dS)Nr(順z.{65535})rr�z	.{,65535}z
.{65535,}?z.{65536})rr.z	.{,65536}z
.{65536,}?�.{%d}r�rQ�.{,%d}�.{%d,}?z.{%d,%d}�)r-r1rUrSr0rr3)rr=rrr�test_repeat_minmax_overflow�s$z#ReTests.test_repeat_minmax_overflowcCs�zddlm}Wnty|�d�Ynwdd}|�t�d|d|��|�t�d|d|���d	�|�t�d
|d|��|�	t
tjd|�|�	t
tjd|�|�	t
tjd
|�dS)Nr)�	MAXREPEATz requires _sre.MAXREPEAT constantr(r&r'rMr()rr&r))rRr,�ImportError�skipTestrTr1rUr-rSr0rr3)rr,r=rrr�%test_repeat_minmax_overflow_maxrepeat�s��z-ReTests.test_repeat_minmax_overflow_maxrepeatcC�|�ddd�dS)Nz
(?P=<foo>)z#bad character in group name '<foo>'r�r�rVrrr�$test_backref_group_name_in_exception���z,ReTests.test_backref_group_name_in_exceptioncCr0)Nz
(?P<?foo>)z"bad character in group name '?foo'r�r�rVrrr�test_group_name_in_exception�r2z$ReTests.test_group_name_in_exceptioncCstdD]5}dD]0}d||d}|jt�|tj��d�dg|d�|��}|jt�|tj��d�dg|d�qqdS)N)r�r�r�z{1}r�rhZyzr])r+r_)r-r1r3rrHrq)rr�r�r/rrr�test_issue17998�s����zReTests.test_issue17998cCsdtd�fD]}t�d|�}dt|�jt|�jf}|�t|�|�qdtd�t	d�t
d�fD]}t�d|�}dt|�jt|�jf}|�t|�|�q/tt�dd��\}}d	t|�jt|�jf}|�t|�|�d
t|�jt|�jf}|�t|�|�dS)Nz
[abracadabra]z(.+)(.*?)\1z7<(%s\.)?%s object; span=\(1, 12\), match='abracadabra'>s
[abracadabra]s(.+)(.*?)\1z8<(%s\.)?%s object; span=\(1, 12\), match=b'abracadabra'>z	(aa)|(bb)zaa bbz-<(%s\.)?%s object; span=\(0, 2\), match='aa'>z-<(%s\.)?%s object; span=\(3, 5\), match='bb'>)
rr1rRr%rrr�reprrrArr"rB)rr=rlr/r	r
rrr�test_match_repr�s0�����zReTests.test_match_reprcCs|�t�dd�gd��|�t�dd�gd��|�t�dd�gd��|�t�dd�gd	��|�t�dd
d�d�|�t�dd
d�d�|�t�d
dd�d�|�t�dd�gd��|�t�dd�gd��|�dd�t�dd�D�gd��|�dd�t�dd�D�gd��dS)Nr�za::bc)r�r\r�r�r�z\b|:+)r�r\r�r�r�r�z(?<!\w)(?=\w)|:+)r�r\r�r�z(?<=\w)(?!\w)|:+)r\r�r�r�r"z	-a-::-bc-z-a---bc-z(\b|:+)z[\1]z[]a[][::][]bc[])r�r�r�r�r�z\b|\w+cS�g|]}|���qSr�rS�r�rlrrrr��z*ReTests.test_zerowidth.<locals>.<listcomp>)rK�rMrMrL�rNrN�r�r�cSr7rr8r9rrrr�
r:)rKr�r;r<)rNr�r=)r-r1r�r<rHrBrVrrr�test_zerowidth�s"���zReTests.test_zerowidthcCsjdD]0}dD]+}t�d||f�}|�d�}|�|�d�d�|�|�d�d�|�|�d	�d
�qqdS)N)�{0,}r�r�z{1,187})r?r�r�z^((x|y)%s)%sZxyyzyrZxyyrMr�r�r))r1r3rUr-rY)rr�r�r�rlrrr�
test_bug_2537s
��zReTests.test_bug_2537cCs�d}t��}t�|tj�Wd�n1swYd|_d}|�|��|�t��}t�|tj�Wd�n1s>wY|�|��|�dS)Nz(\.)(?:[ch]|py)(?(1)$|: )a�SUBPATTERN 1 0 0
  LITERAL 46
BRANCH
  IN
    LITERAL 99
    LITERAL 104
OR
  LITERAL 112
  LITERAL 121
GROUPREF_EXISTS 1
  AT AT_END
ELSE
  LITERAL 58
  LITERAL 32

 0. INFO 8 0b1 2 5 (to 9)
      prefix_skip 0
      prefix [0x2e] ('.')
      overlap [0]
 9: MARK 0
11. LITERAL 0x2e ('.')
13. MARK 1
15. BRANCH 10 (to 26)
17.   IN 6 (to 24)
19.     LITERAL 0x63 ('c')
21.     LITERAL 0x68 ('h')
23.     FAILURE
24:   JUMP 9 (to 34)
26: branch 7 (to 33)
27.   LITERAL 0x70 ('p')
29.   LITERAL 0x79 ('y')
31.   JUMP 2 (to 34)
33: FAILURE
34: GROUPREF_EXISTS 0 6 (to 41)
37. AT END
39. JUMP 5 (to 45)
41: LITERAL 0x3a (':')
43. LITERAL 0x20 (' ')
45: SUCCESS
)rr1r3�DEBUGZmaxDiffr-�getvalue)rr��out�dumprrr�test_debug_flags�)�zReTests.test_debug_flagcCs�t�d�}|�|jdddd���d�|�|jdddd���d�|�|jdddd���d�|�|jdddd�d	g�|�|jdd
d�gd��|�|j	dddd�����d�dS)
Nz(ab)Zabracadabrar{rw)r=r6r�)r{rvrvrNr�rM)r=r�)r�r�Z	racadabra)
r1r3r-rUrSr�rRrHr�r�r�rrr�test_keyword_parametersPs*
������zReTests.test_keyword_parameterscCs |�t�ddtj���d�dS)Nz[a-c]+r=rP)r-r1r�r�rSrVrrr�test_bug_20998bs zReTests.test_bug_20998c	Cs�t�tj�}|�tjtj|�dD]}z	t�tj|�Wqtjy-|�d|�Yqwt��|��|�	�t��|�	�|��dS)N��en_US.iso88591�
en_US.utf8�test needs %s locale)
r�	setlocale�LC_CTYPE�
addCleanup�Errorr.r1r#�check_en_US_iso88591�check_en_US_utf8)r�	oldlocale�locrrr�test_locale_cachinggs�zReTests.test_locale_cachingcCs�t�tjd�|�t�ddtjtjB��|�t�ddtjtjB��|�t�ddtjtjB��|�t�dd��|�t�dd��|�t�dd��dS)NrI��������(?Li)���(?Li)��(?Li)�)rrLrMrr1rUr�r�rVrrrrPy�zReTests.check_en_US_iso88591cCs�t�tjd�|�t�ddtjtjB��|�t�ddtjtjB��|�t�ddtjtjB��|�t�dd��|�t�dd��|�t�dd��dS)NrJrUrVrWrXrYrZ)	rrLrMrr1rUr�r�rTrVrrrrQ�r[zReTests.check_en_US_utf8c	Cs�t�tj�}|�tjtj|�dD]}z	t�tj|�Wqtjy-|�d|�Yqwt�tjd�t�dtjtj	B�}t�dtjtj	B�}t�dtjtj	B�}t�dtjtj	B�}|||fD]}|�
|�d��|�
|�d��|�
|�d	��qb|�|�d
��|�|�d��|�|�d	��t�tjd�|||fD]}|�
|�d��|�|�d��|�|�d	��q�|�
|�d
��|�|�d��|�|�d	��dS)NrHrKrIrUs[a�][a�]s
[az�][az�]s[^�][^�]s��s��s��rJ)
rrLrMrNrOr.r1r3r�r�rrUrT)rrRrSZp1Zp2Zp3Zp4rrrr�test_locale_compiled�s8�zReTests.test_locale_compiledcCs�|�tj��
}t�d�Wd�n1swY|j}|�|jt�|�|jd�|�|j	d�|�|j
d�|�|jd�|�|j
t|��|�dt|��|�d|j
�|�tj��
}t�d�Wd�n1sowY|j}|�|jt�|�|jd�|�|j	d�|�tj��}t�dtj�Wd�n1s�wY|j}|�|j	d�|�|j
d	�|�|jd
�|�|j
t|��|�dt|��|�dt|��dS)
Nu(€))rNrMr�z at position 3s(�))zq
                (
                    abc
                )
                )
                (
                �Mr��z at position 77z(line 5, column 17))r0r1r2r3r5rr/rZr-r6�lineno�colno�assertInr+ZassertNotInr`r�)rr8r9rrr�
test_error�s>����zReTests.test_errorcCs�|�ddd�|�ddd�|�ddd�|�dd	d
�|�ddd
�|�ddd
�|�ddd
�|�ddd�|�dd	d
�|�ddd
�|�dd	d�dS)Nr�r�rz((a|b)z(a|b))zunbalanced parenthesisr�z(?Pzunexpected end of patternrNz(?z)zunknown extension ?zrMz(?iz)rrrz(?#abczmissing ), unterminated commentz(?<z(?<>)zunknown extension ?<>z(?r�r�rVrrr�test_misc_errors�szReTests.test_misc_errorscCs(|�dttj��|�dttj��dS)Nrr6)rarZr1r�rrVrrr�	test_enum�szReTests.test_enumcCs�t�dtj�}|�||�|�||k�t��t�dtj�}|�t|�t|��|�||�t��t�dtj�}|�||�t��t�d�}|�||�|�t	��
||kWd�dS1sdwYdS)Nr�ZXYZ)
r1r3r�r-r+r#�hash�assertNotEqualr0r�)r�pattern1�pattern2�pattern3Zpattern4rrr�test_pattern_compare�s 

"�zReTests.test_pattern_comparecCs�t�d�}t��t�d�}|�t|�t|��|�||�t��t�d�}t���t�dt�|�	||�Wd�dS1sCwYdS)Nrr�r2)
r1r3r#r-rer�r�r�r�rf)rrgrhrirrr�test_pattern_compare_bytes�s



"�z"ReTests.test_pattern_compare_bytescCsptd�}t�d|�}t�d|�}|�|��d�|�|��d�d|dd�<|�|��d�|�|��d�dS)Nsabcdefghs[a-h]+s[e-h]+sefghr_r�)rAr1rRr-rY)rrIrlZm2rrr�test_bug_29444szReTests.test_bug_29444cCs d}d}|�t�||���d�d}d}|�t�||�ddg�|�dd	�t�||�D�dd
g�d}d}|�t�||�d
dg�|�dd	�t�||�D�ddd�ddd�g�d}|�dd	�t�||�D�ddd�ddd�g�d}|�dd	�t�||�D�ddd�ddd�ddd�g�dS)Nza	xz\b(?=(\t)|(x))x)Nr(r�z(?=(.)(.)?)r�)rEr�cSr7r)r�r9rrrr�'r:z*ReTests.test_bug_34294.<locals>.<listcomp>r�z1(?=<(?P<tag>\w+)/?>(?:(?P<text>.+?)</(?P=tag)>)?)z<test><foo2/></test>)r~�<foo2/>)�foo2r�cSr7r�rr9rrrr�/r:r~rm)�tagrgrnz<test>Hello</test><foo/>cSr7rror9rrrr�3r:ZHellor�z<test>Hello</test><foo/><foo/>cSr7rror9rrrr�7r:)r-r1rRr�rHrBrdrrr�test_bug_34294sD���������zReTests.test_bug_34294r
)�rrrr.r:r>rGrJrWr[r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrrrrrr$r)r,r2r5r7r;r<rGrIrNrPrr[r^rerfr1r�rhr=rV�digitsrjrlrrrtrvr~r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrr
rrrrrrrrr!r$r%r+r/r1r3r4r6r>r@rErFrGrTrPrQr\rbrcrdrjrkrlrqrrrrrs



		*0&5!,%
$ $!
-
�
	 
			f
-&









5		 $

rc@steZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�ZdS)�PatternReprTestscCs|�tt�|��|�dSr
�r-r5r1r3)rr/r�rrr�check>szPatternReprTests.checkcCs|�tt�||��|�dSr
rt)rr/rr�rrr�check_flagsAszPatternReprTests.check_flagscC�|�dd�dS)Nr�re.compile('random pattern')�rurVrrr�test_without_flagsD��z#PatternReprTests.test_without_flagscC�|�dtjd�dS)Nrz+re.compile('random pattern', re.IGNORECASE))rvr1r�rVrrr�test_single_flagH�
�z!PatternReprTests.test_single_flagcCs |�dtjtjBtjBd�dS)Nrz@re.compile('random pattern', re.IGNORECASE|re.DOTALL|re.VERBOSE))rvr1r�rr}rVrrr�test_multiple_flagsLs�z$PatternReprTests.test_multiple_flagscCs0|�dtjd�|�dtjtjBtjBd�dS)Nrrxz5re.compile('random pattern', re.IGNORECASE|re.DOTALL))rvr1rr�rrVrrr�test_unicode_flagQs
��z"PatternReprTests.test_unicode_flagcCrw)Nz(?i)patternz(re.compile('(?i)pattern', re.IGNORECASE)ryrVrrrrXr{z"PatternReprTests.test_inline_flagscCs&|�ddd�|�ddtjBd�dS)Nri0z&re.compile('random pattern', 0x123000)z4re.compile('random pattern', re.IGNORECASE|0x123000))rvr1r�rVrrr�test_unknown_flags\s��z#PatternReprTests.test_unknown_flagscCs |�dd�|�dtjd�dS)N�
bytes patternzre.compile(b'bytes pattern')z&re.compile(b'bytes pattern', re.ASCII))rurvr1r�rVrrr�
test_bytesbs�
�zPatternReprTests.test_bytescCr|)Nr�z're.compile(b'bytes pattern', re.LOCALE))rvr1r�rVrrr�test_localehr~zPatternReprTests.test_localecCs(|�dd�|�dd�|�dd�dS)Nzrandom "double quoted" patternz,re.compile('random "double quoted" pattern')zrandom 'single quoted' patternz,re.compile("random 'single quoted' pattern")z!both 'single' and "double" quotesz1re.compile('both \'single\' and "double" quotes')ryrVrrr�test_quotesls���zPatternReprTests.test_quotescCs�ddd}tt�|��}|�t|�d�|�|dd�d�tt�|tj��}|�t|�d�|�|dd�d�|�|dd�d�dS)	NzVery %spatternzlong r�i,�zre.compile('Very long long loni�z, re.IGNORECASE))r5r1r3Z
assertLessr�r-r�)rr/r�rrr�test_long_patterntsz"PatternReprTests.test_long_patterncCs�|�ttj�d�|�ttjtjBtjB�d�|�ttjtjBtjBdB�d�|�ttj�d�|�ttjtjBtjB�d�|�ttjtjBtjBdB�d�dS)Nz
re.IGNORECASEz"re.IGNORECASE|re.DOTALL|re.VERBOSEiz+re.IGNORECASE|re.DOTALL|re.VERBOSE|0x100000z~re.IGNORECASEz%~(re.IGNORECASE|re.DOTALL|re.VERBOSE)z.~(re.IGNORECASE|re.DOTALL|re.VERBOSE|0x100000))r-r5r1r�rr}rVrrr�test_flags_repr~s����z PatternReprTests.test_flags_reprN)rrrrurvrzr}rr�rr�r�r�r�r�r�rrrrrs=s
rsc@s8eZdZdZedd��Zdd�Zdd�Zedd	��Zd
S)�ImplementationTestz7
    Test implementation details of the re module.
    cCs�|�t��dtj_Wd�n1swY|�t��dtj_Wd�n1s-wY|�t��t�d�}t|�d��}d|_Wd�dS1sRwYdS)NrMr�)	r0r�r1�Matchr�rr3r%r�)rr��tprrr�test_immutable�s
�
�
"�z!ImplementationTest.test_immutablecCs|tj}|�|d�g�|�|d�dg�|�|d�gd��|�|d�gd��|�|d�gd	��|�|d
�gd��dS)Nr�r\rr�)rrrrZaaaa)rrMr�rNZababba)rrrMr�rrMZabcabdac)rrrrMr�rrMr)�sre_compile�_generate_overlap_tabler-)r�frrr�test_overlap_table�sz%ImplementationTest.test_overlap_tablecCs |�tjd�|�tjd�dS)Nr)ZassertGreaterEqualr�r,rrVrrr�test_signedness�sz"ImplementationTest.test_signednesscCs:t|tj�t|tj�t�d�}t|t|�d���dS)Nr�)rr1r�rr3r%r�r�rrr�test_disallow_instantiation�s
z.ImplementationTest.test_disallow_instantiationN)	rrr�__doc__rr�r�r�r�rrrrr��s
	r�c@r�)�
ExternalTestscCs�ddlm}|D]o\}}|j||d��\t�|�}|�|�|��|�|�|��|�|�|��dd|dd}|�|�|��|�|�|d��|�|�|ddt	|���|�|�|ddt	|���Wd�n1srwYqdS)zre_tests benchmarksr)�
benchmarks�r/r=r
r4N)
�
test.re_testsr�r4r1r3rrRrUr�r�)rr�r/rIr�s2rrr�test_re_benchmarks�s
���z ExternalTests.test_re_benchmarkscCsddlm}m}m}|D�]�}d}}}}}	t|�dkr'|\}}}}}	nt|�dkr3|\}}}ntd|��|j||d����||krh|�tj	��
t�
|�Wd�n1s[wY	Wd�qt�
|�}
|
�|�}||kr�|�|d�	Wd�q|���y|�
|d	�|�d�\}}
|�d�|��|jjd
�}tdd�D]!}z
|�|�}|dur�d
}Wnty�d}Ynw||d|<q�|jj��D]}z
|�|�}|dur�d
}Wnty�d}Ynw|||<q�|�t||�|	d�Wd�n	1�swYzt|d�}t|d�}Wn
t�y YnPw|�d��t�
|�}
|�
|
�|��Wd�n	1�s?wY|�d��t�
|tj�}
|
�|�}|du�r`td|�Wd�n	1�skwY|dd�dk�r�|dd�dk�r�|du�r�|�d��t�
|�}
|�
|
�|||
d��Wd�n	1�s�wY|�d��t�
|tj�}
|�
|
�|��Wd�n	1�s�wY|�d��t�
|tj�}
|�
|
�|��Wd�n	1�s�wYWd�n	1�swYqdS)zre_tests test suiter)�tests�FAIL�SYNTAX_ERRORNr�rNz%Test tuples should have 3 or 5 fieldsr�zSucceeded incorrectlyzFailed incorrectly)�foundr�rrM�d�NonerOzg%dzgrouping errorrpzbytes pattern matchzlocale-sensitive matchz#=== Fails on locale-sensitive matchr�r*���zrange-limited matchzcase-insensitive matchzunicode-sensitive match)r�r�r�r�r�r�r4r0r1r2r3rRrTrrSrYrr�r�r�keysr-�evalr`�UnicodeEncodeErrorr�printr�ry)rr�r�r��tr/rI�outcomer;r��obj�resultr�r�Zvardictr�Zgir�bsrrr�
test_re_tests�s�

��

�
�
��
��
��
�
�


��$
�
�������zExternalTests.test_re_testsN)rrrr�r�rrrrr��sr��__main__)Ztest.supportrrrrrrrr1r�r=Zunittestr�r�weakrefr	rZrr`rZTestCaserrsr�r�r�mainrrrr�<module>sD 2N'q�
© 2025 GrazzMean