%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/samba/subunit/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/samba/subunit/__pycache__/run.cpython-312.pyc

�

�I�dc`����dZddlZddlZddlZddlZGd�dej
�Zdd�Zdd�Zd�Z	ejZ
ejZe
e
d	d��%	ddlZej�Z
ejZd
Znd
ZdZdZd
ZGd�de�ZGd�de�ZGd�de�ZGd�de�ZGd�de�Zedk(r edej8ej:��yy#e$rdZY�lwxYw)znRun a unittest testcase reporting results as Subunit.

  $ python -m samba.subunit.run mylib.tests.test_suite
�Nc�X��eZdZdZd�Zdd�Zd�Z�fd�Z�fd�Zd�Z	d�Z
d	�Zd
�Z�xZ
S)�TestProtocolClienta�A TestResult which generates a subunit stream for a test run.

    # Get a TestSuite or TestCase to run
    suite = make_suite()
    # Create a stream (any object with a 'write' method). This should accept
    # bytes not strings: subunit is a byte orientated protocol.
    stream = open('tests.log', 'wb')
    # Create a subunit result object which will output to the stream
    result = subunit.TestProtocolClient(stream)
    # Optionally, to get timing data for performance analysis, wrap the
    # serialiser with a timing decorator
    result = subunit.test_results.AutoTimingTestResultDecorator(result)
    # Run the test suite reporting to the subunit result object
    suite.run(result)
    # Close the stream.
    stream.close()
    c�^�tjj|�||_g|_y�N)�unittest�
TestResult�__init__�_stream�	successes)�self�streams  �3/usr/lib/python3/dist-packages/samba/subunit/run.pyr	zTestProtocolClient.__init__4s$�����$�$�T�*�������c��|jjd|z|j�z�|r�|jjd�|D]J}|jj|�|jd�r�0|jjd��L|jjd�|jjd�y)z�Report an outcome of test test.

        :param outcome: A string describing the outcome - used as the
            event name in the subunit stream.
        :param errors: A list of strings describing the errors.
        z%s: z [
�
�]N)r
�write�id�endswith)r�outcome�test�errors�errors     r�_addOutcomezTestProtocolClient._addOutcome9s���	
�����F�W�,����	�9�:���L�L���v�&��
-�����"�"�5�)��~�~�d�+��L�L�&�&�t�,�
-�
�L�L���s�#������4� rc�:�|jj|�y)zReport a success in a test.N)r�append�rrs  r�
addSuccesszTestProtocolClient.addSuccessJs�������d�#rc���tt|�|�|jj	d|j�zdz�|jj
�y)z%Mark a test as starting its test run.ztest: rN)�superr�	startTestr
rr�flush�rr�	__class__s  �rr!zTestProtocolClient.startTestNsE���
� �$�1�$�7������8�d�g�g�i�/�$�6�7������rc�N��tt|�|�|j|�y)z,Mark a test as having finished its test run.N)r r�stopTest�writeOutcomer#s  �rr&zTestProtocolClient.stopTestTs!���
� �$�0��6����$�rc�f�|j||j�\}|_|j||j�\}|_|j||j�\}|_|j||j�\}|_|j||j�\}|_|j||j�\}|_|rd}n|rd}n|rd}n|rd}n|rd}n|rd}nd}|r|j||||z|z|z��|jj�y)	z)Output the overall outcome for test test.r�failure�skip�	uxsuccess�xfail�
successfulN)r)�
_filterErrorsr�failures�expectedFailures�skipped�_filterSuccessesr�unexpectedSuccessesrr
r")	rr�err�failr,r*�successr+rs	         rr'zTestProtocolClient.writeOutcomeYs ��.2�.@�.@��$�+�+�.V���4�;�.2�.@�.@��$�-�-�.X� ��4�=�.2�.@�.@��$�J_�J_�.`�(��4�(�.2�.@�.@��$�,�,�.W���4�<�.2�.C�.C�D�$�.�.�.Y�!��4�>�.2�.C�.C�D�$�Jb�Jb�.c�+�	�4�+���G�
��G�
��G�
�!�G�
��G�
�"�G��G�����W�d�3�t�8�D�=��3F��G������rc�z�g}g}|D]/}|d|ur|j|d��|j|��1||fS)a^Filter a list of errors by test test.

        :param test: The test to filter by.
        :param errors: A list of <test, error> pairs to filter.

        :return: A pair whose first element is a list of strings containing
            errors that apply to test test, and whose second element is a list
            of the remaining elements.
        r��r)rrr�filtered�
unfilteredrs      rr.z TestProtocolClient._filterErrorsvsT�����
��	)�E��Q�x�4������a��)��!�!�%�(�		)��*�%�%rc�P�d}g}|D]}||urd}�
|j|��||fS)abFilter a list of successes by test test.

        :param test: The test to filter by.
        :param successes: A list of tests to filter.

        :return: A tuple whose first element is a boolean stating whether test
            test was found in the list of successes, and whose second element is
            a list of the remaining elements.
        FTr9)rrrr:r;r6s      rr2z#TestProtocolClient._filterSuccesses�sD�����
