%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/twisted/scripts/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/twisted/scripts/__pycache__/trial.cpython-312.pyc

�

Ϫ�f�R�� �ddlZddlZddlZddlZddlZddlZddlZddlZddlZddl	m
Z
mZmZddl
mZddlmZddlmZddlmZmZmZddlmZddlmZdd	lmZmZdd
lmZddl m!Z!ddd
d
ddd�Z"d�Z#d�Z$d�Z%d�Z&d�Z'd�Z(dejRfde(fd�Z*d�Z+Gd�d�Z,Gd�de,ejZej\�Z-de-ddfd �Z/de-de!fd!�Z0de-dejbfd"�Z2d#�Z3Gd$�d%e4�Z5de-dejlfd&�Z7de
fd'�Z8y)(�N)�NoReturn�Optional�Type)�plugin)�app)�defer)�failure�reflect�usage)�FilePath)�namedModule)�itrial�runner)�DistTrialRunner)�	TestSuite�default�brief�verbose)�plainr�emacsr�cgitbrc��d}|j|�t|�z}|j|�}|dk(s|dk(rt|�d���|||j	d�}i}|D]u}t|j��dk(r� |j	d�}t|�dk7rt|�d|����|d	j�||dj�<�w|S)
a

    Accepts a single line in Emacs local variable declaration format and
    returns a dict of all the variables {name: value}.
    Raises ValueError if 'line' is in the wrong format.

    See http://www.gnu.org/software/emacs/manual/html_node/File-Variables.html
    z-*-���z' not a valid local variable declaration�;r�:�z contains invalid declaration �)�find�len�rfind�
ValueError�split�strip)�line�paren�start�end�items�	localVars�itemr"s        �7/usr/lib/python3/dist-packages/twisted/scripts/trial.py�_parseLocalVariablesr,'s���
�E��I�I�e��s�5�z�)�E�
�*�*�U�
�C���{�c�R�i��D�8�#J�K�L�L���s�O�!�!�#�&�E��I��7���t�z�z�|���!���
�
�3����u�:��?���x�'E�d�X�N�O�O�&+�A�h�n�n�&6�	�%��(�.�.�"�#�
7���c���t|�5}|j�|j�g}ddd�D]}	t|�cSiS#1swY�xYw#t$rY�+wxYw)z�
    Accepts a filename and attempts to load the Emacs variable declarations
    from that file, simulating what Emacs does.

    See http://www.gnu.org/software/emacs/manual/html_node/File-Variables.html
    N)�open�readliner,r!)�filename�f�linesr$s    r+�loadLocalVariablesr4@sq��
�h��-�1�����q�z�z�|�,��-����	�'��-�-��
�I�-�-��
�	��	�s�!A�
A�A�	A#�"A#c�b�t|�jdd�}|�gS|jd�S)Nztest-case-name�,)r4�getr")r1�testCaseVars  r+�getTestModulesr9Qs6��$�X�.�2�2�3C�T�J�K����	����S�!�!r-c��tjj|�}|jd�xr%tjj	|�ddk(S)z�
    Returns true if 'filename' looks like a file containing unit tests.
    False otherwise.  Doesn't care whether filename exists.
    �test_rz.py)�os�path�basename�
startswith�splitext)r1r>s  r+�
isTestFilerAXsG��
�w�w����)�H����w�'�T�B�G�G�,<�,<�X�,F�q�,I�e�,T�Tr-c��tjtjtj
�D�cgc]}|j��c}�Scc}w�N)r�CompleteListr�
getPluginsr�	IReporter�longOpt)�ps r+�_reporterActionrIas6�����&�2C�2C�F�DT�DT�2U�V�Q�q�y�y�V�W�W��Vs�Ac���t|dd�}|�t||�}t|dd�}|�|jS	tj|�dS#tt
f$rYywxYw)aH
    Try to find the source line of the given test thing.

    @param testThing: the test item to attempt to inspect
    @type testThing: an L{TestCase}, test method, or module, though only the
        former two have a chance to succeed
    @rtype: int
    @return: the starting source line, or -1 if one couldn't be found
    �_testMethodNameN�__code__rr)�getattr�co_firstlineno�inspect�getsourcelines�OSError�	TypeError)�	testThing�method�codes   r+�_maybeFindSourceLinerVes{���Y� 1�4�
8�F�
���I�v�.�	��9�j�$�/�D����"�"�"���%�%�i�0��3�3���Y�����s�A�A"�!A"zCalphabetical order for test methods, arbitrary order for test caseszDattempt to run test cases and methods in the order they were defined)�alphabetical�toptobottomc�|�|tvr3tjddjd�tD���d���|S)ai
    Check that the given order is a known test running order.

    Does nothing else, since looking up the appropriate callable to sort the
    tests should be done when it actually will be used, as the default argument
    will not be coerced by this function.

    @param order: one of the known orders in C{_runOrders}
    @return: the order unmodified
    z--order must be one of: z, c3�2K�|]}t|����y�wrC)�repr)�.0�orders  r+�	<genexpr>z&_checkKnownRunOrder.<locals>.<genexpr>�s����=���e��=�s�z. See --help-orders for details)�
