relateby-pattern 0.4.2

Core pattern data structures
Documentation
�

i�}i���<�dZddlZddlmcmZd�Zd�Zd�Z	d�Z
dS)z5
Tests for Pattern construction and basic operations
�Nc���ddl}|j�d��}|j}d}||k}|s�t	jd|fd||f��dt
j��vst	j|��rt	j	|��ndt	j	|��t	j	|��d�z}dd	|iz}tt	j|�����dx}x}}|j}t|��}d}||k}	|	�st	jd|	fd
||f��dt
j��vst	jt��rt	j	t��nddt
j��vst	j|��rt	j	|��ndt	j	|��t	j	|��t	j	|��d�z}
d
d|
iz}tt	j|�����dx}x}x}	}|j}|��}d}	||	u}|s�t	jd|fd||	f��dt
j��vst	j|��rt	j	|��ndt	j	|��t	j	|��t	j	|	��d�z}dd|iz}
tt	j|
�����dx}x}x}}	dS)z1Test creating atomic pattern with Pattern.point()rN�hello��==�z-%(py2)s
{%(py2)s = %(py0)s.value
} == %(py5)s�atomic��py0�py2�py5�assert %(py7)s�py7�zN%(py5)s
{%(py5)s = %(py0)s(%(py3)s
{%(py3)s = %(py1)s.elements
})
} == %(py8)s�len�r
�py1�py3r�py8�assert %(py10)s�py10T)�is)zH%(py4)s
{%(py4)s = %(py2)s
{%(py2)s = %(py0)s.is_atomic
}()
} is %(py7)s)r
r�py4rzassert %(py9)s�py9)�pattern_core�Pattern�point�value�
@pytest_ar�_call_reprcompare�@py_builtins�locals�_should_repr_global_name�	_saferepr�AssertionError�_format_explanation�elementsr�	is_atomic)rr�@py_assert1�@py_assert4�@py_assert3�@py_format6�@py_format8�@py_assert2�@py_assert7�@py_assert6�@py_format9�@py_format11�@py_assert5�@py_format10s              �^/Users/akollegger/Developer/gram-data/gram-rs/crates/pattern-core/tests/python/test_pattern.py�test_pattern_pointr5sG������
�
!�
'�
'��
0�
0�F��<�"�7�"�<�7�"�"�"�"�"�"�"�"�"�"�<�7�"�"�"�"�"�"�"�"�"�"�"�"�6�"�"�"�"�"�6�"�"�"�"�"�"�<�"�"�"�"�7�"�"�"�"�"�"�"�"�"�"�"�"�"�"�"�"�"�"�"�"�"�"�"�"�"�"�"���$�3����$�1�$��1�$�$�$�$�$�$�$�$�$�$��1�$�$�$�$�$�$�$�$�$�$�$�$�3�$�$�$�$�$�3�$�$�$�$�$�$�$�$�$�$�$�$�$�v�$�$�$�$�$�v�$�$�$�$�$�$��$�$�$�$��$�$�$�$�1�$�$�$�$�$�$�$�$�$�$�$�$�$�$�$�$�$�$�$�$�$�$�$�$�$�$�$�$�$���%�����%��%���%�%�%�%�%�%�%�%�%�%���%�%�%�%�%�%�%�%�%�%�%�%�6�%�%�%�%�%�6�%�%�%�%�%�%��%�%�%�%��%�%�%�%��%�%�%�%�%�%�%�%�%�%�%�%�%�%�%�%�%�%�%�%�%�%�%�%�%�%�%�%�%�%�%�c�"�ddl}|j�d��}|j�d��}|j�d||g��}|j}d}||k}|s�tjd|fd||f��dtj��vstj	|��rtj
|��ndtj
|��tj
|��d�z}d	d
|iz}ttj|�����dx}x}}|j
}	t|	��}d}
||
k}|�stjd|fd||
f��d
tj��vstj	t��rtj
t��nd
dtj��vstj	|��rtj
|��ndtj
|	��tj
|��tj
|
��d�z}dd|iz}
ttj|
�����dx}	x}x}}
|j
d}|j}	d}|	|k}|stjd|fd|	|f��tj
|��tj
|	��tj
|��d�z}dd|iz}ttj|�����dx}x}	x}}|j
d}|j}	d}|	|k}|stjd|fd|	|f��tj
|��tj
|	��tj
|��d�z}dd|iz}ttj|�����dx}x}	x}}dS)z3Test creating nested pattern with Pattern.pattern()rN�child1�child2�parentrrr	r
r�rrrrr�z-%(py3)s
{%(py3)s = %(py1)s.value
} == %(py6)s�rr�py6�assert %(py8)sr�)rrr�patternrrrr r!r"r#r$r%r&r)rr8r9r:r(r)r*r+r,r-r.r/r0r1�@py_assert0r2�@py_format7s                 r4�test_pattern_patternrDs������
�
!�
'�
'��
1�
1�F�
�
!�
'�
'��
1�
1�F�
�
!�
)�
)�(�V�V�4D�
E�
E�F��<�#�8�#�<�8�#�#�#�#�#�#�#�#�#�#�<�8�#�#�#�#�#�#�#�#�#�#�#�#�6�#�#�#�#�#�6�#�#�#�#�#�#�<�#�#�#�#�8�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#���$�3����$�1�$��1�$�$�$�$�$�$�$�$�$�$��1�$�$�$�$�$�$�$�$�$�$�$�$�3�$�$�$�$�$�3�$�$�$�$�$�$�$�$�$�$�$�$�$�v�$�$�$�$�$�v�$�$�$�$�$�$��$�$�$�$��$�$�$�$�1�$�$�$�$�$�$�$�$�$�$�$�$�$�$�$�$�$�$�$�$�$�$�$�$�$�$�$�$�$��?�1��/��#�/�x�/�#�x�/�/�/�/�/�/�/�/�/�/�#�x�/�/�/�/�/��/�/�/�/�#�/�/�/�/�x�/�/�/�/�/�/�/�/�/�/�/�/�/�/�/�/�/�/�/�/�/�/�/�/�/�/�/�/�/��?�1��/��#�/�x�/�#�x�/�/�/�/�/�/�/�/�/�/�#�x�/�/�/�/�/��/�/�/�/�#�/�/�/�/�x�/�/�/�/�/�/�/�/�/�/�/�/�/�/�/�/�/�/�/�/�/�/�/�/�/�/�/�/�/�/�/r6c��ddl}|j�d|j�d��|j�d��|j�d��g��}|j}d}||k}|s�tjd|fd||f��d	tj��vstj	|��rtj
|��nd	tj
|��tj
|��d
�z}dd|iz}ttj|�����dx}x}}|j
}t|��}d
}||k}	|	�stjd|	fd||f��dtj��vstj	t��rtj
t��ndd	tj��vstj	|��rtj
|��nd	tj
|��tj
|��tj
|��d�z}
dd|
iz}ttj|�����dx}x}x}	}|j
d}|j}d}
||
k}|stjd|fd||
f��tj
|��tj
|��tj
|
��d�z}dd|iz}
ttj|
�����dx}x}x}}
|j
d}|j}d}
||
k}|stjd|fd||
f��tj
|��tj
|��tj
|
��d�z}dd|iz}
ttj|
�����dx}x}x}}
|j
d}|j}d}
||
k}|stjd|fd||
f��tj
|��tj
|��tj
|
��d�z}dd|iz}
ttj|
�����dx}x}x}}
dS)z)Test creating pattern from list of valuesrN�root�a�b�crrrAr	r
r�rrrrrr<r=r?rr@r;)rrrArrrrr r!r"r#r$r%r&r)rrAr(r)r*r+r,r-r.r/r0r1rBr2rCs               r4�test_pattern_from_listrKs��������"�*�*�6���"�"�3�'�'���"�"�3�'�'���"�"�3�'�'�4���G��=�"�F�"�=�F�"�"�"�"�"�"�"�"�"�"�=�F�"�"�"�"�"�"�"�"�"�"�"�"�7�"�"�"�"�"�7�"�"�"�"�"�"�=�"�"�"�"�F�"�"�"�"�"�"�"�"�"�"�"�"�"�"�"�"�"�"�"�"�"�"�"�"�"�"�"���%�3�� � �%�A�%� �A�%�%�%�%�%�%�%�%�%�%� �A�%�%�%�%�%�%�%�%�%�%�%�%�3�%�%�%�%�%�3�%�%�%�%�%�%�%�%�%�%�%�%�%�w�%�%�%�%�%�w�%�%�%�%�%�%��%�%�%�%� �%�%�%�%�A�%�%�%�%�%�%�%�%�%�%�%�%�%�%�%�%�%�%�%�%�%�%�%�%�%�%�%�%�%���A��+��$�+��+�$��+�+�+�+�+�+�+�+�+�+�$��+�+�+�+�+��+�+�+�+�$�+�+�+�+��+�+�+�+�+�+�+�+�+�+�+�+�+�+�+�+�+�+�+�+�+�+�+�+�+�+�+�+�+���A��+��$�+��+�$��+�+�+�+�+�+�+�+�+�+�$��+�+�+�+�+��+�+�+�+�$�+�+�+�+��+�+�+�+�+�+�+�+�+�+�+�+�+�+�+�+�+�+�+�+�+�+�+�+�+�+�+�+�+���A��+��$�+��+�$��+�+�+�+�+�+�+�+�+�+�$��+�+�+�+�+��+�+�+�+�$�+�+�+�+��+�+�+�+�+�+�+�+�+�+�+�+�+�+�+�+�+�+�+�+�+�+�+�+�+�+�+�+�+�+�+r6c�`�ddl}ddh}|j�d��|j�d��d�}|�d||�	��}|j�|��}|j}|j}d}||k}|s�tj
d
|fd||f��dtj��vstj
|��rtj|��ndtj|��tj|��d
�z}	dd|	iz}
ttj|
�����dx}x}}|���}d}||v}
|
s�tj
d|
fd||f��tj|��dtj��vstj
|��rtj|��ndd�z}dd|iz}	ttj|	�����dx}}
d}||v}
|
s�tj
d|
fd||f��tj|��dtj��vstj
|��rtj|��ndd�z}dd|iz}	ttj|	�����dx}}
|���}|d}d}||k}
|
sltj
d
|
fd||f��tj|��tj|��d�z}dd|iz}ttj|�����dx}x}
}|d}d}||k}
|
sltj
d
|
fd||f��tj|��tj|��d�z}dd|iz}ttj|�����dx}x}
}dS)z(Test creating Pattern with Subject valuerN�Person�Employee�Alice�)�name�age�alice)�identity�labels�
propertiesr)z0%(py2)s
{%(py2)s = %(py0)s.identity
} == %(py5)s�pattern_subjectr	r
r)�in)z%(py1)s in %(py3)srU)rrzassert %(py5)srrQ)z%(py1)s == %(py4)s)rrzassert %(py6)sr>rR)r�Value�string�int�SubjectrrrrTrrr r!r"r#r$r%�
get_labels�get_properties)r�
labels_set�properties_dict�subjectrArWr(r)r*r+r,rUrBr-�@py_format4�props�@py_format5rCs                  r4�!test_pattern_subject_constructionre1sg�������J�'�J��"�)�)�'�2�2��!�%�%�b�)�)���O�
�"�"���"�#���G��"�(�(��1�1�G��m�O��#�.�w�.�#�w�.�.�.�.�.�.�.�.�.�.�#�w�.�.�.�.�.�.�.�.�.�.�.�.�?�.�.�.�.�.�?�.�.�.�.�.�.�#�.�.�.�.�w�.�.�.�.�.�.�.�.�.�.�.�.�.�.�.�.�.�.�.�.�.�.�.�.�.�.�.�
�
'�
'�
)�
)�F���8�v�����������8�v������8������������v������v������������������������������:������������:�������:�����������������������������������������������*�*�,�,�E���=�#�G�#�=�G�#�#�#�#�#�#�#�#�#�#�=�G�#�#�#�#�#�=�#�#�#�#�G�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#�#���<��2��<�2�����������<�2������<�����2�����������������������������r6)�__doc__�builtinsr �_pytest.assertion.rewrite�	assertion�rewriterr5rDrKre�r6r4�<module>rlsr����
�������������&�&�&�0�0�0�,�,�,�&����r6