� �	+�G��$�����!�!�'�*�		+��*�%�%rc
�,�|jtjj�}|jjd|j|j|j|j|j|j|jfz�y)z^Inform the client of the time.

        ":param datetime: A datetime.datetime object.
        z*time: %04d-%02d-%02d %02d:%02d:%02d.%06dZ
N)
�
astimezone�datetime�timezone�utcr
r�year�month�day�hour�minute�second�microsecond)r�
a_datetime�times   rrJzTestProtocolClient.time�sn��
�$�$�X�%6�%6�%:�%:�;�������H��I�I�t�z�z�4�8�8�T�Y�Y�����K�K��)�)�L+�+�	,rr)�__name__�
__module__�__qualname__�__doc__r	rrr!r&r'r.r2rJ�
__classcell__�r$s@rrr!s5����$�
!�"$�� �
�:&�*&�*,rrFc�r�	t|�}t|�tj
fvs|r%g}|D]}|j
t|���|Sd}t|�}|D]}|j�}nt|dd��|j�||fgS#t$r|j�|fgcYSwxYw)N�
sort_tests)�iter�	TypeErrorr�typer�	TestSuite�extend�_flatten_tests�
iterate_tests�getattrrR)�
suite_or_case�unpack_outer�tests�resultr�suite_ids      rrXrX�s���5��]�#��	
�]��� 2� 2�4�4�����	0�D��M�M�.��.�/�	0��
����m�,���	�D��w�w�y�H��	��=�,��5�A��$�$�&��=�)�*�*��+�5��!�!�#�]�3�4�4�5�s�B�B6�5B6c��t||��}|j�tj|D��cgc]\}}|��	c}}�Scc}}w)z;Sort suite_or_case while preserving non-vanilla TestSuites.)r\)rX�sortrrV)r[r\r]�sort_keyrs     r�sorted_testsrc�s;���=�|�D�E�	�J�J�L����E�B�(8��4�t�B�C�C��Bs�A
c#�K�	t|�}|D]}t|�D]}|����y#t$r|��YywxYw�w)z>Iterate through all of the test cases in 'test_suite_or_case'.N)rSrYrT)�test_suite_or_case�suiter�subtests    rrYrY�sV������'�(���	�D�(��.�
���
�
�	���!� � �!�s�>�+�>�
;�>�;�>�discoverTz7  -c, --catch      Catch control-C and display results
z=  -b, --buffer     Buffer stdout and stderr during test runs
a/Usage: %(progName)s [options] [tests]

Options:
  -h, --help       Show this message
  -v, --verbose    Verbose output
  -q, --quiet      Minimal output
  -l, --list       List tests rather than executing them.
  --load-list      Specifies a file containing test ids, only tests matching
                   those ids are executed.
%(catchbreak)s%(buffer)s
Examples:
  %(progName)s test_module               - run tests from test_module
  %(progName)s module.TestClass          - run tests from module.TestClass
  %(progName)s module.Class.test_method  - run specified test method

All options must come before [tests].  [tests] can be a list of any number of
test modules, classes and test methods.

Alternative Usage: %(progName)s discover [options]

Options:
  -v, --verbose    Verbose output
