
    dafp                        d dl Z d dlZd dlZd dlZd dlZd dlmZ 	  ej                  e      j                         j                  j                  j                  dz  j                         Z G d dej                         Z ed>i ddd	dd
dddddddddddddddddddddddddddddddddddddddZ ed>i d dd!dd"dd#dd$dd%dd&dd'dd(dd)dd*dd+dd,dd-d d.dd/dd0dd1d d2d3d4d3Z G d5 d6e      Z G d7 d8      Z G d9 d:e      Zd?d;Zd?d<Zd= Zy# e$ r d dlmZ  e       ZY w xY w)@    N)verbosezModules/getpath.py)get_getpath_codeobjectc                        e Zd Z fdZd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Z xZS )MockGetPathTestsc                 2    t        |   |i | d | _        y N)super__init__maxDiff)selfakw	__class__s      ,/root/Python-3.12.4/Lib/test/test_getpath.pyr
   zMockGetPathTests.__init__   s    !"r"    c           	          t        dd      }|j                  d       |j                  d       |j                  d       t	        dddddg d      }t        ||      }| j                  ||       y	)
z,Test a 'standard' install layout on Windows.C:\Python\python.exeargv0real_executableC:\Python\Lib\os.pyC:\Python\DLLs	C:\Python   C:\Python\python98.zipr   C:\Python\Libr   
executablebase_executableprefixexec_prefixmodule_search_paths_setmodule_search_pathsNMockNTNamespaceadd_known_xfileadd_known_fileadd_known_dirdictgetpathassertEqualr   nsexpectedactuals       r   test_normal_win32z"MockGetPathTests.test_normal_win32   s}    )3
 	23
01
*+.3$$%!
 X&6*r   c                     t        dd      }|j                  d       |j                  d       |j                  ddg       t        dddddddg d	      }t	        ||      }| j                  ||       y
)z(Test an in-build-tree layout on Windows.#C:\CPython\PCbuild\amd64\python.exer   C:\CPython\Lib\os.py'C:\CPython\PCbuild\amd64\pybuilddir.txt 
C:\CPythonr   z%C:\CPython\PCbuild\amd64\python98.zipzC:\CPython\PCbuild\amd64C:\CPython\Libr   r    r!   r"   build_prefix_is_python_buildr#   r$   Nr&   r'   r(   r*   r+   r,   r-   s       r   test_buildtree_win32z%MockGetPathTests.test_buildtree_win320   s    8B
 	AB
12
DrdK=B %&$%!
 X&6*r   c                 4   t        ddd      }|j                  d       |j                  d       |j                  d       |j                  d       |j                  ddg       t	        ddddddd	g d
      }t        ||      }| j                  ||       y)zTest a venv layout on Windows.

        This layout is discovered by the presence of %__PYVENV_LAUNCHER__%,
        specifying the original launcher executable. site.py is responsible
        for updating prefix and exec_prefix.
        r   zC:\venv\Scripts\python.exe)r   ENV___PYVENV_LAUNCHER__r   r   r   zC:\venv\pyvenv.cfgzhome = C:\Pythonr   r   r   r   r!   r"   r    base_prefixbase_exec_prefixr#   r$   Nr%   r-   s       r   test_venv_win32z MockGetPathTests.test_venv_win32J   s     )$A3

 	23
89
01
*+
/2
 	 4$3$)$%!
 X&6*r   c                    d}t        |d| dd| ddi      }t        dd|      }|j                  d       |j                  d	       |j	                  d
       t        dg d      }t        ||      }| j                  ||       d|d   d<   d|d   d<   d|d   d<   t        dg d      }t        ||      }| j                  ||       y)zTest registry lookup on Windows.

        On Windows there are registry entries that are intended for other
        applications to register search paths.
        z1HKLM\Software\Python\PythonCore\9.8-XY\PythonPathNz\Path1	path1-dirz\Path1\Subdirznot-subdirsr   )r   r   winregr   r   r   )r   rF   r   r   r   )r#   r$   r   configuse_environmentr#   r$   r   )
MockWinregr&   r'   r(   r)   r*   r+   r,   )r   hkeyrG   r.   r/   r0   s         r   test_registry_win32z$MockGetPathTests.test_registry_win32o   s    D$fGkfO$m
 
 )3

 	23