_runOrdersr�
UsageError�join)r]s r+�_checkKnownRunOrderrb�s>��
�J������y�y�=�*�=�=�
@�
�	
��Lr-c	��eZdZUdZdZddggd�gd�gd�gd�gd	�gd
�gd�gZdd
ddeggd�gd�gd�gZejeje�eejd��ejd��d�ejddd��g��ZdZeej&ed<d�Zd�Zd�Zd �Zd!�Zd"�Zd#�Zd$�Zd%�Zd&�Zd'�Zd(�Z d)�Z!d*�Z"d+�Z#d,�Z$y)-�
_BasicOptionszC
    Basic options shared between trial and its local workers.
    zutrial loads and executes a suite of unit tests, obtained from modules, packages and files listed on the command line.�help�h)�
no-recurse�NzDon't recurse into packages)zhelp-ordersNz%Help on available test running orders)zhelp-reportersNz,Help on available output plugins (reporters))�rterrors�ez;realtime errors, print out tracebacks as soon as they occur)�unclean-warningsNz'Turn dirty reactor errors into warnings)�force-gcNz<Have Trial run gc.collect() before and after each test case.)�	exitfirst�xzSExit after the first non-successful result (cannot be specified along with --jobs).r]�oNzRSpecify what order to run test cases and methods. See --help-orders for more info.)�random�zNz2Run tests in random order using the specified seed)�temp-directoryN�_trial_tempz+Path to use as working directory for tests.)�reporterNrzKThe reporter to use for this test run.  See --help-reporters for more info.�
log file name)�descrzrandom seed)r]rt�logfilerpz*.pyz/file | module | package | TestCase | testMethodT)rv�repeat)�
optActions�extraActions�tracerc�L�g|d<tjj|�y�N�tests)r�Options�__init__��selfs r+r�z_BasicOptions.__init__�s����W�
�
�
�
���t�$r-c�,�tjtjd�}|j	d�rMdjtjjtj�|jdd��}dj|�S)Nrz	.__main__z{} -m {}�zD{} [options] [[file|package|module|TestCase|testmethod]...]
        )r
�filenameToModuleName�sys�argv�endswith�formatr<r=r>�
executable�replace)r��executableNames  r+�getSynopsisz_BasicOptions.getSynopsis�su�� �5�5�c�h�h�q�k�B���"�"�;�/�'�.�.���� � ����0��&�&�{�B�7��N�
��F��
�	
r-c�v�d}t|d�j|�}td|j�d��|S)zx
        Return a L{FilePath} representing the directory into which coverage
        results should be written.
        �coveragerrzSetting coverage directory to �.)r�child�printr=)r��coverdir�results   r+r�z_BasicOptions.coverdirs?��
���$�/�0�1�7�7��A��
�.�v�{�{�m�1�=�>��
r-c��tjdd��|_tj|jj
�d|d<y)z�
        Generate coverage information in the coverage file in the
        directory specified by the temp-directory option.
        rr)�count�traceTr�N)r��Tracer{r��settrace�globaltracer�s r+�opt_coveragez_BasicOptions.opt_coverages6��
�k�k���3������T�[�[�,�,�-���Z�r-c�B�tjj|�s$tjjd|�d��ytjj
|�}t|�r|dj|�y|djt|��y)zG
        Filename to grep for test cases (-*- test-case-name).
        zFile z doesn't exist
Nr~)r<r=�isfiler��stderr�write�abspathrA�append�extendr9)r�r1s  r+�opt_testmodulez_BasicOptions.opt_testmodulesv���w�w�~�~�h�'��J�J���u�X�L�0@�A�B���7�7�?�?�8�,���h����M� � ��*���M� � ���!9�:r-c�:�ddlm}tj|�y)z�
        Print an insanely verbose log of everything that happens.  Useful
        when debugging freezes or locks in complex code.
        r)�spewerN)�twisted.python.utilr�r�r�)r�r�s  r+�opt_spewz_BasicOptions.opt_spew4s��
	/����V�r-c��d}t|�ttj��D]\}\}}td|d|��t	j
