%PDF- %PDF-
Mini Shell

Mini Shell

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

�

Ϫ�f����dZddlmZmZmZddlmZmZddlm	Z	ddl
mZddlm
Z
ddlmZddlmZmZd	�ZGd
�d�ZGd�d
ee�ZGd�dee�Zy)z�
Tests for the command-line scripts in the top-level I{bin/} directory.

Tests for actual functionality belong elsewhere, written in a way that doesn't
involve launching child processes.
�)�chdir�devnull�getcwd)�PIPE�Popen)�
executable)�FilePath)�	getModule)�ZshScriptTestMixin)�SkipTest�TestCasec� �ttd�5}ttd�5}tt|jgt|�zt||��}|j�d}ddd�ddd�S#1swY�xYw#1swYSxYw)a�
    Synchronously run a Python script, with the same Python interpreter that
    ran the process calling this function, using L{Popen}, using the given
    command-line arguments, with standard input and standard error both
    redirected to L{os.devnull}, and return its output as a string.

    @param script: The path to the script.
    @type script: L{FilePath}

    @param args: The command-line arguments to follow the script in its
        invocation (the desired C{sys.argv[1:]}).
    @type args: L{tuple} of L{str}

    @return: the output passed to the proces's C{stdout}, without any messages
        from C{stderr}.
    @rtype: L{bytes}
    �rb�wb)�stdout�stderr�stdinrN)�openrrr�path�listr�communicate)�script�args�	nullInput�	nullError�processrs      �C/usr/lib/python3/dist-packages/twisted/scripts/test/test_scripts.py�outputFromPythonScriptrs���$
�g�t�	�*�	�4���+>�*�)��
����%��T�
�2����	
���$�$�&�q�)��*�*��M�*�*��*��M�s#�B�AA7�%B�7B	�<B�B
c�l�eZdZdZed�j
jjd�Zd�Z	y)�ScriptTestsMixinzr
    Mixin for L{TestCase} subclasses which defines a helper function for testing
    a Twisted-using script.
    �twisted�binc���|jj|�}|j�std��ddlm}t
|d�}|jt|�|�y)a�
        Verify that the given script runs and uses the version of Twisted
        currently being tested.

        This only works when running tests against a vcs checkout of Twisted,
        since it relies on the scripts being in the place they are kept in
        version control, and exercises their logic for finding the right version
        of Twisted to use in that situation.

        @param name: A path fragment, relative to the I{bin} directory of a
            Twisted source checkout, identifying a script to test.
        @type name: C{str}

        @raise SkipTest: if the script is not where it is expected to be.
        �5Script tests do not apply to installed configuration.r)�versionz	--versionN)	r"�preauthChild�existsr�twisted.copyrightr%r�assertIn�str)�self�namerr%�
scriptVersions     r�
scriptTestzScriptTestsMixin.scriptTest:sN�� ���&�&�t�,���}�}���R�S�S�-�.�v�{�C�
��
�
�c�'�l�M�2�N)
�__name__�
__module__�__qualname__�__doc__r
�	pathEntry�filePath�childr"r.�r/rr r 2s/���
�I�
�
(�
(�
1�
1�
7�
7��
>�C�3r/r c�4�eZdZdZdd�Zd�Zdd�Zd�Zdd�Zy)	�ScriptTestsz%
    Tests for the core scripts.
    Nc�&�|jd�y)N�twistd�r.�r+s r�test_twistdzScriptTests.test_twistdZs������!r/c���|jjd�}|j�std��t	�}|jt|�t|j��}|j�t
|j�|jd�jd�t|dd�}|jt|j�|�y)z�
        The twistd script adds the current working directory to sys.path so
        that it's able to import modules from it.
        r;r$zbar.taczimport sys
print sys.path
z-nyN)r"r6r'rr�
addCleanuprr	�mktemp�makedirsr�
setContentrr)�repr�r+r�cwd�testDir�outputs     r�test_twistdPathInsertz!ScriptTests.test_twistdPathInsert]s���
������)���}�}���R�S�S��h������s�#��4�;�;�=�)������
�g�l�l���
�
�i� �+�+�,M�N�'���y�A���
�
�d�7�<�<�(�&�1r/c�&�|jd�y)N�trialr<r=s r�
test_trialzScriptTests.test_trialns������ r/c��|jjd�}|j�std��t	�}|jt|�t|j��}|j�t
|j�|jd�jd�t|d�}|jd|�y)z�
        The trial script adds the current working directory to sys.path so that
        it's able to import modules from it.
        rKr$zfoo.py��foo�PASSEDN)r"r6r'rrr@rr	rArBrrCrr)rEs     r�test_trialPathInsertz ScriptTests.test_trialPathInsertqs���
������(���}�}���R�S�S��h������s�#��4�;�;�=�)������
�g�l�l���
�
�h��*�*�2�.�'���6���
�
�h��'r/c�&�|jd�y)N�
pyhtmlizerr<r=s r�test_pyhtmlizerzScriptTests.test_pyhtmlizer�s������%r/)�returnN)	r0r1r2r3r>rIrLrQrTr7r/rr9r9Us ���"�2�"!�(�"&r/r9c��eZdZdZgd�Zy)�ZshIntegrationTestszH
    Test that zsh completion functions are generated without error
    ))r;z$twisted.scripts.twistd.ServerOptions)rKztwisted.scripts.trial.Options)rSz twisted.scripts.htmlizer.OptionsN)r0r1r2r3�generateForr7r/rrWrW�s����Kr/rWN)r3�osrrr�
subprocessrr�sysr�twisted.python.filepathr	�twisted.python.modulesr
�"twisted.python.test.test_shellcompr�twisted.trial.unittestrr
rr r9rWr7r/r�<module>r`sS���&�%�"��,�,�A�5��: 3� 3�F.&�(�,�.&�b	�(�$6�	r/

Zerion Mini Shell 1.0