HEX
Server: Microsoft-IIS/10.0
System: Windows NT ITPWINWEBSVR22 10.0 build 20348 (Windows Server 2022) AMD64
User: www.conferencesearch.co.uk (0)
PHP: 8.3.30
Disabled: NONE
Upload Files
File: D:/Python311/Lib/test/test_importlib/__pycache__/test_namespace_pkgs.cpython-311.pyc
�

��Vc`2���ddlZddlZddlZddlZddlZddlZddlZddlZddlZddl	m
Z
ejd���Zejd���Z
Gd�dej��ZGd�de��ZGd	�d
e��ZGd�de��ZGd
�de��ZGd�de��ZGd�de��ZGd�de��ZGd�de��ZGd�de��ZGd�de��ZGd�de��ZGd�de��ZGd�d e��ZGd!�d"e��ZGd#�d$e��ZGd%�d&e��Ze d'krej!��dSdS)(�N)�utilc#�K�tj}tj���}	dV�|t_tj���tj�|��dS#|t_tj���tj�|��wxYw)z�
    Make sure sys.modules is the same object and has the same content
    when exiting the context as when entering.

    Similar to importlib.test.util.uncache, but doesn't require explicit
    names.
    N)�sys�modules�copy�clear�update)�sys_modules_saved�sys_modules_copys  �;D:\Python311\Lib\test\test_importlib\test_namespace_pkgs.py�sys_modules_contextr
s���������{�'�'�)�)��-�
����'��������������+�,�,�,�,�,��(��������������+�,�,�,�,���s�A=�=ACc+�6K�|�dtj��|�dtj��t	jdi|��}|5t
��5dV�ddd��n#1swxYwYddd��dS#1swxYwYdS)z�
    Save import state and sys.modules cache and restore it on exit.
    Typical usage:

    >>> with namespace_tree_context(path=['/tmp/xxyy/portion1',
    ...         '/tmp/xxyy/portion2']):
    ...     pass
    �	meta_path�
path_hooksN�)�
setdefaultrrrr�import_stater
)�kwargs�import_contexts  r�namespace_tree_contextr(s"�������k�3�=�1�1�1�
���l�C�N�3�3�3��&�0�0��0�0�N�	���,�.�.���
������������������������������������������s6�B�%A6�*B�6A:	�:B�=A:	�>B�B�Bc�~�eZdZdZej�ej�e��d��Z	d�Z
dS)�NamespacePackageTestzj
    Subclasses should define self.root and self.paths (under that root)
    to be added to sys.path.
    �namespace_pkgsc����fd��jD���_��t�j�����dS)Nc�Z��g|]'}tj��j|����(Sr)�os�path�join�root)�.0r�selfs  �r�
<listcomp>z.NamespacePackageTest.setUp.<locals>.<listcomp>As8���
�
�
�.2�B�G�L�L���D�)�)�
�
�
�)r)�paths�resolved_paths�enterContextr)r!s`r�setUpzNamespacePackageTest.setUp@s[���
�
�
�
�6:�j�
�
�
���	
���0�d�6I�J�J�J�K�K�K�K�Kr#N)�__name__�
__module__�__qualname__�__doc__rrr�dirname�__file__rr'rr#rrr9sX���������7�<�<������1�1�3C�D�D�D�L�L�L�L�Lr#rc�&�eZdZdgZd�Zd�Zd�ZdS)�SingleNamespacePackage�portion1c�N�ddl}|�|jjd��dS�Nr�portion1 foo one��foo.one�assertEqual�one�attr�r!�foos  r�test_simple_packagez*SingleNamespacePackage.test_simple_packageJ�,������������'9�:�:�:�:�:r#c�t�|�t��5ddl}ddd��dS#1swxYwYdS�Nr��assertRaises�ImportError�foo.twor9s  r�test_cant_import_otherz-SingleNamespacePackage.test_cant_import_otherN���
�
�
�{�
+�
+�	�	��N�N�N�	�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	�	��-�1�1c���ddl}tj��5tjd��|�|jj�|��d��ddd��dS#1swxYwYdS)Nr�ignorez<module 'foo' (namespace)>)r5�warnings�catch_warnings�simplefilterr6�__spec__�loader�module_reprr9s  r�test_module_reprz'SingleNamespacePackage.test_module_reprRs�������
�
$�
&�
&�	:�	:��!�(�+�+�+����S�\�0�<�<�S�A�A�8�
:�
:�
:�	:�	:�	:�	:�	:�	:�	:�	:�	:�	:�	:�	:����	:�	:�	:�	:�	:�	:s�AA-�-A1�4A1N)r(r)r*r$r;rCrNrr#rr/r/GsH������
�L�E�;�;�;����:�:�:�:�:r#r/c��eZdZdgZd�ZdS)�DynamicPathNamespacePackager0c��ddl}|�|jjd��|�t
��5ddl}ddd��n#1swxYwYtj�	tj�|jd����ddl}|�|j
jd��dS)Nrr3�portion2�portion2 foo two)r5r6r7r8r@rArBrr�appendrrr�twor9s  r�test_dynamic_pathz-DynamicPathNamespacePackage.test_dynamic_path]s�������������'9�:�:�:�
�
�
�{�
+�
+�	�	��N�N�N�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	��������T�Y�
�;�;�<�<�<�	����������'9�:�:�:�:�:s�A�A�AN)r(r)r*r$rVrr#rrPrPZs*������
�L�E�
;�
;�
;�
;�
;r#rPc��eZdZdgZd�ZdS)�CombinedNamespacePackages�
both_portionsc��ddl}ddl}|�|jjd��|�|jjd��dS�Nrzboth_portions foo one�both_portions foo two�r5rBr6r7r8rUr9s  r�test_importsz&CombinedNamespacePackages.test_importspsP����������������'>�?�?�?�������'>�?�?�?�?�?r#N�r(r)r*r$r^rr#rrXrXms0������
��E�@�@�@�@�@r#rXc��eZdZddgZd�ZdS)�SeparatedNamespacePackagesr0rRc��ddl}ddl}|�|jjd��|�|jjd��dS)Nrr3rSr]r9s  rr^z'SeparatedNamespacePackages.test_importszsP����������������'9�:�:�:�������'9�:�:�:�:�:r#Nr_rr#rraraws-������
��$�E�;�;�;�;�;r#rac��eZdZdgZd�ZdS)�-SeparatedNamespacePackagesCreatedWhileRunningr0c�P�tj��5}tj�|��ddl}|�|jjd��|�	t��5ddl}ddd��n#1swxYwYtj�
|d��}tj|��tj�
|d��}t|dd���5}|�d��ddd��n#1swxYwY|�	t��5ddl}ddd��n#1swxYwYt#j��ddl}|�|jjd	��ddd��dS#1swxYwYdS)
Nrr3r:zjust_created.py�wzutf-8)�encodingzattr = "just_created foo"zjust_created foo)�tempfile�TemporaryDirectoryrrrTr5r6r7r8r@rA�foo.just_createdrr�mkdir�open�write�	importlib�invalidate_caches�just_created)r!�temp_dirr:�namespace_path�module_path�files      r�test_invalidate_cacheszDSeparatedNamespacePackagesCreatedWhileRunning.test_invalidate_caches�s���
�
(�
*�
*�	H�h�
�H�O�O�H�%�%�%��N�N�N����S�W�\�+=�>�>�>��"�"�;�/�/�
(�
(�'�'�'�'�
(�
(�
(�
(�
(�
(�
(�
(�
(�
(�
(����
(�
(�
(�
(�
 �W�\�\�(�E�:�:�N��H�^�$�$�$��'�,�,�~�7H�I�I�K��k�3��9�9�9�
8�T��
�
�6�7�7�7�
8�
8�
8�
8�
8�
8�
8�
8�
8�
8�
8����
8�
8�
8�
8��"�"�;�/�/�
(�
(�'�'�'�'�
(�
(�
(�
(�
(�
(�
(�
(�
(�
(�
(����
(�
(�
(�
(�
�'�)�)�)�#�#�#�#����S�-�2�4F�G�G�G�7	H�	H�	H�	H�	H�	H�	H�	H�	H�	H�	H�	H����	H�	H�	H�	H�	H�	Hs�AF�2B�7F�B	�F�
B	�A)F�4D�
F�D	�F�D	�F�;E�F�E	�F�E	�:F�F�"FN)r(r)r*r$rurr#rrdrd�s/������
�L�E�H�H�H�H�Hr#rdc�(�eZdZddgZd�Zd�Zd�ZdS)�%SeparatedOverlappingNamespacePackagesr0rYc��ddl}ddl}|�|jjd��|�|jjd��dS�Nrr3r\r]r9s  r�test_first_path_winsz:SeparatedOverlappingNamespacePackages.test_first_path_wins��P����������������'9�:�:�:�������'>�?�?�?�?�?r#c���tj���ddl}ddl}|�|jjd��|�|jjd��dSr[)	rr�reverser5rBr6r7r8rUr9s  r�test_first_path_wins_againz@SeparatedOverlappingNamespacePackages.test_first_path_wins_again�sd�����������������������'>�?�?�?�������'>�?�?�?�?�?r#c��ddl}ddl}|�|jjd��|�|jjd��dSry)rBr5r6r7r8rUr9s  r�+test_first_path_wins_importing_second_firstzQSeparatedOverlappingNamespacePackages.test_first_path_wins_importing_second_first�r{r#N)r(r)r*r$rzr~r�rr#rrwrw�sV������
��)�E�@�@�@�@�@�@�@�@�@�@�@r#rwc� �eZdZdgZd�Zd�ZdS)�SingleZipNamespacePackage�top_level_portion1.zipc�N�ddl}|�|jjd��dSr2r4r9s  rr;z-SingleZipNamespacePackage.test_simple_package�r<r#c�t�|�t��5ddl}ddd��dS#1swxYwYdSr>r?r9s  rrCz0SingleZipNamespacePackage.test_cant_import_other�rDrEN�r(r)r*r$r;rCrr#rr�r��s:������
%�&�E�;�;�;�����r#r�c��eZdZddgZd�ZdS)�SeparatedZipNamespacePackagesr�rRc��ddl}ddl}|�|jjd��|�|jjd��|�d|jj��|�d|jj��dS)Nrr3rSr��.zip)	r5rBr6r7r8rU�assertInr-�assertNotInr9s  rr^z*SeparatedZipNamespacePackages.test_imports�s�����������������'9�:�:�:�������'9�:�:�:��
�
�.���0@�A�A�A�������!1�2�2�2�2�2r#Nr_rr#rr�r��s-������
%�z�2�E�3�3�3�3�3r#r�c� �eZdZdgZd�Zd�ZdS)�SingleNestedZipNamespacePackage�#nested_portion1.zip/nested_portion1c�N�ddl}|�|jjd��dSr2r4r9s  rr;z3SingleNestedZipNamespacePackage.test_simple_package�r<r#c�t�|�t��5ddl}ddd��dS#1swxYwYdSr>r?r9s  rrCz6SingleNestedZipNamespacePackage.test_cant_import_other�rDrENr�rr#rr�r��s:������
2�3�E�;�;�;�����r#r�c��eZdZddgZd�ZdS)�#SeparatedNestedZipNamespacePackagesr�rRc�V�ddl}ddl}|�|jjd��|�|jjd��tj�dd��}|�	||jj
��|�d|jj
��dS)Nrr3rSznested_portion1.zip�nested_portion1r�)r5rBr6r7r8rUrrrr�r-r�)r!r:�fns   rr^z0SeparatedNestedZipNamespacePackages.test_imports�s�����������������'9�:�:�:�������'9�:�:�:�
�W�\�\�/�1B�
C�
C���
�
�b�#�'�*�+�+�+�������!1�2�2�2�2�2r#Nr_rr#rr�r��s-������
2�J�?�E�3�3�3�3�3r#r�c��eZdZgd�Zd�ZdS)�
LegacySupport)�not_a_namespace_pkgr0rRrYc�$�ddl}|�t��5ddl}ddd��n#1swxYwY|�d|j��|�dt|j���	����dS)Nr�__init__�	namespace)
r5r@rArBr�r-r��str�
__loader__�lowerr9s  r�+test_non_namespace_package_takes_precedencez9LegacySupport.test_non_namespace_package_takes_precedence�s�������
�
�
�{�
+�
+�	�	��N�N�N�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	��
�
�j�#�,�/�/�/�����c�#�.�&9�&9�&?�&?�&A�&A�B�B�B�B�B��0�4�4N)r(r)r*r$r�rr#rr�r��s3������L�L�L�E�C�C�C�C�Cr#r�c�"�eZdZddgZd�Zd�ZdS)�DynamicPathCalculation�project1�project2c��ddl}|�t|j��d��|�t|jj��d��ddl}|�t|j��d��|�t|jj��d��|�|jjjd��|�|jjjd��|�	t��5ddl}ddd��n#1swxYwY|�t|j��d��|�t|jj��d��dS)Nr��parent child one�parent child two)�parent.child.oner6�len�__path__�child�parent.child.twor7r8rUr@rA�parent.child.three�r!�parents  r�test_project3_failsz*DynamicPathCalculation.test_project3_fails�s�����������V�_�-�-�q�1�1�1�����V�\�2�3�3�Q�7�7�7���������V�_�-�-�q�1�1�1�����V�\�2�3�3�Q�7�7�7������)�.�0B�C�C�C������)�.�0B�C�C�C�
�
�
�{�
+�
+�	&�	&�%�%�%�%�	&�	&�	&�	&�	&�	&�	&�	&�	&�	&�	&����	&�	&�	&�	&�	
����V�_�-�-�q�1�1�1�����V�\�2�3�3�Q�7�7�7�7�7��D(�(D,�/D,c���ddl}|�t|j��d��|�t|jj��d��ddl}|�t|j��d��|�t|jj��d��|�|jjjd��|�|jjjd��|�	t��5ddl}ddd��n#1swxYwYtj
�tj
�|jd����ddl}|�t|j��d��|�t|jj��d��|�|jjjd��dS)Nrr�r�r��project3�zparent child three)r�r6r�r�r�r�r7r8rUr@rAr�rrrTrrr�threer�s  r�test_project3_succeedsz-DynamicPathCalculation.test_project3_succeeds
s�����������V�_�-�-�q�1�1�1�����V�\�2�3�3�Q�7�7�7���������V�_�-�-�q�1�1�1�����V�\�2�3�3�Q�7�7�7������)�.�0B�C�C�C������)�.�0B�C�C�C�
�
�
�{�
+�
+�	&�	&�%�%�%�%�	&�	&�	&�	&�	&�	&�	&�	&�	&�	&�	&����	&�	&�	&�	&�	��������T�Y�
�;�;�<�<�<�!�!�!�!�	
����V�_�-�-�q�1�1�1�����V�\�2�3�3�Q�7�7�7������+�0�2F�G�G�G�G�Gr�N)r(r)r*r$r�r�rr#rr�r��sA������
��$�E�8�8�8�"H�H�H�H�Hr#r�c�:�eZdZdgZejd���Zd�ZdS)�ZipWithMissingDirectoryzmissing_directory.zipc��ddl}dSr>)r5r9s  r�test_missing_directoryz.ZipWithMissingDirectory.test_missing_directory&s��	�����r#c�N�ddl}|�|jjd��dS)Nrzmissing_directory foo two)�bar.twor6rUr8)r!�bars  r�test_present_directoryz.ZipWithMissingDirectory.test_present_directory6s,������������'B�C�C�C�C�Cr#N)r(r)r*r$�unittest�expectedFailurer�r�rr#rr�r�#sM������
$�%�E�
��
�
���
�D�D�D�D�Dr#r�c��eZdZdgZd�ZdS)�"ModuleAndNamespacePackageInSameDir�module_and_namespace_packagec�D�ddl}|�|jd��dS)Nrz	in module)�a_testr6r8)r!r�s  r�$test_module_before_namespace_packagezGModuleAndNamespacePackageInSameDir.test_module_before_namespace_package?s+��	�
�
�
������k�2�2�2�2�2r#N)r(r)r*r$r�rr#rr�r�<s+������
+�,�E�3�3�3�3�3r#r�c�&�eZdZdgZd�Zd�Zd�ZdS)�ReloadTestsr0c�v�ddl}tj|��}|�|jjd��dSr2)r5rn�reloadr6r7r8r9s  rr;zReloadTests.test_simple_packageIs<��������s�#�#��������'9�:�:�:�:�:r#c��ddl}|�t��5ddl}ddd��n#1swxYwYt	j|��}|�t��5ddl}ddd��dS#1swxYwYdSr>)r:r@rArBrnr�r9s  rrCz"ReloadTests.test_cant_import_otherNs���
�
�
�
�
�
�{�
+�
+�	�	��N�N�N�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	���s�#�#��
�
�
�{�
+�
+�	�	��N�N�N�	�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	�	s�0�4�4�)A;�;A?�A?c�n�ddl}|�t��5ddl}ddd��n#1swxYwYtj�tj�|j	d����tj|��}ddl}|�|j
jd��dS)NrrRrS)r5r@rArBrrrTrrrrnr�r6rUr8r9s  rrVzReloadTests.test_dynamic_pathVs�������
�
�
�{�
+�
+�	�	��N�N�N�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	��������T�Y�
�;�;�<�<�<���s�#�#��	����������'9�:�:�:�:�:r�N)r(r)r*r$r;rCrVrr#rr�r�FsH������
�L�E�;�;�;�
���;�;�;�;�;r#r�c�,�eZdZdgZd�Zd�Zd�Zd�ZdS)�LoaderTestsr0c��ddl}|�|j|jj��|�|j��dSr>)r:r6r�rKrL�assertIsNotNoner9s  r�!test_namespace_loader_consistencyz-LoaderTests.test_namespace_loader_consistencygsD���
�
�
��������)<�=�=�=����S�^�,�,�,�,�,r#c��ddl}|�|jj��|�|j��dSr>)r:�assertIsNonerK�originr-r9s  r�!test_namespace_origin_consistencyz-LoaderTests.test_namespace_origin_consistencyms@���
�
�
����#�,�-�.�.�.����#�,�'�'�'�'�'r#c��ddl}tj�|jdd��}|�|jd|��dS)Nrr0r:)r:rrrrr6r�)r!r:�
expected_paths   r�test_path_indexablezLoaderTests.test_path_indexablessF���
�
�
�����T�Y�
�E�B�B�
������a��-�8�8�8�8�8r#c���ddl}|�t|jtjj����|�t|jtjj����dSr>)	r:�
assertTrue�
isinstancer�rn�abc�Loader�	machinery�NamespaceLoaderr9s  r�test_loader_abczLoaderTests.test_loader_abcysX���
�
�
����
�3�>�9�=�3G�H�H�I�I�I����
�3�>�9�3F�3V�W�W�X�X�X�X�Xr#N)r(r)r*r$r�r�r�r�rr#rr�r�ds\������
�L�E�-�-�-�(�(�(�9�9�9�Y�Y�Y�Y�Yr#r��__main__)"�
contextlibrn�
importlib.abc�importlib.machineryrrrhr�rH�test.test_importlibr�contextmanagerr
r�TestCaserr/rPrXrardrwr�r�r�r�r�r�r�r�r�r�r(�mainrr#r�<module>r�s�������������������	�	�	�	�
�
�
�
�������������$�$�$�$�$�$���-�-���-�$������� L�L�L�L�L�8�,�L�L�L�:�:�:�:�:�1�:�:�:�&;�;�;�;�;�"6�;�;�;�&@�@�@�@�@� 4�@�@�@�;�;�;�;�;�!5�;�;�;�H�H�H�H�H�4H�H�H�H�D@�@�@�@�@�,@�@�@�@�.	�	�	�	�	� 4�	�	�	�	3�	3�	3�	3�	3�$8�	3�	3�	3�	�	�	�	�	�&:�	�	�	�
3�
3�
3�
3�
3�*>�
3�
3�
3�C�C�C�C�C�(�C�C�C�*H�*H�*H�*H�*H�1�*H�*H�*H�ZD�D�D�D�D�2�D�D�D�23�3�3�3�3�)=�3�3�3�;�;�;�;�;�&�;�;�;�<Y�Y�Y�Y�Y�&�Y�Y�Y�6�z����H�M�O�O�O�O�O��r#