
    X-Ph6                        d dl mZ d dlZd dlmZmZmZ d dlmZ d dl	m
Z
 d dlmZmZ ej                            ej                            e
d                    Z G d d	e          Z G d
 de          ZdS )    )annotationsN)FindModuleCacheModuleNotFoundReasonSearchPaths)Options)package_path)Suiteassert_equalmodulefinderc                      e Zd ZddZddZddZddZddZddZdd	Z	dd
Z
ddZddZddZddZddZddZddZdS )ModuleFinderSuitereturnNonec                   t          dt          j                            t          d          t          j                            t          d          t          j                            t          d          t          j                            t          d          t          j                            t          d          t          j                            t          d          t          j                            t          d          fdd	          | _        t                      }d
|_        t          | j        d |          | _	        t                      }d|_        t          | j        d |          | _
        d S )N nsx-pkg1nsx-pkg2nsx-pkg3nsy-pkg1nsy-pkg2pkg1pkg2python_path	mypy_pathr   typeshed_pathTfscacheoptionsF)r   ospathjoin	data_pathsearch_pathsr   namespace_packagesr   fmc_nsfmc_nons)selfr   s     Z/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/mypy/test/testmodulefinder.pysetUpzModuleFinderSuite.setUp   s	   'Y
33Y
33Y
33Y
33Y
33Y//Y// 
 
 
 ))%)"%d&7wWWW))%*"'(94QXYYY    c                n    | j                             d          }t          t          j        |           dS )zG
        If namespace_packages is False, we shouldn't find nsx
        nsxNr'   find_moduler
   r   	NOT_FOUNDr(   found_modules     r)    test__no_namespace_packages__nsxz2ModuleFinderSuite.test__no_namespace_packages__nsx%   s3     }0077)3\BBBBBr+   c                n    | j                             d          }t          t          j        |           dS )zJ
        If namespace_packages is False, we shouldn't find nsx.a.
        nsx.aNr.   r1   s     r)   "test__no_namespace_packages__nsx_az4ModuleFinderSuite.test__no_namespace_packages__nsx_a,   s3     }0099)3\BBBBBr+   c                    | j                             d          }t          j                            t          j                            t          dd                    }t          ||           dS )zL
        Find find pkg1/a.py for "a" with namespace_packages False.
        ar   a.pyN)r'   r/   r    r!   abspathr"   r#   r
   r(   r2   expecteds      r)   +test__no_namespace_packages__find_a_in_pkg1z=ModuleFinderSuite.test__no_namespace_packages__find_a_in_pkg13   sT     }00557??27<<	66#J#JKKX|,,,,,r+   c                    | j                             d          }t          j                            t          j                            t          ddd                    }t          ||           d S Nbr   __init__.pyr&   r/   r    r!   r:   r"   r#   r
   r;   s      r)   +test__no_namespace_packages__find_b_in_pkg2z=ModuleFinderSuite.test__no_namespace_packages__find_b_in_pkg2;   T    {..s337??27<<	63#V#VWWX|,,,,,r+   c                    | j                             d          }t          j                            t          j                            t          dd                    }t          ||           dS )z|
        There's no __init__.py in any of the nsx dirs, return
        the path to the first one found in mypypath.
        r-   r   NrB   r;   s      r)   'test__find_nsx_as_namespace_pkg_in_pkg1z9ModuleFinderSuite.test__find_nsx_as_namespace_pkg_in_pkg1@   sT    
 {..u557??27<<	:u#M#MNNX|,,,,,r+   c           	         | j                             d          }t          j                            t          j                            t          dddd                    }t          ||           dS )zP
        Find nsx-pkg1/nsx/a/__init__.py for "nsx.a" in namespace mode.
        r5   r   r-   r8   rA   NrB   r;   s      r)   test__find_nsx_a_init_in_pkg1z/ModuleFinderSuite.test__find_nsx_a_init_in_pkg1I   Y     {..w777??27<<	:ucS`#a#abbX|,,,,,r+   c           	         | j                             d          }t          j                            t          j                            t          dddd                    }t          ||           dS )zP
        Find nsx-pkg2/nsx/b/__init__.py for "nsx.b" in namespace mode.
        znsx.br   r-   r@   rA   NrB   r;   s      r)   test__find_nsx_b_init_in_pkg2z/ModuleFinderSuite.test__find_nsx_b_init_in_pkg2Q   rI   r+   c           	         | j                             d          }t          j                            t          j                            t          dddd                    }t          ||           dS )zK
        Find nsx-pkg3/nsx/c/c.py for "nsx.c.c" in namespace mode.
        znsx.c.cr   r-   cc.pyNrB   r;   s      r)   test__find_nsx_c_c_in_pkg3z,ModuleFinderSuite.test__find_nsx_c_c_in_pkg3Y   sY     {..y997??27<<	:ucSY#Z#Z[[X|,,,,,r+   c           	         | j                             d          }t          j                            t          j                            t          dddd                    }t          ||           dS )zG
        Prefer nsy-pkg1/a/__init__.pyi file over __init__.py.
        znsy.ar   nsyr8   __init__.pyiNrB   r;   s      r)   test__find_nsy_a__init_pyiz,ModuleFinderSuite.test__find_nsy_a__init_pyia   sY     {..w777??27<<	:ucSa#b#bccX|,,,,,r+   c           	         | j                             d          }t          j                            t          j                            t          dddd                    }t          ||           dS )z
        There is a nsy-pkg2/nsy/b.pyi, but also a nsy-pkg2/nsy/b/__init__.py.
        We expect to find the latter when looking up "nsy.b" as
        a package is preferred over a module.
        znsy.br   rQ   r@   rA   NrB   r;   s      r)   test__find_nsy_b__init_pyz+ModuleFinderSuite.test__find_nsy_b__init_pyi   sY     {..w777??27<<	:ucS`#a#abbX|,,,,,r+   c                    | j                             d          }t          j                            t          j                            t          ddd                    }t          ||           dS )z
        There is a nsy-pkg2/nsy/c.pyi and nsy-pkg2/nsy/c.py
        We expect to find the former when looking up "nsy.b" as
        .pyi is preferred over .py.
        znsy.cr   rQ   zc.pyiNrB   r;   s      r)   test__find_nsy_c_pyiz&ModuleFinderSuite.test__find_nsy_c_pyis   sV     {..w777??27<<	:ug#V#VWWX|,,,,,r+   c                    | j                             d          }t          j                            t          j                            t          dd                    }t          ||           d S )Nr8   r   r9   rB   r;   s      r)   test__find_a_in_pkg1z&ModuleFinderSuite.test__find_a_in_pkg1}   sR    {..s337??27<<	66#J#JKKX|,,,,,r+   c                    | j                             d          }t          j                            t          j                            t          ddd                    }t          ||           d S r?   rB   r;   s      r)   test__find_b_init_in_pkg2z+ModuleFinderSuite.test__find_b_init_in_pkg2   rD   r+   c                n    | j                             d          }t          t          j        |           d S )Nd)r&   r/   r
   r   r0   r1   s     r)   test__find_d_nowherez&ModuleFinderSuite.test__find_d_nowhere   s1    {..s33)3\BBBBBr+   Nr   r   )__name__