d�y)Nz�Trial can attempt to run test cases and their methods in a few different orders. You can select any of the following options using --order=<foo>.
�   �	r)r��sortedr_r(r��exit)r��synopsis�name�description�_s     r+�opt_help_ordersz_BasicOptions.opt_help_orders=sU��
7�	�	�h��&,�Z�-=�-=�-?�&@�	2�"�D�"�;���%��t�[�1�	2�����r-c���d}t|�tjtj�D]$}td|j
d|j��&tjd�y)Nz�Trial's output can be customized using plugins called Reporters. You can
select any of the following reporters using --reporter=<foo>
r�r�r)	r�rrErrFrGr�r�r�)r�r�rHs   r+�opt_help_reportersz _BasicOptions.opt_help_reportersIsV��
1�	�
	�h���"�"�6�#3�#3�4�	9�A��%����D�!�-�-�8�	9�����r-c�6�d|d<tj�y)z/
        Disable the garbage collector
        T�	disablegcN)�gc�disabler�s r+�
opt_disablegcz_BasicOptions.opt_disablegcTs��!��[��
�
�
�r-c�b�	t||d<y#t$rtjd��wxYw)z�
        Specify the format to display tracebacks with. Valid formats are
        'plain', 'emacs', and 'cgitb' which uses the nicely verbose stdlib
        cgitb.text function
        �tbformatz.tbformat must be 'plain', 'emacs', or 'cgitb'.N)�TBFORMAT_MAP�KeyErrorrr`)r��opts  r+�opt_tbformatz_BasicOptions.opt_tbformat[s:��	U�+�C�0�D�����	U��"�"�#S�T�T�	U�s��.c��	tjt|��t|�|d<y#ttf$rtjd��wxYw)z-
        see sys.setrecursionlimit()
        �recursionlimitz-argument to recursionlimit must be an integerN)r��setrecursionlimit�intrRr!rr`)r��args  r+�opt_recursionlimitz _BasicOptions.opt_recursionlimitfsT��	.��!�!�#�c�(�+�&)��X�D�!�"���:�&�	T��"�"�#R�S�S�	T�s	�/�%Ac��	t|�|d<|ddkrtjd��|ddk(r$ttj�dz�|d<yy#t$rtjd��wxYw)Nrprz/Argument to --random must be a positive integer�d)r�rr`�timer!)r��options  r+�
opt_randomz_BasicOptions.opt_randomqs���
	8� ��[�D��N��H�~��!��&�&�E����h��1�$�!$�T�Y�Y�[�3�%6�!7��X��%���	V��"�"�#T�U�U�	V�s�A�A9c���||d<|jd�D]F}|tjvrtjd|�d�t
��dtj|<�Hy)zP
        Fake the lack of the specified modules, separated with commas.
        �without-moduler6zModule 'z%' already imported, disabling anyway.)�categoryN)r"r��modules�warnings�warn�RuntimeWarning)r�r��modules   r+�opt_without_modulez _BasicOptions.opt_without_module~sX��"(��
���l�l�3�'�	'�F�����$��
�
�LR�T�+��#'�C�K�K���
	'r-c�,�|dj|�yr})r�)r��argss  r+�	parseArgsz_BasicOptions.parseArgs�s���W�
���T�"r-c��tjtj�D]C}|j�d|j
��}|j|k(s�.tj|�cStjd��)Nr�zVOnly pass names of Reporter plugins to --reporter. See --help-reporters for more info.)rrErrFr��klassrGr
�namedAnyrr`)r�r�rH�quals    r+�_loadReporterByNamez!_BasicOptions._loadReporterByName�sq���"�"�6�#3�#3�4�	.�A��h�h�Z�q����	�*�D��y�y�D� ��'�'��-�-�	.����
�
�	
r-c��|j|d�|d<d|vrd|d<|d�|d�tjd��yy)Nrtr�rr]rpz-You can't specify --random when using --order)r�rr`r�s r+�postOptionsz_BasicOptions.postOptions�s^�� �3�3�D��4D�E��Z���T�!�(�D�����=�$��h��)C��"�"�#R�S�S�*D�$r-)%�__name__�
__module__�__qualname__�__doc__�longdesc�optFlagsrb�
optParametersr�CompletionsrDr_rI�
CompleteFiles�	Completer�compDatar{rr�r��__annotations__r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r��r-r+rdrd�s@���
	G�
�
��
�:�F�P�	
�
	N�	
�
	
�!�H�4
���
/��
	
�	T�	
�	
�!�M�2!�u� � �'�U�'�'�
�3�'�*�u�*�*��A�%�e�o�o�M�:�	
�
 �E����G��
�
��H� %)�F�H�U�[�[�!�(�%�
��$ �;�.�
�	��	U�	.�8�'�#�	
�Tr-rdc��eZdZdZgd�gd�gd�gd�gd�gd�gZgd�gd	�gd
�gZejejgd��e	d��
�Z
gd�Zgd�Zd�Z
d�Zd�Zy)ra�
    Options to the trial command line tool.

    @ivar _workerFlags: List of flags which are accepted by trial distributed
        workers. This is used by C{_getWorkerArguments} to build the command
        line arguments.
    @type _workerFlags: C{list}

    @ivar _workerParameters: List of parameter which are accepted by trial
        distributed workers. This is used by C{_getWorkerArguments} to build
        the command line arguments.
    @type _workerParameters: C{list}
    )�debug�bziRun tests in a debugger. If that debugger is pdb, will load '.pdbrc' from current directory if it exists.)�debug-stacktraces�Bz2Report Deferred creation and callback stack traces)�nopmNzFdon't automatically jump into debugger for postmorteming of exceptions)�dry-run�nzdo everything but run the tests)�profileNz#Run tests under the Python profiler)�
until-failure�uzRepeat test until it fails)�debuggerN�pdbzBthe fully qualified name of a debugger to use if --debug is passed)rw�lztest.logru)�jobs�jNzNumber of local workers to run)rrr)r�rt)ry)r�rlr�)r��reactorr�c��	t|�}|dkrtjd��||d<y#t$rtjd|z��wxYw)zN
        Number of local workers to run, a strictly positive integer.
        z,Expecting integer argument to jobs, got '%s'rz4Argument to jobs must be a strictly positive integerr�N)r�r!rr`)r��numbers  r+�opt_jobszOptions.opt_jobs�sf��	���[�F�
�Q�;��"�"�F��
���V����	��"�"�>��G��
�	�s	�-�"Ac��g}|jD].}|j|���||s�|jd|����0|jD]6}|j|���|j	d|��t||�g��8|S)zJ
        Return a list of options to pass to distributed workers.
        z--)�_workerFlagsr7r��_workerParametersr��str)r�r�r�s   r+�_getWorkerArgumentszOptions._getWorkerArguments�s������'�'�	/�F��x�x���+���<��K�K�"�V�H�
�.�	/��,�,�	@�F��x�x���+����r�&��]�C��V��,=�>�?�	@��r-c���tj|�|dr(gd�}|D]}||s�	tjd|z��|dr&|dstjd��dt_yy)Nr�)r�r�r�z(You can't specify --%s when using --jobsr�r�z+You must specify --debug when using --nopm F)rdr�rr`r	�DO_POST_MORTEM)r��	conflictsr�s   r+r�zOptions.postOptions�s|���!�!�$�'���<�A�I�#�
����<��*�*�B�V�K���
�
��<���=��&�&�'W�X�X�%*�G�"�r-N)r�r�r�r�r�r�rr�rDrIr�r�rr�rr�r�r-r+rr�s����	
�	
�
	
�
	<�@�<�'�H�.	
�	6�=�	�M�!�u� � �*��*�*�+F�G�'�
��H�9�L�G��� �+r-r�config�returnc�v�|drtj�|ds|drtjd�yy)Nr�r�T)r	�startDebugModer�setDebugging)rs r+�_initialDebugSetuprs7��
�g����� �
�g��&�!4�5�
���4� �6r-c�P�t|�}|d}|j|d|��S)Nrgr~)�recurse)�
_getLoader�loadByNames)r�loaderr
s   r+�	_getSuiters3��
��
�F���&�&�G����f�W�o�w��?�?r-c�,��tj�}|drDtj���j	|d��fd�|_t
d|dz�n|drt|d\}}||_|dstj|_	|S)Nrpc�$���j�SrC)rp)rn�randomers �r+�<lambda>z_getLoader.<locals>.<lambda>s���(�/�/�"3�r-z$Running tests shuffled with seed %d
r]r�)
r�
TestLoaderrp�Random�seed�sorterr�r_�DestructiveTestSuite�suiteFactory)rrr�rrs    @r+rrs����
�
�
�
 �F�
�h���=�=�?���
�
�f�X�&�'�3��
�
�5��x�8H�H�I�	����v�g��/�	��6���
��/�"�$�9�9����Mr-c�~�tj�}	td�dD]b}t
jj|�s�#	t|�}|5|jj|j��ddd��d|S#t$rt	d�Y�wxYw#1swY��xYw#t$rY��wxYw)zR
    Wrap an instance of C{pdb.Pdb} with readline support and load any .rcs.

    r0zreadline module not available)z.pdbrc�pdbrcN)
r��Pdbr
�ImportErrorr�r<r=�existsr/�rcLinesr��	readlinesrQ)�dbgr=�rcFiles   r+�_wrappedPdbr%(s����'�'�)�C�/��J��$�;��
�7�7�>�>�$��
;��d����;��K�K�&�&�v�'7�'7�'9�:�;�;�;��J���/�
�-�.�/��;�;���
��
�s/�B
�B0�*B$�
B!� B!�$B-	�0	B<�;B<c��eZdZdZy)�_DebuggerNotFoundzk
    A debugger import failed.

    Used to allow translating these errors into usage error messages.

    N)r�r�r�r�r�r-r+r'r'?s��r-r'c��tj}|d|d|d|d|d|d|dd�}|d	rtjj|d
<n�|dr"t}|d|d<|j	�|d
<nc|drNtjj
|d
<|d}|dk7r	t
j|�|d<n
t�|d<|d|d<|d|d<|di|��S#tj$rt|�d���wxYw)z�
    Return a trial runner class set up with the parameters extracted from
    C{config}.

    @return: A trial runner instance.
    rtr�rirkrwrrrm)�reporterFactory�tracebackFormat�realTimeErrors�uncleanWarningsrw�workingDirectory�	exitFirstr��moder��
maxWorkers�workerArgumentsr�r�r�z debugger could not be found.r�rl�forceGarbageCollectionr�)r�TrialRunner�DRY_RUNrr�DEBUGr
r��ModuleNotFoundr'r%)r�clsr�r�s    r+�_makeRunnerr8HsL��!'� 2� 2�C�!�*�-�!�*�-� ��,�!�"4�5��)�$�"�#3�4��K�(��D��i���)�)�1�1��V��	�����#�F�^��\��"(�"<�"<�">��
���'�?�!�-�-�3�3�D��L��j�)�H��5� ��'.�'7�'7��'A�D��$�$/�=��Z� � ��+��Y��)/�
�);��
%�&��;��;����-�-��+�#�,�&C�D����s�'C%�%"Dc�H�ttj�dk(rtjjd�t	�}	|j�t|�	t|�}t|�}|dr|j|�}n|j|�}|j r[tj"d�|j j%�}|j'dd|j)�j*��tj,|j/��y#tj$r&}ttjd�d|����d}~wwxYw#t$r/}ttjd�dt|�����d}~wwxYw)	Nrz--helprz: r�TF)�show_missing�summaryr�)rr�r�r�r�parseOptionsr�error�
SystemExitrr8r'rr�runUntilFailure�runr{r��results�
write_resultsr�r=r��
wasSuccessful)r�ue�trialRunnerrj�suite�
testResultrAs       r+r@r@tsR��
�3�8�8�}���������!�
�Y�F�1������v��5�!�&�)��
�f��E�
�o�� �0�0��7�
� �_�_�U�+�
�
�}�}����T���-�-�'�'�)������u�v���7H�7M�7M�	�	
��H�H��)�)�+�
+�,��)�;�;�1��C�H�H�Q�K�=��2�$�/�0�0��1���5��C�H�H�Q�K�=��3�q�6�(�3�4�4��5�s0�D-�#E)�-E&�!E!�!E&�)	F!�2*F�F!)9r�rOr<r�rpr�r�r�r��typingrrr�twistedr�twisted.applicationr�twisted.internetr�twisted.pythonr	r
r�twisted.python.filepathr�twisted.python.reflectr
�
twisted.trialrr�twisted.trial._dist.disttrialr�twisted.trial.unittestrr�r,r4r9rArIrVr�r_rbrdr�ReactorSelectionMixinrrrrr%�	Exceptionr'�_Runnerr8r@r�r-r+�<module>rUsQ��
��	�
�
�
����+�+��#�"�2�2�,�.�(�9�,�
��
�
�
��
���2�""�U�X��B	N�����
	O���	�
��&~T�~T�Bd+�m�U�]�]�C�,E�,E�d+�N!�w�!�4�!�@�g�@�)�@��w��6�#4�#4���.�	��)��)�F�N�N�)�X-�X�-r-

Zerion Mini Shell 1.0