s%(catchbreak)s%(buffer)s  -s directory     Directory to start discovery ('.' default)
  -p pattern       Pattern to match test files ('test*.py' default)
  -t directory     Top level directory of project (default to
                   start directory)
  -l, --list       List tests rather than executing them.
  --load-list      Specifies a file containing test ids, only tests matching
                   those ids are executed.

For test discovery all test modules must be importable from the top
level directory of the project.
c��eZdZdZd�Zd�Zd�Zd�Zd�Zdd�Z	dd	�Z
d
�Zdd�Zdd�Z
d
�Zd�Zed��Zd�Zed��Zd�Zy)�TestResultDecoratoraGeneral pass-through decorator.

    This provides a base that other TestResults can inherit from to
    gain basic forwarding functionality. It also takes care of
    handling the case where the target doesn't support newer methods
    or features by degrading them.
    c��||_y)z5Create a TestResultDecorator forwarding to decorated.N)�	decorated)rrls  rr	zTestResultDecorator.__init__1s��#��rc�8�|jj|�Sr)rlr!rs  rr!zTestResultDecorator.startTest6s���~�~�'�'��-�-rc�6�|jj�Sr)rl�startTestRun�rs rroz TestResultDecorator.startTestRun9s���~�~�*�*�,�,rc�8�|jj|�Sr)rlr&rs  rr&zTestResultDecorator.stopTest<s���~�~�&�&�t�,�,rc�6�|jj�Sr)rl�stopTestRunrps rrszTestResultDecorator.stopTestRun?s���~�~�)�)�+�+rNc�:�|jj||�Sr)rl�addError�rrr4s   rruzTestResultDecorator.addErrorBs���~�~�&�&�t�S�1�1rc�:�|jj||�Sr)rl�
addFailurervs   rrxzTestResultDecorator.addFailureEs���~�~�(�(��s�3�3rc�8�|jj|�Sr)rlrrs  rrzTestResultDecorator.addSuccessHs���~�~�(�(��.�.rc�:�|jj||�Sr)rl�addSkip�rr�reasons   rr{zTestResultDecorator.addSkipKs���~�~�%�%�d�F�3�3rc�:�|jj||�Sr)rl�addExpectedFailurervs   rrz&TestResultDecorator.addExpectedFailureNs���~�~�0�0��s�;�;rc�8�|jj|�Sr)rl�addUnexpectedSuccessrs  rr�z(TestResultDecorator.addUnexpectedSuccessQs���~�~�2�2�4�8�8rc�6�|jj�Sr)rl�
wasSuccessfulrps rr�z!TestResultDecorator.wasSuccessfulTs���~�~�+�+�-�-rc�.�|jjSr�rl�
shouldStoprps rr�zTestResultDecorator.shouldStopW����~�~�(�(�(rc�6�|jj�Sr)rl�stoprps rr�zTestResultDecorator.stop[s���~�~�"�"�$�$rc�.�|jjSr)rl�testsRunrps rr�zTestResultDecorator.testsRun^s���~�~�&�&�&rc�8�|jj|�Sr)rlrJ�rrIs  rrJzTestResultDecorator.timebs���~�~�"�"�:�.�.rr)rKrLrMrNr	r!ror&rsrurxrr{rr�r��propertyr�r�r�rJ�rrrjrj(su���#�
.�-�-�,�2�4�/�4�<�9�.��)��)�%��'��'�/rrjc���eZdZdZ�fd�Zd�Zd�Zd�Zd�Zdd�Z	dd�Z
d	�Zdd
�Zdd�Z
d�Zd
�Zed��Zd�Zd�Z�xZS)�HookedTestResultDecoratorz/A TestResult which calls a hook on every event.c�f��tt|�|_|jj|�yr)r r�r	�rrlr$s  �rr	z"HookedTestResultDecorator.__init__is$����4�d�;��
��
�
���I�&rc�X�|j�|jj|�Sr)�
_before_eventr r!rs  rr!z#HookedTestResultDecorator.startTestms#�������z�z�#�#�D�)�)rc�V�|j�|jj�Sr)r�r rorps rroz&HookedTestResultDecorator.startTestRunqs!�������z�z�&�&�(�(rc�X�|j�|jj|�Sr)r�r r&rs  rr&z"HookedTestResultDecorator.stopTestus#�������z�z�"�"�4�(�(rc�V�|j�|jj�Sr)r�r rsrps rrsz%HookedTestResultDecorator.stopTestRunys!�������z�z�%�%�'�'rc�Z�|j�|jj||�Sr)r�r rurvs   rruz"HookedTestResultDecorator.addError}s%�������z�z�"�"�4��-�-rc�Z�|j�|jj||�Sr)r�r rxrvs   rrxz$HookedTestResultDecorator.addFailure�s%�������z�z�$�$�T�3�/�/rc�X�|j�|jj|�Sr)r�r rrs  rrz$HookedTestResultDecorator.addSuccess�s#�������z�z�$�$�T�*�*rc�Z�|j�|jj||�Sr)r�r r{r|s   rr{z!HookedTestResultDecorator.addSkip�s%�������z�z�!�!�$��/�/rc�Z�|j�|jj||�Sr)r�r rrvs   rrz,HookedTestResultDecorator.addExpectedFailure�s%�������z�z�,�,�T�3�7�7rc�X�|j�|jj|�Sr)r�r r�rs  rr�z.HookedTestResultDecorator.addUnexpectedSuccess�s#�������z�z�.�.�t�4�4rc�V�|j�|jj�Sr)r�r r�rps rr�z'HookedTestResultDecorator.wasSuccessful�s!�������z�z�'�'�)�)rc�N�|j�|jjSr)r�r r�rps rr�z$HookedTestResultDecorator.shouldStop�s�������z�z�$�$�$rc�V�|j�|jj�Sr)r�r r�rps rr�zHookedTestResultDecorator.stop�s�������z�z��� � rc�X�|j�|jj|�Sr)r�r rJr�s  rrJzHookedTestResultDecorator.time�s!�������z�z���z�*�*rr)rKrLrMrNr	r!ror&rsrurxrr{rr�r�r�r�r�rJrOrPs@rr�r�fs`���9�'�*�)�)�(�.�0�+�0�8�5�*��%��%�!�+rr�c�>��eZdZdZ�fd�Zd�Zed��Zd�Z�xZ	S)�AutoTimingTestResultDecoratoraDecorate a TestResult to add time events to a test run.

    By default this will cause a time event before every test event,
    but if explicit time data is being provided by the test run, then
    this decorator will turn itself off to prevent causing confusion.
    c�:��d|_tt|�|�yr)�_timer r�r	r�s  �rr	z&AutoTimingTestResultDecorator.__init__�s�����
�
�+�T�;�I�Frc���|j}|�ytjj�jtjj
��}|jj|�y)N)�tzinfo)r�r?�utcnow�replacer@rArlrJ)rrJs  rr�z+AutoTimingTestResultDecorator._before_event�sT���z�z������ � �'�'�)�1�1��9J�9J�9N�9N�1�O�������D�!rc�.�|jjSrr�rps rr�z(AutoTimingTestResultDecorator.shouldStop�r�rc�F�||_|jj|�S)a\Provide a timestamp for the current test activity.

        :param a_datetime: If None, automatically add timestamps before every
            event (this is the default behaviour if time() is not called at
            all).  If not None, pass the provided time onto the decorated
            result object and disable automatic timestamps.
        )r�rlrJr�s  rrJz"AutoTimingTestResultDecorator.time�s �� ��
��~�~�"�"�:�.�.r)
rKrLrMrNr	r�r�r�rJrOrPs@rr�r��s,����G�"��)��)�	/rr�c��eZdZdd�Zd�Zy)�SubunitTestRunnerNc�6�|xstj|_y)zhCreate a SubunitTestRunner.

        :param verbosity: Ignored.
        :param buffer: Ignored.
        N)�sys�stdoutr
)r�	verbosity�bufferr
s    rr	zSubunitTestRunner.__init__�s���*��
�
��rc�V�t|j�}t|�}||�|S)z&Run the given test case or test suite.)rr
r�)rrr^s   r�runzSubunitTestRunner.run�s&��#�D�K�K�0��.�v�6���V���
r)NNN)rKrLrMr	r�r�rrr�r��s��+�rr�c
�`�eZdZdZeZdxZxZZeddde	dddddf
d�Z
d�Zd�Ze
fd�Zd	�Zdd
�Zy)�TestProgramzA command-line program that runs a set of tests; this is primarily
       for making test modules conveniently executable.
    NTr8c�.�|tk(rd|_n\t|t�rEt	|�|_|jd�ddD]}t
|j|�|_�n||_|�tj}|
�tj}
|�
t�}||_||_||_
|	|_||_d|_d|_||_||_|d}|j)dt*j,j.z�r2|jt*j,j.�}
d|
dz}n"t*j,j1|d�}||_|j5|�|j"r�t7|j"d�}	|j9�}|j;�t=d	�|D��}t?j@�}tC|jD�D]&}|jG�|vs�|jI|��(||_"|j s|jK�ytC|jD�D]$}|
jMd
|jG�z��&y#|j;�wxYw)N�.r8Frz%srun.pyz%s.run����rbc3�ZK�|]#}|j�jd����%y�w)zutf-8N)�strip�decode)�.0�lines  r�	<genexpr>z'TestProgram.__init__.<locals>.<genexpr>s!����J�D�4�:�:�<�.�.�w�7�J�s�)+z%s
)'rK�module�
isinstance�str�
__import__�splitrZr��argvr�r��exit�
catchbreakr�r��defaultTest�	listtests�	load_list�
testRunner�
testLoaderr�os�path�sep�basename�progName�	parseArgs�open�	readlines�close�setrrVrYrr�addTest�runTestsr)rr�r�r�r�r�r�r�r�r�r��partr��elements�source�lines�test_idsr:rs                   rr	zTestProgram.__init__�s���X���D�K�
���
$�$�V�,�D�K����S�)�!�"�-�
9��%�d�k�k�4�8���
9�!�D�K��<��8�8�D��>��Z�Z�F���*�,�J���	�$���"������&���������$���$�����7�����Z�"�'�'�+�+�5�6��~�~�b�g�g�k�k�2�H��(�2�,�.�H��w�w�'�'��Q��0�H� ��
����t���>�>�
�$�.�.�$�/�F�
��(�(�*�������J�E�J�J�H��)�)�+�H�%�d�i�i�0�
+���7�7�9��(��$�$�T�*�
+�!�D�I��~�~��M�M�O�%�d�i�i�0�
1�����V�d�g�g�i�/�0�
1������s�J�Jc���t|�dkDr+|dj�dk(r|j|dd�yddl}gd�}	|j|ddd|�\}}|D]u\}}|dvr|j	�|dvrd|_|d	vrd|_|d
vr|j�d|_|dvr|j�d|_|d
vrd|_|dk(s�o||_	�wt|�dk(r|j�d|_n(t|�dkDr||_n|jf|_|j�y#|j$r)|j	tj�d�YywxYw)Nr8rh�r)�help�verbose�quiet�catchr��listz
load-list=�hHvqfcbl)z-hz-Hz--help)z-qz--quiet)�-v�	--verbose)�-c�--catchT)�-b�--buffer)�-l�--list�--load-list)�len�lower�
_do_discovery�getopt�	usageExitr�r�r�r�r�r��	testNames�createTestsrr��exc_info)rr�r��	long_opts�options�args�opt�values        rr�zTestProgram.parseArgssp���t�9�q�=�T�!�W�]�]�_�
�:����t�A�B�x�(���"�	�	.�"�M�M�$�q�r�(�J�	�J�M�G�T�%�
+�
��U��.�.��N�N�$��*�*�%&�D�N��,�,�%&�D�N��*�*����.�*.����+�+��{�{�*�&*����*�*�%)�D�N��-�'�%*�D�N�%
+�&�4�y�A�~�$�"2�"2�":�!%����T��Q��!%���"&�"2�"2�!4���������|�|�	.��N�N�3�<�<�>�!�,�-�	.�s�B	D1�
A#D1�15E)�(E)c���|j�+|jj|j�|_y|jj|j|j�|_yr)r�r��loadTestsFromModuler�r�loadTestsFromNamesrps rr�zTestProgram.createTestsGsJ���>�>�!����;�;�D�K�K�H�D�I����:�:�4�>�>�;?�;�;�H�D�Irc�Z�tstd��d|jz|_ddl}|j	�}|j|_|j
dddddd	�
�|jdk7r|j
ddd
ddd	�
�|jdk7r|j
dddddd	�
�|j
ddddd��|j
ddddd��|j
ddd dd!��|j
d"d#d$dd	d%�&�|j
d'd(dd)��|j|�\}}t|�d*kDr|j�td+|�D]\}}t|||��|j�|j|_|j�|j|_|j|_|j|_|j rd,|_|j$}	|j&}
|j(}|�}|j+|	|
|�}
t-|
�|_y)-NzYUnable to use discovery, must use python 2.7 or greater, or install the discover package.z%s discoverrr�r�r�FzVerbose output�
store_true)�dest�defaultr��actionr�r�r�z'Catch ctrl-C and display results so farr�r�r�z%Buffer stdout and stderr during testsz-sz--start-directory�startr�z*Directory to start discovery ('.' default))rrr�z-pz	--pattern�patternztest*.pyz+Pattern to match tests ('test*.py' default)z-tz--top-level-directory�topz<Top level directory of project (defaults to start directory)r�r�r�z$List tests rather than running them.)rrrr�r�r�z2Specify a filename containing the test ids to use.�)rrrr�)�
have_discover�AssertionErrorr��optparse�OptionParser�prog�
add_optionr�r��
parse_argsr�r��zip�setattrr�r�r�r�rrrrhrcr)rr��Loaderr�parserr�r��namer��	start_dirr�
top_level_dir�loader�loadeds              rr�zTestProgram._do_discoveryNsM��� �"C�D�
D�%��
�
�5��
���&�&�(���m�m������$��)�U�/��	�	F��?�?�e�#����d�I�L�%�#L�%1�
�
3��;�;�%�����d�J�X�u�#J�%1�
�
3�	���$� 3�'�3�K�	�	M����$��)�Z�L�	�	N����$� 7�e�T�]�	�	_����$��{�E�R^�E�	�	G����-�k�4�S�	�	U��)�)�$�/�
����t�9�q�=��N�N���:�D�A�	*�K�D�%��G�T�5�)�	*�
�?�?�"�%�0�0�D�O��;�;��!�.�.�D�K� �*�*��� �*�*����?�?��D�N��M�M�	��/�/�����
��������G�]�C�� ��(��	rc�0�|jr%ttdd��tj�|jj|j�|_|jr/tj|jj��yy)N�installHandler)r�rZrrr�r�rr^r�r�r�rps rr�zTestProgram.runTests�sg���O�O���"2�D�9�E��#�#�%��o�o�)�)�$�)�)�4����9�9��H�H����2�2�4�4�5�rc��|rt|�|jddd�}|jdk7r	t|d<|jdk7r	t
|d<|j|z}|jd�}|jdd�|jd	d�tdj|��tjd�y)
N�)r�r�r�Fr�r�rr�z)Run a test suite with a subunit reporter.r	)�printr�r��
CATCHBREAKr��BUFFEROUTPUT�USAGEr��insert�joinr�r�)r�msg�usage�
usage_text�usage_liness     rr�zTestProgram.usageExit�s�����3�K�!�]�]�"�����?�?�e�#�",�E�,���;�;�%��*�E�(�O��Z�Z�%�'�
� �&�&�t�,�����1�I�J����1�b�!�
�d�i�i��$�%�����rr)rKrLrMrN�
USAGE_AS_MAINr!r�r�r��defaultTestLoaderr	r�r��defaultTestLoaderClsr�r�r�r�rrr�r��s`���
�E�&*�)�J�)��(�&�D�t�#�0A���t���81�t&.�PH�*>�@)�D6�rr��__main__)r�r�r�)F)rNr?r�r�rrrrXrcrYr)�
TestLoaderr*rZrh�DiscoveringTestLoaderr
�ImportErrorrr r(�objectrjr�r�r�r�rKr�r�r�rr�<module>r0s+��,�
�	�
��G,��,�,�G,�T+�6D�	��.�.���*�*��
��j�$�/�7���:�H�:�:�<��'�=�=���
��M�4J�
�O��!�
�L;/�&�;/�|>+� 3�>+�B /�$=� /�F���$J�&�J�Z�z���t�#�(�(�3�:�:�>���O���
��s�#C�C)�(C)

Zerion Mini Shell 1.0