01
*+$%!

 X&6**+8&'238./.28*+$%!
 X&6*r   c           	      ,   t        dd      }|j                  d       |j                  d       |j                  dd       |j                  d       |j	                  d       t        dddddg d	      }t        ||      }| j                  ||       y
)z8Test a 'standard' install layout via symlink on Windows.C:\LinkedFrom\python.exer   r   r   r   r   r   r   r   N)r&   r'   add_known_linkr(   r)   r*   r+   r,   r-   s       r   test_symlink_normal_win32z*MockGetPathTests.test_symlink_normal_win32   s    -3
 	67
23
57NO
01
*+27$$%!
 X&6*r   c                 4   t        dd      }|j                  d       |j                  d       |j                  dd       |j                  d       |j                  ddg       t	        dddddddg d	
      }t        ||      }| j                  ||       y)z4Test an in-build-tree layout via symlink on Windows.rN   r3   r   r4   r5   r6   r7   r   r8   r:   N)r&   r'   rO   r(   r*   r+   r,   r-   s       r   test_symlink_buildtree_win32z-MockGetPathTests.test_symlink_buildtree_win32   s    -B
 	67
AB
57]^
12
DrdK27 %&$%!
 X&6*r   c                     t        ddd      }|j                  d       |j                  d       |j                  ddg       t        dddddddg d	
      }t	        ||      }| j                  ||       y)zETest an out-of-build-tree layout on Windows with PYTHONHOME override.zC:\Out\python.exer7   )r   r   ENV_PYTHONHOMEr4   zC:\Out\pybuilddir.txtr6   zC:\r   )zC:\Out\python98.zipzC:\Outr9   r:   Nr=   r-   s       r   test_buildtree_pythonhome_win32z0MockGetPathTests.test_buildtree_pythonhome_win32   s    &0(

 	/0
12
2RD9+0 %  $%!
" X&6*r   c           	          t        dd      }|j                  d       |j                  d       t        dddddg d      }t	        ||      }| j                  ||       y)	z0Test a layout on Windows with no DLLs directory.r   r   r   r   r   )r   r   r   r   Nr=   r-   s       r   test_no_dlls_win32z#MockGetPathTests.test_no_dlls_win32   sn    )3
 	23
01.3$$%!
 X&6*r   c           	          t        ddd      }|j                  d       |j                  d       |j                  d       t	        dddddg d	
      }t        ||      }| j                  ||       y)z(Test a 'standard' install layout on *nix/usrpythonz/usr/bin)PREFIXr   ENV_PATH/usr/bin/python/usr/lib/python9.8/os.py/usr/lib/python9.8/lib-dynloadr   z/usr/lib/python98.zipz/usr/lib/python9.8r_   r   NMockPosixNamespacer'   r(   r)   r*   r+   r,   r-   s       r   test_normal_posixz"MockGetPathTests.test_normal_posix  s    

 	,-
45
9:(-$%!
 X&6*r   c                 2   t        dd      }|j                  d       |j                  d       |j                  ddg       |j                  d       |j                  d       t	        ddddd	d
d
g d      }t        ||      }| j                  ||       y)Test an in-build-tree layout on POSIX.

        This layout is discovered from the presence of pybuilddir.txt, which
        contains the relative path from the executable's directory to the
        platstdlib path.
        /home/cpython/python
/usr/localr   r[   /usr/local/bin/python/home/cpython/pybuilddir.txtbuild/lib.linux-x86_64-9.8/home/cpython/Lib/os.py/home/cpython/lib-dynload/home/cpythonr   /usr/local/lib/python98.zip/home/cpython/Libz(/home/cpython/build/lib.linux-x86_64-9.8r   r!   r"   r    r;   r<   r#   r$   Nra   r-   s       r   test_buildpath_posixz%MockGetPathTests.test_buildpath_posix%  s      )
 	12
23
8;W:XY
34
45-$2($%!
 X&6*r   c                 4   t        ddd      }|j                  d       |j                  d       |j                  d       |j                  d       |j                  d	d
g       t	        dddddddg d      }t        ||      }| j                  ||       y)Test a venv layout on *nix.rZ   rY   /venv/bin:/usr/binr   r[   r\   r]   /venv/bin/pythonr^   r_   /venv/pyvenv.cfghome = /usr/binr   r`   rA   Nra   r-   s       r   test_venv_posixz MockGetPathTests.test_venv_posixF  s    )

 	,-
-.
45
9:
,/
 	 )-#$%!
 X&6*r   c                 X   t        ddd      }|j                  d       |j                  d       |j                  dd       |j                  d       |j	                  d       |j                  d	d
g       t        dddddddg d      }t        ||      }| j                  ||       y)ru   rZ   rY   rv   rw   z/usr/bin/python3rx   r^   r_   ry   rz   r   r`   rA   Nrb   r'   rO   r(   r)   r*   r+   r,   r-   s       r   test_venv_changed_name_posixz-MockGetPathTests.test_venv_changed_name_posixe  s    )

 	-.
