HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //usr/lib/python3/dist-packages/twisted/mail/test/__pycache__/test_bounce.cpython-310.pyc
o

�b��@sNddlZddlZddlmZmZddlmZddlm	Z	Gdd�de	j
�ZdS)�N)�BytesIO�StringIO)�bounce)�unittestc@s8eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�ZdS)
�BounceTestsz#
    Bounce message generation
    cCs�t�td�dd�\}}}|�|d�|�|d�tj��}|�t|�d���}|�|dd�|�|dd	�|�|d
d�dS)
zN
        L{twisted.mail.bounce.generateBounce} can accept L{unicode}.
        zRFrom: Moshe Zadka <moshez@example.com>
To: nonexistent@example.org
Subject: test

�moshez@example.com�nonexistent@example.org��moshez@example.com�utf-8�To�From�postmaster@example.org�subject�)Returned Mail: see transcript for detailsN)	r�generateBouncer�assertEqual�email�parser�Parser�parse�decode��self�fromAddress�to�s�emailParser�mess�r�?/usr/lib/python3/dist-packages/twisted/mail/test/test_bounce.py�test_bounceMessageUnicode��
�
z%BounceTests.test_bounceMessageUnicodecCs�t�td�dd�\}}}|�|d�|�|d�tj��}|�t|�	d���}|�|dd�|�|dd	�|�|d
d�dS)
zL
        L{twisted.mail.bounce.generateBounce} can accept L{bytes}.
        �RFrom: Moshe Zadka <moshez@example.com>
To: nonexistent@example.org
Subject: test

r
�nonexistent@example.orgr	rrrr
rrrN)
rrrrrrrrrrrrrr �test_bounceMessageBytes)r"z#BounceTests.test_bounceMessageBytescCs�t�td�ddd�\}}}|�|d�|�|d�tj��}|�t|�	d���}|�|dd�|�|d	d
�|�|dd�|�
|���|��}|�|d
��d�dS)z\
        Pass a custom transcript message to L{twisted.mail.bounce.generateBounce}.
        r#r
r$zCustom transcriptr	rrrr
rrrrzCustom transcript
N)
rrrrrrrrrr�
assertTrue�is_multipart�get_payload)rrrrrr�partsrrr �"test_bounceMessageCustomTranscriptAs$�
�

z.BounceTests.test_bounceMessageCustomTranscriptcCs�t�|||�dd�\}}}tj��}|�t|�d���}|�|dd�|�|dd�|�|dd�|�	|�
��|��}	|	d	��}
t|t
�rP|�d�}|�|
d
��d|�dS)
zU
        Pass a really big message to L{twisted.mail.bounce.generateBounce}.
        rrrrr
rrr�r�
N)rrrrrrrrrr&r'r(�
isinstance�bytes)r�header�message�ioTyperrrrrr)�innerMessagerrr �_bounceBigMessage]s
�


zBounceTests._bounceBigMessagecCs2d}|�|ddt�|�|�d�ddt�dS)zj
        L{twisted.mail.bounce.generateBounce} with big L{unicode} and
        L{bytes} messages.
        r#s
Test test
i'rz
More test
N)r3rrr)rr/rrr �test_bounceBigMessagepsz!BounceTests.test_bounceBigMessageN)	�__name__�
__module__�__qualname__�__doc__r!r%r*r3r4rrrr rsr)�
email.messager�email.parser�iorr�twisted.mailr�
twisted.trialr�TestCaserrrrr �<module>s