Файловый менеджер - Редактировать - /opt/imh-python/lib/python3.9/site-packages/twisted/test/__pycache__/test_modules.cpython-39.pyc
Ðазад
a k�hD � @ s� d Z ddlZddlZddlZddlZddlZddlmZ ddlm Z ddl mZ ddlm Z ddlmZ ddlmZ dd lmZ G d d� dee�ZG dd � d e�ZG dd� de�ZG dd� de�ZG dd� de�ZG dd� de�Zg d�ZdS )zV Tests for twisted.python.modules, abstract access to imported or importable objects. � N)�modules)� networkString)�FilePath)�namedAny)�TwistedModulesMixin)�zipit)�TestCasec @ s e Zd ZdZedfdd�ZdS )�TwistedModulesTestCasez/ Base class for L{modules} test cases. Fc C s: |j |d�D ]}|j|kr| S q| �d|�d�� dS )z� You don't ever actually want to do this, so it's not in the public API, but sometimes we want to compare the result of an iterative call with a lookup call and make sure they're the same for test purposes. ��importPackageszUnable to find module z through iteration.N)�walkModules�nameZfail)�self�modname�wherer �modinfo� r ��/root/rpmbuild/BUILDROOT/imh-python39-modules-3.9.7-92.el8.x86_64/opt/imh-python/lib/python3.9/site-packages/twisted/test/test_modules.py�findByIteration s z&TwistedModulesTestCase.findByIterationN)�__name__� __module__�__qualname__�__doc__r r r r r r r s r c @ sl e Zd Zdd� Zdd� Zdd� Zdd� Zd d � Zdd� Zd d� Z dd� Z dd� Zdd� Zdd� Z dd� ZdS )� BasicTestsc C sV t d� d}| �� }|�d�}|�d��|� |�d�}|�� |�d��|� |�d��d� | �� }|�d�}|�d��|� |�d�}|�� |�d��|� |�d��d� | �|j|jg� t�d�}z@d d � |j dd�D �} W t tj�� �D ]}|� d�r�tj|= q�n,t tj�� �D ]}|� d��r tj|= �q 0 g d �} | �| | � dS )zd Duplicate packages are not yielded when iterating over namespace packages. �pkgutilsB import pkgutil; __path__ = pkgutil.extend_path(__path__, __name__)�test_package�__init__.pyZnested_packagez module.py� z module2.pyc S s g | ] }|j �qS r �r )�.0�modr r r � <listcomp>h r z6BasicTests.test_namespacedPackages.<locals>.<listcomp>Tr )r ztest_package.nested_packagez"test_package.nested_package.modulez#test_package.nested_package.module2N)� __import__�pathEntryWithOnePackage�child� setContent�makedirs�replaceSysPath�pathr � getModuler �list�sys�keys� startswith�assertEqual)r ZnamespaceBoilerplate�entryZtestPackagePathZnestedEntryZanotherEntryZanotherPackagePathZanotherNestedEntry�moduleZwalkedNames�expectedr r r �test_namespacedPackages+ s: � �z"BasicTests.test_namespacedPackagesc C sH g }t j| �� jg|ji i ddid�}| �|g � | �|d �� � dS )a If a package has been explicitly forbidden from importing by setting a L{None} key in sys.modules under its name, L{modules.PythonPath.__getitem__} should still be able to retrieve an unloaded L{modules.PythonModule} for that package. r N)�sysPathZmoduleLoaderZ importerCacheZsysPathHooksZ moduleDict)r � PythonPathr# r( �appendr. �assertFalse�isLoaded)r Z shouldNotLoadr( r r r �test_unimportablePackageGetItemw s �z*BasicTests.test_unimportablePackageGetItemc C s^ | � � }| �|jg� | �ddi� tt�� �}| �dd� |D �dg� | �|d � � � dS )a If a package has been explicitly forbidden from importing by setting a L{None} key in sys.modules under its name, L{modules.walkModules} should still be able to retrieve an unloaded L{modules.PythonModule} for that package. r Nc S s g | ] }|j �qS r r )r �mr r r r! � r zBBasicTests.test_unimportablePackageWalkModules.<locals>.<listcomp>r ) r# r'