-.
,.@A
45
9:
,/
 	 ).#$%!
 X&6*r   c                 X   t        ddd      }|j                  d       |j                  d       |j                  dd       |j                  d       |j	                  d       |j                  dd	g       t        dd
d
dd
d
dg d      }t        ||      }| j                  ||       y)zCTest a venv created from non-installed python has correct zip path.rx   rY   rv   rw   z!/path/to/non-installed/bin/pythonz*/path/to/non-installed/lib/python9.8/os.py0/path/to/non-installed/lib/python9.8/lib-dynloadry   zhome = /path/to/non-installedz/path/to/non-installedr   )z'/path/to/non-installed/lib/python98.zipz$/path/to/non-installed/lib/python9.8r   rA   Nr}   r-   s       r   &test_venv_non_installed_zip_path_posixz7MockGetPathTests.test_venv_non_installed_zip_path_posix  s    $)

 	>?
-.
,=	?
FG
KL
,,/
 	 )+0?05$%!
 X&6*r   c                 4   t        ddd      }|j                  d       |j                  d       |j                  d       |j                  d       |j                  d	d
g       t	        dddddddg d      }t        ||      }| j                  ||       y)zETest a venv --copies layout on *nix that lacks a distributed 'python'rZ   rY   rv   rw   z/usr/bin/python9rx   r^   r_   ry   rz   r   r`   rA   Nra   r-   s       r   !test_venv_changed_name_copy_posixz2MockGetPathTests.test_venv_changed_name_copy_posix  s    )

 	-.
-.
45
9:
,/
 	 ).#$%!
 X&6*r   c           	      ,   t        dd      }|j                  d       |j                  d       |j                  dd       |j                  d       |j	                  d       t        dddddg d	      }t        ||      }| j                  ||       y
)z4Test a 'standard' install layout via symlink on *nixrY   /linkfrom/python)r[   r   r]   r^   r_   r   r`   r   Nr}   r-   s       r   test_symlink_normal_posixz*MockGetPathTests.test_symlink_normal_posix  s    $
 	-.
,-
,.?@
45
9:).$%!
 X&6*r   c                 x   t        dd      }|j                  d       |j                  d       |j                  dd       |j                  d       |j                  ddg       |j                  d       |j	                  d	       t        ddddd
ddg d      }t        ||      }| j                  ||       y)re   r   rg   rh   rf   ri   rj   rk   rl   rm   rn   r   ro   rr   Nr}   r-   s       r   test_symlink_buildpath_posixz-MockGetPathTests.test_symlink_buildpath_posix  s      %
 	-.
12
,.DE
23
8;W:XY
34
45)$.($%!
 X&6*r   c           	          t        ddd      }|j                  d       |j                  d       |j                  d       t	        dddddg d	
      }t        ||      }| j                  ||       y)z.Test an install with custom platlibdir on *nixrY   r   lib64)r[   r   
PLATLIBDIRr]   z/usr/lib64/python9.8/os.py /usr/lib64/python9.8/lib-dynloadr   )z/usr/lib64/python98.zipz/usr/lib64/python9.8r   r   Nra   r-   s       r   test_custom_platlibdir_posixz-MockGetPathTests.test_custom_platlibdir_posix  s    $

 	,-
67
;<).$%!
 X&6*r   c                    t        dddddddd      }|j                  d       |j                  d       |j                  d       |j                  d	       t	        dddddddg d
      }t        ||      }| j                  ||       y)z Test framework layout on macOS

        This layout is primarily detected using a compile-time option
        (WITH_NEXT_FRAMEWORK).
        darwin\/Library/Frameworks/Python.framework/Versions/9.8/Resources/Python.app/Contents/MacOS/Pythonr   1/Library/Frameworks/Python.framework/Versions/9.8?/Library/Frameworks/Python.framework/Versions/9.8/bin/python9.88/Library/Frameworks/Python.framework/Versions/9.8/Pythonos_namer   WITH_NEXT_FRAMEWORKr[   EXEC_PREFIXr@   r   libraryK/Library/Frameworks/Python.framework/Versions/9.8/lib/python9.8/lib-dynloadE/Library/Frameworks/Python.framework/Versions/9.8/lib/python9.8/os.pyzB/Library/Frameworks/Python.framework/Versions/9.8/lib/python98.zipz?/Library/Frameworks/Python.framework/Versions/9.8/lib/python9.8r   rA   N)rb   r'   r)   r(   r*   r+   r,   r-   s       r   test_framework_macosz%MockGetPathTests.test_framework_macos  s      p !FK$ezN	
 	yz
