HEX
Server: Apache
System: Linux scp1.abinfocom.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: confeduphaar (1010)
PHP: 8.1.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //usr/lib/python3/dist-packages/twisted/test/__pycache__/test_nooldstyle.cpython-38.pyc
U


W[C�@s�dZddlmZmZddlZddlZddlmZmZddl	m
Z
ddlmZm
Z
ddlmZddlmZdZervd	Zn
e
�s�d
Zddd
ddddddddgZGdd�d�ZGdd�de�ZGdd�dej�ZGdd�de�Zdd�Zee��dS) z2
Tests for L{twisted.python._oldstyle._oldStyle}.
�)�absolute_import�divisionN)�namedAny�fullyQualifiedName)�	getModule)�_PY3�_shouldEnableNewStyle)�unittest)�	_oldstylezNot relevant on Python 3.z#Not running with TWISTED_NEWSTYLE=1ztwisted._threadsztwisted.applicationztwisted.internetztwisted.loggerztwisted.pluginsztwisted.positioningztwisted.protocols.haproxyztwisted.pythonztwisted.scriptztwisted.tapz
twisted.trialc@seZdZdZdZdd�ZdS)�SomeOldStyleClassz
    I am a docstring!
    �bazcCsdS)zX
        A function on an old style class.

        @return: "hi", for testing.
        �hi�)�selfrr�>/usr/lib/python3/dist-packages/twisted/test/test_nooldstyle.py�func1szSomeOldStyleClass.funcN)�__name__�
__module__�__qualname__�__doc__�barrrrrrr+src@seZdZdZdS)�SomeNewStyleClassz
    Some new style class!
    N)rrrrrrrrr;src@sReZdZdZdd�Zdd�Zdd�Zdd	�Zer6d
e_	e
rHe
e_	e
e_	nde_	dS)
�OldStyleDecoratorTestsz+
    Tests for L{_oldstyle._oldStyle}.
    cCstGdd�dt�}|�t|�tj�t�|�}|�t|�t�|�|jttf�|�|��	�d�|�|�j
d�dS)z�
        L{_oldstyle._oldStyle} wraps an old-style class and returns a new-style
        class that has the same functions, attributes, etc.
        c@seZdZdS)zLOldStyleDecoratorTests.test_makesNewStyle.<locals>.SomeClassThatUsesOldStyleN)rrrrrrr�SomeClassThatUsesOldStyleLsrr
rN)r�assertEqual�type�types�	ClassTyper
�	_oldStyle�	__bases__�objectrr)rr�updatedClassrrr�test_makesNewStyleGs
z)OldStyleDecoratorTests.test_makesNewStylecCs>t�t�}|�|jtj�|�|jtj�|�|jtj�dS)z�
        The class returned by L{_oldstyle._oldStyle} has the same C{__name__},
        C{__module__}, and docstring (C{__doc__}) attributes as the original.
        N)r
rrrrrr�rr!rrr�test_carriesAttributesWs
z-OldStyleDecoratorTests.test_carriesAttributesc	Cs8|�t��}t�t�W5QRX|�|jjdd�dS)zp
        Using L{_oldstyle._oldStyle} on a new-style class on Python 2 will
        raise an exception.
        rz�twisted.python._oldstyle._oldStyle is being used to decorate a new-style class (twisted.test.test_nooldstyle.SomeNewStyleClass). This should only be used to decorate old-style classes.N)ZassertRaises�
ValueErrorr
rrrZ	exception�args)r�errr�test_onlyOldStyleMayBeDecoratedcs
�z6OldStyleDecoratorTests.test_onlyOldStyleMayBeDecoratedcCs.t�t�}|�t|�tt��|�|t�dS)zw
        On Python 3 or on Py2 when C{TWISTED_NEWSTYLE} is not set,
        L{_oldStyle._oldStyle} is a no-op.
        N)r
rrrrZassertIsr#rrr�test_noOpByDefaultrs
z)OldStyleDecoratorTests.test_noOpByDefaultzOnly relevant on Py2.z7Only relevant when not running under TWISTED_NEWSTYLE=1N)rrrrr"r$r(r)r�skip�_skiprrrrrBs	rc@seZdZdZeZdd�ZdS)�NewStyleOnlyz�
    A base testclass that takes a module and tests if the classes defined
    in it are old-style.

    CAVEATS: This is maybe slightly dumb. It doesn't look inside functions, for
    classes defined there, or nested classes.
    c
Cs�zt|j�}Wn2tk
r@}zt�d�|���W5d}~XYnXg}t�|�D]8\}}t|d�rP|j	|jkrPt
|tj�rP|�
t|��qP|r�d|_tD]}|j�|�r�t|d�q�t�dj|jd�|�d���dS)	zJ
        Test that C{self.module} has no old-style classes in it.
        zNot importable: {}Nrz2Not all classes are made new-style yet. See #8243.�todoz$Old-style classes in {module}: {val}z, )�module�val)rr.�ImportErrorr	ZSkipTest�format�inspectZ
getmembers�hasattrr�
isinstancerr�appendrr-�forbiddenModules�
startswith�delattrZFailTest�join)rr.r'ZoldStyleClasses�namer/�xrrr�test_newStyleClassesOnly�s,"

���z%NewStyleOnly.test_newStyleClassesOnlyN)rrrrr+r*r<rrrrr,�sr,cs�td���D]t�dddg}�fdd�|D�}d|kr6qG�fdd	�d	ttj�}�j�d
d�}||_t|d�rr||_	|�
||i�qd
S)z�
    Build the test classes that use L{NewStyleOnly}, one class per module.

    @param _locals: The global C{locals()} dict.
    Ztwistedztwisted.test.reflect_helperztwisted.internet.test.process_ztwisted.test.process_csg|]}�j�|��qSr)r:r7)�.0Zignored�r;rr�
<listcomp>�sz%_buildTestClasses.<locals>.<listcomp>TcseZdZdZ�jZdS)z_buildTestClasses.<locals>.Testz/
            @see: L{NewStyleOnly}
            N)rrrrr:r.rr>rr�Test�sr@�.�_rN)rZwalkModulesr,r	�TestCaser:�replacerr3r�update)Z_localsZignoredModulesZ	isIgnoredr@ZacceptableNamerr>r�_buildTestClasses�s�
rF)rZ
__future__rrrr2Ztwisted.python.reflectrrZtwisted.python.modulesrZtwisted.python.compatrrZ
twisted.trialr	Ztwisted.pythonr
r+r6rr rrCrr,rF�localsrrrr�<module>s>�E*"