
    i~                         d dl Z d dlmZ d dlZd dlmZ  ee      j                  dz  Zd dl	m
Z
 e
j                  Zd Zee
_        ej                  d        Zd Zy)	    N)Path)registryzfactory_registrations.json)utilc                 h    	 t        | |      S # t        $ r t        |       t        |      k(  cY S w xY w)N)original_is_same_func	TypeErrorstr)func1func2s     w/var/www/vps2.regionflexible.com/Desarrollo/venv/lib/python3.12/site-packages/spacy/tests/test_factory_registrations.pypatched_is_same_funcr      s6    ($UE22 (5zSZ''(s     11c                      t         j                         st        j                  dt          d       t         j	                  d      5 } t        j                  |       cddd       S # 1 sw Y   yxY w)z3Load reference factory registrations from JSON filezReference file z6 not found. Run export_factory_registrations.py first.rN)REFERENCE_FILEexistspytestfailopenjsonload)fs    r   reference_factory_registrationsr      s\       "n--cd	
 
		S	! Qyy|  s   A&&A/c                    t        j                          t         j                  j                         }i }|j	                         D ](  \  }}	 |j
                  }	 |j                  }|||d||<   * t        | j                               t        |j                               z
  }|r"J ddj                  t!        |                    t        |j                               t        | j                               z
  }|r't#        d	dj                  t!        |                    y
y
# t        t        f$ r2 t        |      j                         d   j                  d      d   }Y w xY w# t        t        f$ rJ t        |d      r|j                  n-t        |      j                         d   j                  d      d   }Y [w xY w)zNTest that all factory registrations from the reference file are still present.   .r   __name__)namemodulefunctionzMissing factory registrations: z, z!New factory registrations found: N)r   ensure_populated	factoriesget_allitems
__module__AttributeErrorr   r	   split__qualname__hasattrr   setkeysjoinsortedprint)	r   all_factoriescurrent_registrationsr   funcmodule_name	func_namemissing_registrationsnew_registrationss	            r   $test_factory_registrations_preservedr6   *   s     &&..0M  $))+ 

d	=//K
	))I !!'
d#%
2   ? D D FG#""$K  % 
)$))F;P4Q*R)ST$
 16689C',,.=  /		&AR:S0T/UV	
 A 	* 	=d)//+A.44S9!<K	= 	* 	 4, Y__&q)//4R8 	s%   D$E($=E%$E%(AG G)r   pathlibr   r   
spacy.utilr   __file__parentr   spacyr   is_same_funcr   r   fixturer   r6        r   <module>r@      se        h&&)EE )) ( )   4
r?   