\]
fg
ab
 XFK]KP$%!
 X&6*r   c                 "   t        ddddddddddddd      }|j                  d       |j                  d       |j                  d	       |j                  d
       t        dddddddg d      }t	        ||      }| j                  ||       y)z Test framework layout on macOS with alternate framework name

        ``--with-framework-name=DebugPython``

        This layout is primarily detected using a compile-time option
        (WITH_NEXT_FRAMEWORK).
        f/Library/Frameworks/DebugPython.framework/Versions/9.8/Resources/Python.app/Contents/MacOS/DebugPythonr   r   6/Library/Frameworks/DebugPython.framework/Versions/9.8D/Library/Frameworks/DebugPython.framework/Versions/9.8/bin/python9.8B/Library/Frameworks/DebugPython.framework/Versions/9.8/DebugPythonN)r   r   r   r[   r   r@   r   r   
PYTHONPATHrT   ENV_PYTHONEXECUTABLEexecutable_dir
py_setpathP/Library/Frameworks/DebugPython.framework/Versions/9.8/lib/python9.8/lib-dynloadJ/Library/Frameworks/DebugPython.framework/Versions/9.8/lib/python9.8/os.pyzG/Library/Frameworks/DebugPython.framework/Versions/9.8/lib/python98.zipzD/Library/Frameworks/DebugPython.framework/Versions/9.8/lib/python9.8r   rA   )rb   r'   r)   r*   r+   r,   r-   s       r   test_alt_framework_macosz)MockGetPathTests.test_alt_framework_macosD  s      z !KP$j EX!%
 	  D  	E
ab
kl
gh ]KPbPU$%!
 X&6*r   c                    d}t        ddddd| ddd      }|j                  |       |j                  | d	       |j                  | d
       |j                  | d       |j                  | d       |j                  d       |j                  d       |j                  d       |j                  d       |j                  | ddg       t	        | dddddddg d      }t        ||      }| j                  ||       y)z<Test a venv layout on macOS using a framework build
        /tmp/workdir/venvr   r   r   r   /bin/pythonr   r   /bin/lib/lib/python9.8r   r   r   /pyvenv.cfgz<home = /Library/Frameworks/Python.framework/Versions/9.8/binr   rA   Nrb   r)   r'   r(   r*   r+   r,   r   	venv_pathr.   r/   r0   s        r   test_venv_framework_macosz*MockGetPathTests.test_venv_framework_macoss  s<    (	p !FK'0k$=zN	
 	#
I;d+,
I;d+,
I;n56
i[45
yz
\]
fg
bc
YK{3J6
 	 #K0FK]KP$%!
 X&6*r   c                    d}t        ddddd| ddd      }|j                  |       |j                  | d	       |j                  | d
       |j                  | d       |j                  | d       |j                  d       |j                  d       |j                  d       |j                  d       |j                  | ddg       t	        | dddddddg d      }t        ||      }| j                  ||       y)zkTest a venv layout on macOS using a framework build

        ``--with-framework-name=DebugPython``
        r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   zAhome = /Library/Frameworks/DebugPython.framework/Versions/9.8/binr   rA   Nr   r   s        r   test_venv_alt_framework_macosz.MockGetPathTests.test_venv_alt_framework_macos  sE   
 (	z !KP'0k$= EX	
 	#
I;d+,
I;d+,
I;n56
i[45
  D  	E
ab
kl
gh
YK{3O6
 	 #K0KPbPU$%!
 X&6*r   c                 8   t        ddddd      }|j                  d       |j                  d       |j                  d       |j                  d       |j                  dd	g       t	        ddddddd
g d      }t        ||      }| j                  ||       y)zTest a venv layout on macOS.

        This layout is discovered when 'executable' and 'real_executable' match,
        but $__PYVENV_LAUNCHER__ has been set to the original process.
        r   r]   rY   z/framework/Python9.8/python)r   r   r[   r@   r   r^   r_   z/framework/Python9.8/pyvenv.cfgrz   r   r`   rA   Nra   r-   s       r   test_venv_macosz MockGetPathTests.test_venv_macos  s      #$A-
 	,-
89
45
9:
;>
 	 4-#$%!
 X&6*r   c           	      2   t        ddddd      }|j                  d       |j                  d       |j                  dd       |j                  d       |j	                  d	       t        ddddd
g d      }t        ||      }| j                  ||       y)z5Test a 'standard' install layout via symlink on macOSr   rY   rZ   /linkfrom:/usr/binr   )r   r[   r   r\   r   r]   r^   r_   r   r`   r   Nr}   r-   s       r   test_symlink_normal_macosz*MockGetPathTests.test_symlink_normal_macos  s    ).
 	-.
