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: //lib/python3/dist-packages/twisted/words/test/__pycache__/test_basesupport.cpython-310.pyc
o

�b��@s^ddlmZmZddlmZddlmZGdd�dej�ZGdd�d�Z	Gdd	�d	ej
�Zd
S)�)�defer�error)�unittest)�basesupportc@s0eZdZdZdZdZdd�Zdd�Zdd�Zd	S)
�DummyAccountzO
    An account object that will do nothing when asked to start to log on.
    FcGst��|_|jS)z�
        Set self.loginDeferred to the same as the deferred returned, allowing a
        testcase to .callback or .errback.

        @return: A deferred.
        )r�Deferred�
loginDeferred)�self�args�r�E/usr/lib/python3/dist-packages/twisted/words/test/test_basesupport.py�_startLogOns
zDummyAccount._startLogOncC�d|_tj�||�S�NT)�loginHasFailedr�AbstractAccount�_loginFailed�r	�resultrrrr�zDummyAccount._loginFailedcCrr)�loginCallbackCalledrr�	_cb_logOnrrrrrrzDummyAccount._cb_logOnN)	�__name__�
__module__�__qualname__�__doc__rrr
rrrrrrr	s
rc@seZdZdZdZdd�ZdS)�DummyUIzT
    Provide just the interface required to be passed to AbstractAccount.logOn.
    FcCs
d|_dSr)�clientRegisteredrrrr�registerAccountClient+s
zDummyUI.registerAccountClientN)rrrrrrrrrrr$src@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�ClientMsgTestscCst�S)N)r�r	rrr�makeUI0szClientMsgTests.makeUIcCstdddddd�S)N�laF�	localhosti)rr rrr�makeAccount3szClientMsgTests.makeAccountcsB�������}��|�}�j�d���fdd�}|�|�|S)�z
        Test that account.logOn works, and it calls the right callback when a
        connection is established.
        Ncs ���jd����jd�dS)NzLogin shouldn't have failedzWe should be logged in)�assertFalser�
assertTruer)r��accountr	rr�check@sz*ClientMsgTests.test_connect.<locals>.check)r$r!�logOnr�callback�addCallback)r	�ui�dr*rr(r�test_connect6s

zClientMsgTests.test_connectcsT������������}�j�t�����fdd�}�fdd�}|�||�|S)r%cs0���jd����jd����jd�dS)NzLogin should have failedzWe shouldn't be logged inz(Client shouldn't be registered in the UI)r'rr&rr)�reason�r)r	r.rr�errQs
�z.ClientMsgTests.test_failedConnect.<locals>.errcs��dd�S)NFzShouldn't get called back)r')�rr rr�<lambda>Xsz3ClientMsgTests.test_failedConnect.<locals>.<lambda>)r$r!r+r�errback�	Exception�addCallbacks)r	r/r3�cbrr2r�test_failedConnectGs
z!ClientMsgTests.test_failedConnectcCs0|��}|��}|�|�|�tj|j|�dS)ze
        Test that it can fail sensibly when someone tried to connect before
        we did.
        N)r$r!r+�assertRaisesr�ConnectError)r	r)r.rrr�test_alreadyConnecting\s
z%ClientMsgTests.test_alreadyConnectingN)rrrr!r$r0r:r=rrrrr/srN)�twisted.internetrr�
twisted.trialr�twisted.words.imrrrr�TestCaserrrrr�<module>s