__module____qualname__r*   r3   r6   r=   rC   rF   rH   rK   rO   rS   rU   rW   rY   r[   r^   r   r+   r)   r   r      sR       Z Z Z Z.C C C CC C C C- - - -- - - -
- - - -- - - -- - - -- - - -- - - -- - - -- - - -- - - -
- - - -
C C C C C Cr+   r   c                  .    e Zd Zd
dZddZd
dZd
dZd	S )ModuleFinderSitePackagesSuiter   r   c                   t           j                            t           j                            t          d                    | _        t           j                            | j        d          t           j                            | j        dd          t           j                            | j        dd          | j        f}t          dt           j                            t          d          ft          |          d          | _	        t                      }d	|_        t          | j	        d |
          | _        t                      }d|_        t          | j	        d |
          | _        d S )Nzmodulefinder-site-packagesbaz..znot-a-directorymodulefinder-srcr   r   r   Tr   F)r    r!   relpathr"   r   package_dirr   r#   tupler$   r   r%   r   r&   r'   )r(   package_pathsr   s      r)   r*   z#ModuleFinderSitePackagesSuite.setUp   s    7??GLL'CDD
 

 GLL)511GLL)41BCCGLL)41CDD	
 (w||Iv668}--	
 
 
 ))%)"%d&7wWWW))%*"'(94QXYYYr+   partsstrc                t    t           j                            t          j        j        | j        g|R            S )N)r    r!   r:   r"   rj   )r(   rm   s     r)   r!   z"ModuleFinderSitePackagesSuite.path   s-    wrw|D,<EuEEEFFFr+   c           	     <   g d|                      d          fd|                      dd          fd|                      dd          fd|                      ddd          fdt          j        fd	t          j        fd
t          j        fdt          j        fdt          j        fdt          j        fd|                      d          fd|                      ddd          fd|                      ddd          fdt          j        fd|                      dd          fd|                      dd          fd|                      ddd          fd|                      ddd          fdt          j        fd|                      dd          fd|                      dd          fd t          j        fd!t          j        fd"t          j        fd#t          j        fd$t          j        fd%t          j        fd&t          j        fd'|                      d(d'd          fd)|                      d(d*d          fd+|                      d,d-d+d          fd.|                      d,d-d/d          fd0t          j        fd1|                      d2d3          fd4t          j                             t          j                             t          d5d                    f}|D ]8\  }}d6|z   d7z   }| j        	                    |          }t          |||           9d S )8Nns_pkg_typedns_pkg_typed.ar9   ns_pkg_typed.br@   ns_pkg_typed.b.crN   ns_pkg_typed.a.a_varns_pkg_untypedns_pkg_untyped.ans_pkg_untyped.bns_pkg_untyped.b.cns_pkg_untyped.a.a_varns_pkg_w_stubsns_pkg_w_stubs.typedzns_pkg_w_stubs-stubstypedrR   ns_pkg_w_stubs.typed_inlinetyped_inlinerA   ns_pkg_w_stubs.untyped	pkg_typedpkg_typed.apkg_typed.bpkg_typed.b.cpkg_typed.a.a_varpkg_typed_w_stubspkg_typed_w_stubs-stubspkg_typed_w_stubs.spamspam.pyipkg_untypedpkg_untyped.apkg_untyped.bpkg_untyped.b.cpkg_untyped.a.a_var
standalonestandalone.standalone_varbaz_pkgrf   ns_baz_pkg.a
ns_baz_pkgneighbor_pkgrg   rh   ns_neighbor_pkg.ans_neighbor_pkgdoes_not_existfoo.bar	foo-stubsbar.pyir8   r   Find() got {}; expected {})r!   r   r0   FOUND_WITHOUT_TYPE_HINTSr    r:   r"   r#   r&   r/   r
   r(   casesmoduler<   templateactuals         r)   test__packages_with_nsz4ModuleFinderSitePackagesSuite.test__packages_with_ns   s   2