,-
,.?@
45
9:).$%!
 X&6*r   c                 ~   t        ddddd      }|j                  d       |j                  d       |j                  dd       |j                  d       |j                  d	d
g       |j                  d       |j	                  d       t        dddddddg d      }t        ||      }| j                  ||       y)zTest an in-build-tree layout via symlink on macOS.

        This layout is discovered from the presence of pybuilddir.txt, which
        contains the relative path from the executable's directory to the
        platstdlib path.
        r   rZ   r   rg   r   )r   r   r\   r[   r   rf   ri   rj   zbuild/lib.macos-9.8rl   rm   rn   r   )rp   rq   z!/home/cpython/build/lib.macos-9.8rr   Nr}   r-   s       r   test_symlink_buildpath_macosz-MockGetPathTests.test_symlink_buildpath_macos  s      ).
 	-.
12
,.DE
23
8;P:QR
34
45)$.($%!
 X&6*r   )__name__
__module____qualname__r
   r1   r>   rD   rL   rP   rR   rU   rW   rc   rs   r{   r~   r   r   r   r   r   r   r   r   r   r   r   r   __classcell__r   s   @r   r   r      s    +2+4#+J/+b+6+8+<+.+2+B+>+@+B+>+4!+F+2'+R-+^)+V++Z#+J+<%+r   r   r[   r6   r   r   VPATHr   
PYDEBUGEXTVERSION_MAJOR	   VERSION_MINOR   PYWINVER
EXE_SUFFIXr\   rT   r   r@   r   r   r   r   r   rG   r;   venv_prefixhome
platlibdir
pythonpathprogram_namer!   r"   rB   rC   r   r    
stdlib_dirplatstdlib_dirr$   r#   pythonpath_envargv	orig_argvisolatedrI   r   use_sitec                        e Zd Zddd fd
ZddZd Zd Zd Zd Zd	 Z	d
 Z
d Zd Zd Zd Zd Zd Zd Zd Zd ZddZd Z xZS )r&   Nr   rH   c                .   | j                  t               t        j                         | d<   d| d<   d| d<   d| d<   d| d	<   t	        |   |i | |r	|g| d   d
<   |r| d   j                  |       i | _        i | _        t               | _	        g | _
        y )NrH   ntr   DLLsr   z9.8-XYr   z..\..r   r   )updateDEFAULT_NAMESPACEDEFAULT_CONFIGcopyr	   r
   _files_linksset_dirs	_warningsr   r   rH   r   r   r   s        r   r
   zMockNTNamespace.__init__k  s    %&',,.XY#\#Z W!"r"+0'DN;'N!!&)U
