
    BThP                     p    d dl mZmZ d dlmZ d dlmZmZ d dlZd dl	m
Z
  ed       G d d	             Zy)
    )	dataclassfield)Path)IteratorOptionalN)PYTEST_NODE_SEPT)frozenc                      e Zd ZU ded<    ed      Zee   ed<    ed      Zeed<    ed      Z	eed<    ed      Z
eed<    ed      Zeed	<   d dZd dZd dZed
efd       Zed
ee   fd       Zed
efd       Zed
efd       Zed
efd       Zed
efd       Zed
efd       Zddd
efdZded
efdZded
ee   fdZded
efdZded
efdZded
efdZy)!PyTestLocationzpytest.ItemitemF)initnodenametestname
methodname
modulenamefilepathreturnNc                 \    | j                   r| j                         S | j                          y N)
is_doctest__attrs_post_init_doc____attrs_post_init_def__selfs    a/var/www/catia.catastroantioquia-mas.com/valormas/lib/python3.12/site-packages/syrupy/location.py__post_init__zPyTestLocation.__post_init__   s&     ??//11$$&    c           	         t        | j                  d      }t        j                  | dt	        |j                                      t        | j                  d      }t        j                  | d|j                         t        j                  | d|j                         t        j                  | dt        | j                  dd              t        j                  | d| j                  xs | j                         y )	Npathr   objr   r   r   namer   )
getattrr   object__setattr__strabsolute
__module____name__r   r   )r   	node_pathr    s      r   r   z&PyTestLocation.__attrs_post_init_def__$   s    !$))V4	4S1C1C1E-FGdii'4s~~>4s||<4WTYY-MN4T]]-MdooNr   c                 P   t        | j                  d      }t        j                  | d|j                         | j
                  j                  t              \  }}t        |      }t        j                  | ddj                  g |j                  j                  |j                               t        j                  | dd        t        j                  | d|j                  | j                   dd             t        j                  | d| j                  xs | j                          y )	Ndtestr   r   .r   r    r   )r"   r   r#   r$   filenamenodeidsplitr   r   joinparentpartsstemreplacer   r   r   )r   doctesttest_relfile	test_nodetest_relpaths        r   r   z&PyTestLocation.__attrs_post_init_doc__.   s    $))W-4W-=-=>"&++"3"3O"DiL)HHD|**00D,2C2CDE	

 	4t4*i//4??2C10ErJ	
 	4T]]-MdooNr   c                 8    | j                   j                  d      S )N])r/   endswithr   s    r   is_item_parametrizedz#PyTestLocation.is_item_parametrized?   s    {{##C((r   c                     | j                   ry dj                  | j                  j                  t              dd       xs d S )Nr,      )r   r1   r/   r0   r   r   s    r   	classnamezPyTestLocation.classnameC   s6    ??xx))/:1R@AITIr   c                 @    t        t        | j                  d            S )a  
        Pytest node names contain file path and module members delimited by `::`

        Examples:
        - tests/grouping/test_file.py::TestClass::TestSubClass::test_method
        - tests/grouping/test_file.py::DocTestClass.doc_test_method
        - tests/grouping/test_file.py::doctestfile.txt

        :raises: `AttributeError` if node has no node id
        :return: test node id
        r/   )r%   r"   r   r   s    r   r/   zPyTestLocation.nodeidI   s     7499h/00r   c                 @    t        | j                        j                  S r   )r   r   r4   r   s    r   basenamezPyTestLocation.basenameX   s    DMM"'''r   c                 z    | j                   | j                    d| j                   S t        | j                        S Nr,   )rA   r   r%   r   s    r   snapshot_namezPyTestLocation.snapshot_name\   5    >>%nn%Qt}}o664==!!r   c                 z    | j                   | j                    d| j                   S t        | j                        S rF   )rA   r   r%   r   s    r   snapshot_name_parametrizedz)PyTestLocation.snapshot_name_parametrizedb   rH   r   c                 8    | j                  | j                        S r   )_PyTestLocation__is_doctestr   r   s    r   r   zPyTestLocation.is_doctesth   s      ++r   nodec                     t        |d      S )Nr+   )hasattr)r   rM   s     r   __is_doctestzPyTestLocation.__is_doctestl   s    tW%%r   r!   c                 N    d}|D ]  }| | }|j                         s |S |} |S )z
        Take characters from the name while the result would be a valid python
        identified. Example: "test_2[A]" returns "test_2" while "1_a" would return ""
        r-   )isidentifier)r   r!   valid_idcharnew_valid_ids        r   
__valid_idzPyTestLocation.__valid_ido   sH    
  	$D&Zv.L,,. $H		$
 r   c              #   t   K   |j                  d      D ]   }| j                  |      }|r| ||k7  s  y yw)z
        Break a name path into valid name parts stopping at the first non valid name.
        Example "TestClass.test_method_[1]" would yield ("TestClass", "test_method_")
        r,   N)r0   _PyTestLocation__valid_id)r   r!   nrS   s       r   __valid_idszPyTestLocation.__valid_ids|   s?     
 C 	Aq)H1}	s   188c                 B    dj                  | j                  |            S rF   )r1   _PyTestLocation__valid_ids)r   r!   s     r   __parsezPyTestLocation.__parse   s    xx((.//r   rG   c                 \    | j                  | j                        | j                  |      k(  S r   )_PyTestLocation__parserG   )r   rG   s     r   matches_snapshot_namez$PyTestLocation.matches_snapshot_name   s%    ||D../4<<3NNNr   snapshot_locationc                    t        |      }| j                  r| j                  |j                  k(  xs | j                  |j                  j
                  k(  xrm |j                  | j                  k(  xsR |j                  j                  | j                   d      xs( |j                  j                  | j                   d      S | j                  |j                  k(  xs# | j                  |j                  j
                  k(  S )Nr,   [)r   r=   rD   r4   r2   r!   rJ   
startswith)r   ra   locs      r   matches_snapshot_locationz(PyTestLocation.matches_snapshot_location   s    $%$$==CHH, 0 HH ? ?? Rxx**d.M.M-Na+PQRxx**d.M.M-Na+PQ }}(LDMMSZZ__,LLr   )r   N)r(   r'   __qualname____annotations__r   r   r   r%   r   r   r   r   r   r   r   propertyboolr=   rA   r/   rD   rG   rJ   r   rL   rX   r   r\   r_   r`   rf    r   r   r   r      s   
#/Hhsm/u%Hc%'J''J'u%Hc%	'OO" )d ) ) J8C= J J
 1 1 1 (# ( ( "s " "
 "C " "
 ,D , ,& &4 &s s 
 
 
0C 0C 0O3 O4 OM3 M4 Mr   r   )dataclassesr   r   pathlibr   typingr   r   pytestsyrupy.constantsr   r   rk   r   r   <module>rq      s@    
  , $LM LM LMr   