%PDF- %PDF-
Mini Shell

Mini Shell

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

�

Ϫ�f����dZddlZddlZddlmZddlmZddlmZm	Z	Gd�d�Z
Gd�d	e
e	�ZGd
�de
e	�ZGd�d
e
e	�Z
Gd�de
e	�Zy)z-
Tests for L{twisted.names} example scripts.
�N)�StringIO)�FilePath)�SkipTest�TestCasec�.�eZdZdZd�Zd�Zd�Zd�Zd�Zy)�ExampleTestBasea�
    This is a mixin which adds an example to the path, tests it, and then
    removes it from the path and unimports the modules which the test loaded.
    Test cases which test example code and documentation listings should use
    this.

    This is done this way so that examples can live in isolated path entries,
    next to the documentation, replete with their own plugin packages and
    whatever other metadata they need.  Also, example code is a rare instance
    of it being valid to have multiple versions of the same code in the
    repository at once, rather than relying on version control, because
    documentation will often show the progression of a single piece of code as
    features are added to it, and we want to test each one.
    c�~�tjdd|_tjj	�|_t
�|_|jtd|j�t
�|_	|jtd|j�	ttjd�jd�}|j j#d�D]<}|j|�}|j%�r�%td|j�d	���||_tjj)|j&j+�j�|j&j-�j#d
�d}t/|�|_y#t$rtd��wxYw)zn
        Add our example directory to the path and record which modules are
        currently loaded.
        N�stderr�stdout�TOX_INI_DIR�docsz5Examples not found ($TOX_INI_DIR unset) - cannot test�/z
Examples (z) not found - cannot test�.r)�sys�path�originalPath�modules�copy�originalModulesr�fakeErr�patch�fakeOutr�os�environ�child�KeyErrorr�exampleRelativePath�split�exists�examplePath�append�parent�basename�
__import__�example)�self�here�	childName�
moduleNames    �B/usr/lib/python3/dist-packages/twisted/names/test/test_examples.py�setUpzExampleTestBase.setUp!s`��
 �H�H�Q�K���"�{�{�/�/�1��� �z����
�
�3��$�,�,�/��z����
�
�3��$�,�,�/�	��B�J�J�}�5�6�<�<�V�D�D��1�1�7�7��<�	R�I��:�:�i�(�D��;�;�=���D�I�I�;�6O�P�Q�Q�	R� ���	������(�(�/�/�1�6�6�7��%�%�.�.�0�6�6�s�;�A�>�
�!�*�-����#�	��G��
�	�s�+F'�'F<c���tjj�tjj|j�|j
tjddy)z�
        Remove the example directory from the path and remove all
        modules loaded by the test from sys.modules.
        N)rr�clear�updaterrr)r&s r*�tearDownzExampleTestBase.tearDownEs?��
	�����������4�/�/�0��'�'������c��|jj�5}|j|j�j	�d�ddd�y#1swYyxYw)zK
        The example scripts start with the standard shebang line.
        s#!/usr/bin/env pythonN)r �open�assertEqual�readline�rstrip)r&�fs  r*�test_shebangzExampleTestBase.test_shebangNsQ���
�
�
"�
"�
$�	N�����Q�Z�Z�\�0�0�2�4L�M�	N�	N�	N�s�/A�Ac��|jt|jjdd�|jj�j
�}|j|djd�d|d���y)z�
        The example script prints a usage message to stdout if it is
        passed a --help option and then exits.

        The first line should contain a USAGE summary, explaining the
        accepted command arguments.
        Nz--helpr�Usage:�=Usage message first line should start with "Usage:". Actual: )	�assertRaises�
SystemExitr%�mainr�getvalue�
splitlines�
assertTrue�
startswith)r&�outs  r*�test_usageConsistencyz%ExampleTestBase.test_usageConsistencyUsg��	
���*�d�l�l�&7�&7��x�H��l�l�#�#�%�0�0�2�������F���h�'���F�
%�	
r0c�T�|jt|jjdd�|jj�j
�}|j|djd�d|d���|j|djd�d|d���y)	a`
        The example script prints a usage message to stderr if it is
        passed unrecognized command line arguments.

        The first line should contain a USAGE summary, explaining the
        accepted command arguments.

        The last line should contain an ERROR summary, explaining that
        incorrect arguments were supplied.
        Nz--unexpected_argumentrr9r:���zERROR:z;Usage message last line should start with "ERROR:" Actual: )	r;r<r%r=rr>r?r@rA)r&�errs  r*�test_usageConsistencyOnErrorz,ExampleTestBase.test_usageConsistencyOnErrorhs���	
���*�d�l�l�&7�&7��?V�W��l�l�#�#�%�0�0�2�������F���h�'���F�
%�	
�
	
�����G���x�(���G�
&�	
r0N)	�__name__�
__module__�__qualname__�__doc__r+r/r7rCrG�r0r*rrs"��
�".�H(�N�
�&
r0rc��eZdZdZdZy)�TestDnsTestsz-
    Test the testdns.py example script.
    znames/examples/testdns.pyN�rHrIrJrKrrLr0r*rNrN�s���6�r0rNc��eZdZdZdZy)�GetHostByNameTestsz3
    Test the gethostbyname.py example script.
    znames/examples/gethostbyname.pyNrOrLr0r*rQrQ�s���<�r0rQc��eZdZdZdZy)�DnsServiceTestsz1
    Test the dns-service.py example script.
    znames/examples/dns-service.pyNrOrLr0r*rSrS�s���:�r0rSc��eZdZdZdZy)�MultiReverseLookupTestsz:
    Test the multi_reverse_lookup.py example script.
    z&names/examples/multi_reverse_lookup.pyNrOrLr0r*rUrU�s���C�r0rU)rKrr�ior�twisted.python.filepathr�twisted.trial.unittestrrrrNrQrSrUrLr0r*�<module>rYsb���

�
��,�5�p
�p
�f6�?�H�6�<��(�<�:�o�x�:�C�o�x�Cr0

Zerion Mini Shell 1.0