r   c                     t        |xs d      | j                  |j                         <   | j                  |j	                  d      d          y )N \r   )listr   casefoldr)   
rpartitionr   pathliness      r   r(   zMockNTNamespace.add_known_file|  s;    '+EKR'8DMMO$4??4034r   c                 &    | j                  |       y r   )r(   r   r   s     r   r'   zMockNTNamespace.add_known_xfile  s    D!r   c                 >    || j                   |j                         <   y r   )r   r   r   r   targets      r   rO   zMockNTNamespace.add_known_link  s    '-DMMO$r   c                     |j                  d      j                         }|r3| j                  j                  |       |j	                  d      d   }|r2y y )Nr   r   )rstripr   r   addr   r   r   ps      r   r)   zMockNTNamespace.add_known_dir  sD    KK&&(JJNN1T"1%A r   c                 N    	 t        | |      S # t        $ r t        |      d w xY wr   getattrAttributeErrorKeyErrorr   keys     r   __missing__zMockNTNamespace.__missing__  /    	*4%% 	*3-T)	*    $c                 L    | j                  |      r|S | j                  d|      S )NzC:\Absoluteisabsjoinpathr   s     r   abspathzMockNTNamespace.abspath  s$    ::dK}}^T22r   c                 *    |j                  d      d   S )Nr      r   r   s     r   basenamezMockNTNamespace.basename  s    t$Q''r   c                 f    |j                  d      j                  d      d   }|dd  dk(  r|dz   S |S )Nr   r   r   :r   r   )r   r   names      r   dirnamezMockNTNamespace.dirname  s<    {{4 ++D1!48s?$;r   c                 \    |j                         j                  |j                               S r   )r   endswithr   r   suffixs      r   	hassuffixzMockNTNamespace.hassuffix  s     }}''(9::r   c                     |dd dk(  S )Nr      z:\r   r   s     r   r  zMockNTNamespace.isabs  s    AayE!!r   c                 `    t         rt        d|d       |j                         | j                  v S NCheck ifzis a dir)r   printr   r   r   s     r   isdirzMockNTNamespace.isdir  s&    *dJ/}}$**,,r   c                 `    t         rt        d|d       |j                         | j                  v S Nr  z	is a file)r   r  r   r   r   s     r   isfilezMockNTNamespace.isfile  s&    *dK0}}$++--r   c                     t         rt        d|d       |j                         }|| j                  v xr% |j	                  d      d   dj                         k(  S Nr  zis a module.r	  pyr   r  r   r   r   r   s     r   ismodulezMockNTNamespace.ismodule  sI    *dM2}}t{{"Qts';A'>$--/'QQr   c                     t         rt        d|d       |j                         }|| j                  v xr% |j	                  d      d   dj                         k(  S )Nr  zis a executabler"  r	  exer$  r   s     r   isxfilezMockNTNamespace.isxfile  sK    *d$56}}t{{"Rts';A'>%..BR'RRr   c                 L    t        j                  t        j                  |       S r   )ntpathnormpathjoinr   s     r   r  zMockNTNamespace.joinpath  s    v{{D122r   c                 p    	 | j                   |j                            S # t        $ r t        |      d w xY wr   )r   r   r   FileNotFoundErrorr   s     r   	readlineszMockNTNamespace.readlines  s8    	4;;t}}// 	4#D)t3	4s    5c                 :   t         rt        d|       	 | j                  |j                            }|t               }n|j                         |v rt        d      |j                  |j                                | j                  ||      S # t        $ r |cY S w xY wNzRead link fromzcircular link)	r   r  r   r   r   r   OSErrorr   realpathr   r   _traillinks       r   r3  zMockNTNamespace.realpath  s    "D)	;;t}}/D >UF]]_&/**

4==?#}}T6**  	K	s   B BBc                 ^    | j                   j                  |       t        rt        |       y y r   r   appendr   r  r   messages     r   warnzMockNTNamespace.warn  #    g&'N r   r   r   r   r   r
   r(   r'   rO   r)   r   r  r  r  r  r  r  r  r%  r(  r  r/  r3  r<  r   r   s   @r   r&   r&   j  si    !%d "5".&*3
(;"-
.
RS34+r   r&   c                   D    e Zd ZdZdZd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zy)rJ   HKLMHKCUc                     |j                         D ci c]  \  }}|j                         | c}}| _        i | _        y c c}}w r   )itemsr   keysopen)r   rD  kvs       r   r
   zMockWinreg.__init__  s4    15>AQZZ\1_>		 ?s   A c                      y)Nz<MockWinreg>r   r   s    r   __repr__zMockWinreg.__repr__  s    r   c                 ,    t        |t        |             S r   )
