%PDF- %PDF-
Direktori : /lib/python3/dist-packages/twisted/trial/__pycache__/ |
Current File : //lib/python3/dist-packages/twisted/trial/__pycache__/util.cpython-312.pyc |
� Ϫ�f�3 � �R � d Z ddlmZ ddlmZ ddlmZmZmZm Z ddlm Z ddlmZm Z ddlmZ ddlmZ dd lmZ g d �Z e� ZdZ G d� d e� Z G d� d� Z e� Zefd�Zd� Zdd�Z e d� Z e d� Z d d�Z! G d� de� Z"d� Z# G d� de� Z$d� Z%d!d�Z&d"d�Z'y)#a A collection of utility functions and classes, used internally by Trial. This code is for Trial's internal use. Do NOT use this code if you are writing tests. It is subject to change at the Trial maintainer's whim. There is nothing here in this module for you to use unless you are maintaining Trial. Any non-Trial Twisted code that uses this module will be shot. Maintainer: Jonathan Lange @var DEFAULT_TIMEOUT_DURATION: The default timeout which will be applied to asynchronous (ie, Deferred-returning) test methods, in seconds. � )�annotations)� randrange)�Any�Callable�TextIO�TypeVar)� ParamSpec)� interfaces�utils)�Failure)�FilePath)�FilesystemLock)�DEFAULT_TIMEOUT_DURATION�excInfoOrFailureToExcInfo�suppress�acquireAttributeg ^@c � � e Zd ZdZdd�Zdd�Zy)�DirtyReactorAggregateErrora7 Passed to L{twisted.trial.itrial.IReporter.addError} when the reactor is left in an unclean state after a test. @ivar delayedCalls: The L{DelayedCall<twisted.internet.base.DelayedCall>} objects which weren't cleaned up. @ivar selectables: The selectables which weren't cleaned up. Nc � � || _ || _ y �N)�delayedCalls�selectables)�selfr r s �4/usr/lib/python3/dist-packages/twisted/trial/util.py�__init__z#DirtyReactorAggregateError.__init__5 s � �(���&��� c � � d}| j r1|dz }|dj t t | j � � z }| j r1|dz }|dj t t | j � � z }|S )zR Return a multi-line message describing all of the unclean state. zReactor was unclean.zM DelayedCalls: (set twisted.internet.base.DelayedCall.debug = True to debug) � z Selectables: )r �join�map�strr )r �msgs r �__str__z"DirtyReactorAggregateError.__str__9 s| � � %������� �C� �4�9�9�S��d�&7�&7�8�9�9�C�����%�%�C��4�9�9�S��d�&6�&6�7�8�8�C�� r r )�returnr! )�__name__� __module__�__qualname__�__doc__r r# � r r r r + s � ��'�r r c �l � e Zd ZdZd d�Zd� Zd� Zd� Zd� Z e j eded d �f� Zd� Zd� Z y)�_Janitorz� The guy that cleans up after you. @ivar test: The L{TestCase} to report errors about. @ivar result: The L{IReporter} to report errors to. @ivar reactor: The reactor to use. If None, the global reactor will be used. Nc �. � || _ || _ || _ y)z� @param test: See L{_Janitor.test}. @param result: See L{_Janitor.result}. @param reactor: See L{_Janitor.reactor}. N)�test�result�reactor)r r- r. r/ s r r z_Janitor.__init__U s � � �� ������r c � � | j � }|r;t |� }| j j | j t |� � yy)z� Called by L{unittest.TestCase} after a test to catch any logged errors or pending L{DelayedCall<twisted.internet.base.DelayedCall>}s. FT)� _cleanPendingr r. �addErrorr- r )r �calls� aggregates r �postCaseCleanupz_Janitor.postCaseCleanup_ sB � � �"�"�$���2�5�9�I��K�K� � ����G�I�,>�?��r c �� � | j � }| j � }|s|r;t ||� }| j j | j t |� � | j � y)a Called by L{unittest.TestCase} after the last test in a C{TestCase} subclass. Ensures the reactor is clean by murdering the threadpool, catching any pending L{DelayedCall<twisted.internet.base.DelayedCall>}s, open sockets etc. N)� _cleanReactorr1 r r. r2 r- r � _cleanThreads)r r r3 r4 s r �postClassCleanupz_Janitor.postClassCleanupk sZ � � �(�(�*���"�"�$���%�2�5�+�F�I��K�K� � ����G�I�,>�?����r c �F � | j �| j }|S ddlm } |S )zI Get either the passed-in reactor or the global reactor. r )r/ )r/ �twisted.internet�r r/ s r �_getReactorz_Janitor._getReactory s( � � �<�<�#��l�l�G� �� 1��r c �( � | j � }|j d� |j d� g }|j � D ]J }|j � rt |� }|j � nt d� |j � �L |S )zS Cancel all pending calls and return their string representations. r z)WEIRDNESS! pending timed call not active!)r= �iterate�getDelayedCalls�activer! �cancel�print�append)r r/ �delayedCallStrings�p� delayedStrings r r1 z_Janitor._cleanPending� s� � � �"�"�$�� �������������(�(�*� 5�A��x�x�z� #�A�� ���� ��A�B��%�%�m�4� 5� "�!r ��ignorez!reactor\.iterate cannot be used.*)�category�messagec � � | j � }t j j |� r|j �|j � y y y r )r= r �IReactorThreads� providedBy� threadpool�_stopThreadPoolr<