
    i                         d dl Z d dlmZ d dlmZ d dlmZmZ d Zd Z	d Z
e j                  j                  dg d	      d
        Zd Zy)    N)Mock)Language)get_attr_infovalidate_attrsc                     t        j                  dddg      d        } t        j                  dddgddg	      d
        }t        j                  ddgdg	      d        }t        j                  d      sJ t        j                  d      sJ t        j                  d      sJ t               }|j                  d       |j                  d       |j	                         d   }|d   dgk(  sJ |j                  d       t        |d      d   ddgk(  sJ |j                  dd       |j                  d      }|j                  dk(  sJ |j                  g dk(  sJ t        j                  d      rJ |j                  d   dk(  sJ |j                  d   dk(  sJ t        |d      d   g dk(  sJ t        |d      d   dgk(  sJ  |d      sJ y )Nc1	token.tagz
doc.tensorassignsc                     | S N docs    s/var/www/vps2.regionflexible.com/Desarrollo/venv/lib/python3.12/site-packages/spacy/tests/pipeline/test_analysis.pytest_component1z9test_component_decorator_assigns.<locals>.test_component1	       
    c2	token.posztoken.lemma)requiresr   c                     | S r   r   r   s    r   test_component2z9test_component_decorator_assigns.<locals>.test_component2   	     
r   c3ztoken._.custom_lemmac                     | S r   r   r   s    r   test_component3z9test_component_decorator_assigns.<locals>.test_component3   r   r   problemsr   c4)name)r   r   r   r   )r   r   r   r   hello world)
r   	componenthas_factoryadd_pipeanalyze_pipesr   get_pipe_metafactory
pipe_namespipe_factories)r   r   r   nlpr   test_component4_metas         r    test_component_decorator_assignsr,      s   {L&AB C [1M<;X 1G0H %%%%%%%%%
*CLLLL  ":.HD>k]***LLl+I64,FFFLLDL!,,T2''4///>>5555##D)))d#t+++d#t+++l+I6:LLLLk*:64&@@@}r   c                  4    G d d      } t                |        _        ddt        ffd}t        j                  d|       t        j
                  d      sJ t               }|j                  dddi        |d	      sJ j                  |d
       y)zTest that class components can implement a from_nlp classmethod that
    gives them access to the nlp object and config via the factory.c                       e Zd Zd Zy);test_component_factories_class_func.<locals>.TestComponent5c                     |S r   r   )selfr   s     r   __call__zDtest_component_factories_class_func.<locals>.TestComponent5.__call__5   s    Jr   N)__name__
__module____qualname__r2   r   r   r   TestComponent5r/   4   s    	r   r6   barc5fooc                      | |      S )Nr9   r   )r*   r9   r    mocks      r   test_componen5_factoryzCtest_component_factories_class_func.<locals>.test_componen5_factory;   s    CS!!r   )func)configr!   r;   N)r7   r8   )r   return_valuestrr   r'   r#   r$   assert_called_once_with)r6   r=   r*   r<   s      @r   #test_component_factories_class_funcrC   0   s      6D&(D" " T 67%%%
*CLLuenL-}  % 0r   c                      g d} t        |       sJ | D ]  }t        |g      rJ  t        j                  t              5  t        ddg       d d d        y # 1 sw Y   y xY w)N)	doc.sentszdoc.entsr	   ztoken._.xyzz
span._.xyzrE   doc.xyz)r   pytestraises
ValueError)attrsattrs     r   "test_analysis_validate_attrs_validrL   F   sb    OE%    &tf%%%&	z	" 1Y/01 1 1s    AA rK   )r   doc_entsrF   z	token.xyzz
token.tag_ztoken.tag.xyzztoken._.xyz.abcz
span.labelc                 x    t        j                  t              5  t        | g       d d d        y # 1 sw Y   y xY wr   )rG   rH   rI   r   )rK   s    r   $test_analysis_validate_attrs_invalidrO   O   s/     
z	" v  s   09c                     t        j                  ddg      d        } t        j                  ddg      d        }t               }|j                  d       |j                  d       |j                         d	   }|d   dgk(  sJ |j	                  d       |j                         d	   }t        d
 |j                         D              sJ y)z7Test that attributes are validated correctly on remove.pipe_analysis_c6r	   r
   c                     | S r   r   r   s    r   r   z4test_analysis_validate_attrs_remove_pipe.<locals>.c1d   r   r   pipe_analysis_c7r   )r   c                     | S r   r   r   s    r   r   z4test_analysis_validate_attrs_remove_pipe.<locals>.c2h   r   r   r   c              3   &   K   | ]	  }|g k(    y wr   r   ).0ps     r   	<genexpr>z;test_analysis_validate_attrs_remove_pipe.<locals>.<genexpr>s   s     21qBw2s   N)r   r"   r$   r%   remove_pipeallvalues)r   r   r*   r   s       r   (test_analysis_validate_attrs_remove_piper\   a   s     *[MB C *k]C D *CLL#$LL#$  ":.H&'K=888OO&'  ":.H2 12222r   )rG   r<   r   spacy.languager   spacy.pipe_analysisr   r   r,   rC   rL   markparametrizerO   r\   r   r   r   <module>ra      sQ      # =%P1,1 
	
3r   