isinstancetype)r   others     r   __eq__zMockWinreg.__eq__  s    %d,,r   c                 ,    t        | j                        S r   )r   rE  rI  s    r   	open_keyszMockWinreg.open_keys  s    DIIr   c                     t         rt        d| d| d       | d| j                         }|| j                  v r.| j                  j                  |d      dz   | j                  |<   |S t               )Nz
OpenKeyEx(, )r   r   r   )r   r  r   rD  rE  getr.  )r   rK   subkeyr   s       r   	OpenKeyExzMockWinreg.OpenKeyEx  sp    JtfBvha01b!**,$))!YY]]32Q6DIIcNJ!!r   c                     t         rt        d| d       |j                         }|| j                  vrt	        d      | j                  |xx   dz  cc<   | j                  |   s| j                  |= y y )Nz	CloseKey(rT  key is not openr   )r   r  r   rE  RuntimeError)r   rK   s     r   CloseKeyzMockWinreg.CloseKey  sf    IdV1%&}}tyy 011		$1yy		$ r   c                    t         rt        d| d| d       |j                         }|| j                  vrt	        d      | d}t        | j                        D cg c]"  }|j                  |      s|t        |      d  $ }}|D cg c]	  }d|vs| c}|d d  t        |      D ]  \  }}||k(  s|j                  |      c S  t        d      c c}w c c}w )NzEnumKey(rS  rT  rY  r   zend of enumeration)r   r  r   rE  rZ  sortedrD  
startswithlen	enumerateremoveprefixr2  )r   rK   ir!   rF  subkeysjns           r   EnumKeyzMockWinreg.EnumKey  s    HTF"QCq)*}}tyy 0116,2499,=VqfAU1S[\?VV!(:ADMa:
g& 	.DAqAv~~f--	. *++ W:s   C5C	CCc                    t         rt        d| d| d       |j                         }|| j                  vrt	        d      |r|j                         }| d| }	 | j
                  |   S # t        $ r t               w xY w)NzQueryValue(rS  rT  rY  r   )r   r  r   rE  rZ  rD  r   r2  )r   rK   rV  s      r   
QueryValuezMockWinreg.QueryValue  s    KvRxq12}}tyy 011__&FV2fX&D	99T?" 	)O	s   A+ +A?N)r   r   r   HKEY_LOCAL_MACHINEHKEY_CURRENT_USERr
   rJ  rO  rQ  rW  r[  rf  rh  r   r   r   rJ   rJ     s6    -" ,r   rJ   c                        e Zd Zddd fd
ZddZd Zd Zd Zd Zd	 Z	d
 Z
d Zd Zd Zd Zd Zd Zd Zd Zd ZddZd Z xZS )rb   Nr   c                B   | j                  t               t        j                         | d<   d| d<   d| d<   d| d<   t	        |   |i | |r	|g| d   d<   |r| d   j                  |       i | _        t               | _        i | _	        t               | _
        g | _        y )	NrH   posixr   libr   r   r   r   )r   r   r   r   r	   r
   r   r   _xfilesr   r   r   r   s        r   r
   zMockPosixNamespace.__init__  s    %&',,.X!Y"\&'"#!"r"+0'DN;'N!!&)uU
r   c                     t        |xs d      | j                  |<   | j                  |j                  d      d          y )Nr   /r   )r   r   r)   r   r   s      r   r(   z!MockPosixNamespace.add_known_file,  s5     "-D4??3/23r   c                 \    | j                  |       | j                  j                  |       y r   )r(   ro  r   r   s     r   r'   z"MockPosixNamespace.add_known_xfile0  s"    D!r   c                 "    || j                   |<   y r   )r   r   s      r   rO   z!MockPosixNamespace.add_known_link4  s    "Dr   c                     |j                  d      }|r3| j                  j                  |       |j                  d      d   }|r2y y Nrq  r   )r   r   r   r   r   s      r   r)   z MockPosixNamespace.add_known_dir7  s;    KKJJNN1S!!$A r   c                 N    	 t        | |      S # t        $ r t        |      d w xY wr   r   r   s     r   r   zMockPosixNamespace.__missing__=  r  r  c                 L    | j                  |      r|S | j                  d|      S )Nz	/Absoluter  r   s     r   r  zMockPosixNamespace.abspathC  s$    ::dK}}[$//r   c                 *    |j                  d      d   S )Nrq  r	  r
  r   s     r   r  zMockPosixNamespace.basenameH  s    s#A&&r   c                 H    |j                  d      j                  d      d   S ru  r  r   s     r   r  zMockPosixNamespace.dirnameK  s!    {{3**3/22r   c                 $    |j                  |      S r   )r  r  s      r   r  zMockPosixNamespace.hassuffixN  s    }}V$$r   c                     |dd dk(  S )Nr   r   rq  r   r   s     r   r  zMockPosixNamespace.isabsQ  s    AayCr   c                 D    t         rt        d|d       || j                  v S r  )r   r  r   r   s     r   r  zMockPosixNamespace.isdirT  s     *dJ/tzz!!r   c                 D    t         rt        d|d       || j                  v S r  )r   r  r   r   s     r   r  zMockPosixNamespace.isfileY  s     *dK0t{{""r   c                 v    t         rt        d|d       || j                  v xr |j                  d      d   dk(  S r!  )r   r  r   r   r   s     r   r%  zMockPosixNamespace.ismodule^  s8    *dM2t{{"Fts';A'>$'FFr   c                 D    t         rt        d|d       || j                  v S )Nr  zis an xfile)r   r  ro  r   s     r   r(  zMockPosixNamespace.isxfilec  s     *dM2t||##r   c                 L    t        j                  t        j                  |       S r   )	posixpathr+  r,  r   s     r   r  zMockPosixNamespace.joinpathh  s    !!)..$"788r   c                 T    	 | j                   |   S # t        $ r t        |      d w xY wr   )r   r   r.  r   s     r   r/  zMockPosixNamespace.readlinesk  s2    	4;;t$$ 	4#D)t3	4s    'c                     t         rt        d|       	 | j                  |   }|t	               }n||v rt        d      |j                  |       | j                  ||      S # t        $ r |cY S w xY wr1  )r   r  r   r   r   r2  r   r3  r4  s       r   r3  zMockPosixNamespace.realpathq  sv    "D)	;;t$D >UFV^/**

