Current File : //usr/lib/python3/dist-packages/twisted/scripts/test/__pycache__/test_scripts.cpython-312.pyc |
�
Ϫ�f� � � � d Z ddlmZmZmZ ddlmZmZ ddlm Z ddl
mZ ddlm
Z
ddlmZ ddlmZmZ d � Z G d
� d� Z G d� d
ee� Z G d� 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 � � t t d� 5 }t t d� 5 }t t | j gt |� z t ||�� }|j � d }ddd� ddd� S # 1 sw Y �xY w# 1 sw Y S xY w)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�stdinr N)�openr r r �path�listr �communicate)�script�args� nullInput� nullError�processr s �C/usr/lib/python3/dist-packages/twisted/scripts/test/test_scripts.py�outputFromPythonScriptr s� � �$
�g�t� � *� �4���+>� *�)��
����%��T�
�2����
�� �$�$�&�q�)��*� *� �M�*� *�� *� �M�s# �B�AA7�%B�7B �<B�B
c �l � e Zd ZdZ ed� j
j j d� Zd� Z y)�ScriptTestsMixinzr
Mixin for L{TestCase} subclasses which defines a helper function for testing
a Twisted-using script.
�twisted�binc �� � | j j |� }|j � st d� �ddlm} t
|d� }| j t |� |� 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"