TYY~6672
 tyy@@A2
 tyy==>	2

  >3!G!GH2
 $%9%CD2
 3LM2
  !5!NO2
  !5!NO2
 "#7#PQ2
 &';'TU2
 tyy)9::;2
 $TYY/EwP^%_%_`2
" .		*NMJJ!2
( &';'TU)2
, $))K??@-2
. DIIk6::;/2
0 DIIk3FFG12
2 diiS&AAB32
4 !"6"@A52
8 !$)),E~"V"VW92
: &tyy1JJ'W'WX;2
> 0IJ?2
@ 2KLA2
B 2KLC2
D  4 MNE2
F #$8$QRG2
J /HIK2
L )*>*WXM2
P 		%MBBCQ2
R TYYulFCCDS2
T TYYt-?Q^__`U2
V !$))D2DFWY_"`"`aW2
Z 3=>[2
^ 		+y99:_2
b "'//"',,y&&"I"IJJKc2
f !& 	5 	5FH'*AAH[,,V44F84444		5 	5r+   c           	        g dt           j        fdt           j        fdt           j        fdt           j        fdt           j        fdt           j        fdt           j        fdt           j        fd	t           j        fd
t           j        fdt           j        fdt           j        fd|                     ddd          fdt           j        fd|                     dd          fd|                     dd          fd|                     ddd          fd|                     ddd          fdt           j        fd|                     dd          fd|                     dd          fdt           j        fdt           j        fd t           j        fd!t           j        fd"t           j        fd#t           j        fd$t           j        fd%|                     d&d%d          fd't           j        fd(|                     d)d*d(d          fd+t           j        fd,t           j        fd-|                     d.d/          fd0t          j                            t          j                            t          d1d                    f}|D ]8\  }}d2|z   d3z   }| j        	                    |          }t          |||           9d S )4Nrq   rr   rs   rt   ru   rv   rw   rx   ry   rz   r{   r|   r~   r   rA   r   r   r   r9   r   r@   r   rN   r   r   r   rR   r   r   r   r   r   r   r   r   r   r   rf   r   r   rg   rh   r   r   r   r   r   r8   r   r   r   )r   r0   r   r!   r    r:   r"   r#   r'   r/   r
   r   s         r)   test__packages_without_nsz7ModuleFinderSitePackagesSuite.test__packages_without_ns   s   2
1;<2
 3=>2
 3=>	2

  !5!?@2
 $%9%CD2
 3LM2
  !5!NO2
  !5!NO2
 "#7#PQ2
 &';'TU2
 3LM2
 $%9%RS2
" .		*NMJJ!2
( &';'TU)2
, $))K??@-2
. DIIk6::;/2
0 DIIk3FFG12
2 diiS&AAB32
4 !"6"@A52
8 !$)),E~"V"VW92
: &tyy1JJ'W'WX;2
> 0IJ?2
@ 2KLA2
B 2KLC2
D  4 MNE2
F #$8$QRG2
J /HIK2
L )*>*WXM2
P 		%MBBCQ2
R 1;<S2
T TYYt-?Q^__`U2
V !"6"@AW2
Z 3=>[2
^ 		+y99:_2
b "'//"',,y&&"I"IJJKc2
f !& 	5 	5FH'*AAH]..v66F84444		5 	5r+   Nr_   )rm   rn   r   rn   )r`   ra   rb   r*   r!   r   r   r   r+   r)   rd   rd      sm        Z Z Z Z4G G G G85 85 85 85t85 85 85 85 85 85r+   rd   )
__future__r   r    mypy.modulefinderr   r   r   mypy.optionsr   mypy.test.configr   mypy.test.helpersr	   r
   r!   ri   r"   r#   r   rd   r   r+   r)   <module>r      s   " " " " " " 				 P P P P P P P P P P             ) ) ) ) ) ) 1 1 1 1 1 1 1 1GOOBGLL~FFGG	|C |C |C |C |C |C |C |C~P5 P5 P5 P5 P5E P5 P5 P5 P5 P5r+   