4}}T6**  	K	s   A" "A0/A0c                 ^    | j                   j                  |       t        rt        |       y y r   r8  r:  s     r   r<  zMockPosixNamespace.warn  r=  r   r   r>  r   s   @r   rb   rb     sh    !%d "4#%*0
'3% "
#
G
$
94+r   rb   c           
         g }t        |       D ]P  }|d d dk(  r|dk(  rt        | |   ||   d       &||v s+||   | |   k7  s7|j                  || |   ||   f       R |sy t        d |D              }dt	        |      dz   |z   z  }t
        rg|D ]a  \  }}}|r.t        dj                  ||j                  |      |||             7t        d	j                  ||j                  |      |             c y y )
Nr	  __rH   r!   c              3   :   K   | ]  \  }}}t        |        y wr   r_  ).0rF  _s      r   	<genexpr>zdiff_dict.<locals>.<genexpr>  s     +71aA+s    r   z{}.{} -{!r}
{} +{!r}z{}.{} +{!r})	r]  	diff_dictr9  maxr_  r   r  formatljust)	beforeafterr!   diffrF  max_kindentbr   s	            r   r  r    s   DF^ 2Ra5D==fQiq(;:%(fQi/KKF1IuQx012 +d++ECK!Oe+,F 	GGAq!-44VQWWU^QPVXYZ[m**61775>1EF		G r   c           
         t         r|sy t        d |D              }t        |j                         d       D ]  \  }}|d d dk(  r|dk(  rt	        | |   ||   d       )	 || |   k7  r0t        dj                  ||j                  |      || |                b	 t        d	j                  ||j                  |      |              y # t        $ r Y 9w xY w)
Nc              3   2   K   | ]  }t        |        y wr   r  )r  rF  s     r   r  zdump_dict.<locals>.<genexpr>  s     &1A&s   c                     | d   S )Nr   r   )rb  s    r   <lambda>zdump_dict.<locals>.<lambda>  s
    AaD r   )r   r	  r  rH   r  z{}.{} {!r} (was {!r})z
{}.{} {!r})	r   r  r]  rC  	dump_dictr  r  r  r   )r  r  r!   r  rF  rG  s         r   r  r    s    %&&&Eu{{}.9 >1Ra5D==fQiq(;	F1I~-44VQWWU^QPVWXPYZ[ 
 	l!!&!''%.!<=>  		s   "7C			CCc                 @   t        j                  |       }d}	 t        t        |        d}|rt	        ||        nt        ||        	 |D ci c](  }|| d   j                  || j                  |d            * c}S # |rt	        ||        w t        ||        w xY wc c}w )NTFrH   .)r   deepcopyexecSOURCEr  r  rU  )r.   rD  r  failedrF  s        r   r+   r+     s    ]]2FF"VRfb!fb!  	
2h<Arvva~.. 	 fb!fb!s   A; -B;Br   )global)r   r*  pathlibr  unittesttest.supportr   Path__file__absoluteparent
read_bytesr  r.  _testinternalcapir   TestCaser   r*   r   r   r&   rJ   rb   r  r  r+   r   r   r   <module>r     sv         &gll8$--/66==DDG[[ggiFa+x(( a+L    	
            !" #$ %& '( )* +, -. / 4  	  	
             
!" #& '( )* +0ld l^> >Bh hVG,>&E%  &8#%F&s   AD6 6E
E