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 :  /usr/lib/python3/dist-packages/twisted/trial/test/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


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

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

�b�D�@s�dZddlZddlZddlmZddlmZddlmZddl	m
Z
mZddlm
Z
Gdd	�d	�ZGd
d�de
�ZGdd
�d
e�ZGdd�de
�ZdS)z?
Tests for Trial's interaction with the Python warning system.
�N)�StringIO)�
TestResult)�FilePath)�_collectWarnings�_setWarningRegistryToNone)�SynchronousTestCasec@s eZdZdZGdd�de�ZdS)�MaskzQ
    Hide a test case definition from trial's automatic discovery mechanism.
    c@s(eZdZdZdZeZdd�Zdd�ZdS)zMask.MockTestsz�
        A test case which is used by L{FlushWarningsTests} to verify behavior
        which cannot be verified by code inside a single test method.
        �some warning textcCst�|j|j�dS)z@
            Generate a warning and don't flush it.
            N)�warnings�warn�message�category��self�r�A/usr/lib/python3/dist-packages/twisted/trial/test/test_warning.py�test_unflushed!szMask.MockTests.test_unflushedcCs(t�|j|j�|�t|���d�dS)z:
            Generate a warning and flush it.
            �N)r
rrr
�assertEqual�len�
flushWarningsrrrr�test_flushed'szMask.MockTests.test_flushedN)	�__name__�
__module__�__qualname__�__doc__r�UserWarningr
rrrrrr�	MockTestssrN)rrrrrrrrrrrsrc@s�eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$S)%�FlushWarningsTestsze
    Tests for C{flushWarnings}, an API for examining the warnings
    emitted so far in a test.
    cCs&|��D]\}}|�|||�qdS)z�
        Assert that all the keys present in C{subset} are also present in
        C{set} and that the corresponding values are equal.
        N)�itemsr)r�set�subset�k�vrrr�assertDictSubset5s�z#FlushWarningsTests.assertDictSubsetcCs8|�t|�t|��t||�D]
\}}|�||�qdS)z�
        For each pair of corresponding elements in C{sets} and C{subsets},
        assert that the element from C{subsets} is a subset of the element from
        C{sets}.
        N)rr�zipr$)r�sets�subsets�a�brrr�assertDictSubsets=s�z$FlushWarningsTests.assertDictSubsetscCs|�|��g�dS)zg
        If no warnings are emitted by a test, C{flushWarnings} returns an empty
        list.
        N)rrrrrr�	test_noneGszFlushWarningsTests.test_nonecCsPd}t}tj||d�d}t}tj||d�|�|��||d�||d�g�dS)z|
        If several warnings are emitted by a test, C{flushWarnings} returns a
        list containing all of them.
        zfirst warning message�rr
zsecond warning message�r
rN)rr
r�RuntimeWarningr*r)r�firstMessage�
firstCategory�
secondMessage�secondCategoryrrr�test_severalNs��zFlushWarningsTests.test_severalcCsDd}t}td�D]	}tj||d�q|�|��||d�gd�dS)z�
        The same warning triggered twice from the same place is included twice
        in the list returned by C{flushWarnings}.
        �the message�r,r-N)r.�ranger
rr*r)rrr
�irrr�
test_repeatedcs�z FlushWarningsTests.test_repeatedcCsBd}t}tj||d�|�|��||d�g�|�|��g�dS)z�
        After a particular warning event has been returned by C{flushWarnings},
        it is not returned by subsequent calls.
        r4r,r-N)r.r
rr*rr)rrr
rrr�test_clearedqs�zFlushWarningsTests.test_clearedcCs�t�}t�d�}|�|�|�tjjg�}|�|ddd�|�|ddt�t	|�jj
}|j}|jd}|�|dd|�|�|dd|�|�t
|�d	�d
S)zx
        Any warnings emitted by a test which are not flushed are emitted to the
        Python warning system.
        rrrr	r
��filename�linenorN)rrr�runrrr�assertIdenticalr�type�__code__�co_filename�co_firstlinenor)r�result�case�
warningsShown�wherer;r<rrrr~s


z!FlushWarningsTests.test_unflushedcCsJt�}t�d�}t�}|�td|�}|�|�|��|�|�	�d�dS)zx
        Any warnings emitted by a test which are flushed are not emitted to the
        Python warning system.
        r�stdout�N)
rrrr�patch�sysr=�restorer�getvalue)rrCrD�output�monkeyrrrr�s

zFlushWarningsTests.test_flushedc
Cs�Gdd�dt�}t�}t�d�}||_tjdd�}z9t�d�|�|�|�	t
|j�d�|�|jdd|�|�
|jdd��d�d	��W|tjdd�<dS|tjdd�<w)
z�
        If a warnings filter has been installed which turns warnings into
        exceptions, tests have an error added to the reporter for them for each
        unflushed warning.
        c@�eZdZdS)zIFlushWarningsTests.test_warningsConfiguredAsErrors.<locals>.CustomWarningN�rrrrrrr�
CustomWarning��rQrN�errorrr���z CustomWarning: some warning text)�Warningrrrr
r
�filters�simplefilterr=rr�errorsr>�
assertTrue�
splitlines�endswith�rrQrCrD�originalWarningsrrr�test_warningsConfiguredAsErrors�s"


��"z2FlushWarningsTests.test_warningsConfiguredAsErrorsc
Cs|Gdd�dt�}t�}t�d�}||_tjdd�}zt�d�|�|�|�	|j
g�W|tjdd�<dS|tjdd�<w)z�
        If a warnings filter has been installed which turns warnings into
        exceptions, tests which emit those warnings but flush them do not have
        an error added to the reporter.
        c@rO)zPFlushWarningsTests.test_flushedWarningsConfiguredAsErrors.<locals>.CustomWarningNrPrrrrrQ�rRrQrNrS)rUrrrr
r
rVrWr=rrXr\rrr�&test_flushedWarningsConfiguredAsErrors�s


"z9FlushWarningsTests.test_flushedWarningsConfiguredAsErrorscCs@t�d�|�t|���d�t�d�|�t|���d�dS)z�
        Any warnings emitted after a call to C{flushWarnings} can be flushed by
        another call to C{flushWarnings}.
        z
first messagerzsecond messageN)r
rrrrrrrr�test_multipleFlushes�s

z'FlushWarningsTests.test_multipleFlushescsxd�t���fdd�}d�t���fdd�}|�|�|�|j|gd���d�g�|�|j|gd���d�g�d	S)
z�
        The list returned by C{flushWarnings} includes only those
        warnings which refer to the source of the function passed as the value
        for C{offendingFunction}, if a value is passed for that parameter.
        zfirst warning textc�tj��dd�dS�Nr)�
stacklevel�r
rr)r0r/rr�one��z>FlushWarningsTests.test_filterOnOffendingFunction.<locals>.onez	some textcrarbrdr)r2r1rr�two�rfz>FlushWarningsTests.test_filterOnOffendingFunction.<locals>.two��offendingFunctionsr-N)rr.r*r)rrergr)r0r/r2r1r�test_filterOnOffendingFunction�s 
�
�z1FlushWarningsTests.test_filterOnOffendingFunctioncCs,dd�}|�|�t|j|gd��d�dS)z�
        Verify that warnings emitted at the very edges of a function are still
        determined to be emitted from that function.
        cSs"t�d�t�d�t�d�dS)Nzfirst line warningzinternal line warningzlast line warningrdrrrr�warners

z:FlushWarningsTests.test_functionBoundaries.<locals>.warnerrh�N�rrr)rrkrrr�test_functionBoundaries�sz*FlushWarningsTests.test_functionBoundariescCs4t�d�|�t|jdg�|�t|���d�dS)z�
        If an object which is neither a function nor a method is included in the
        C{offendingFunctions} list, C{flushWarnings} raises L{ValueError}.  Such
        a call flushes no warnings.
        �oh noNr)r
r�assertRaises�
ValueErrorrrrrrrr�test_invalidFilters
z%FlushWarningsTests.test_invalidFiltercCs�t|���d���d�}|��|�d��d�|�d��d�|��j�d�}t	j�
d|�|�t	jj|�ddl
m}|�t	jjd	�|�t	jj|j�|�d���|��|�t|�|jg��d
�dS)zx
        Warnings emitted by a function the source code of which is not
        available can still be flushed.
        �utf-8�twisted_private_helper�__init__.py�smissingsourcefile.py�7
import warnings
def foo():
    warnings.warn("oh no")
r)�missingsourcefile�twisted_private_helperrN)r�mktemp�encode�child�makedirs�
setContent�parent�path�decoderJ�insert�
addCleanup�removeryrx�modules�popr�foorrr)r�package�	pathEntryrxrrr�test_missingSources"�
�z%FlushWarningsTests.test_missingSourcecCst|���d���d�}|��|�d��d�|�d��d�|��j�d�}t	j�
d|�|�t	jj|�ddl
m}t	jd	=t	j|j=zdd
lm}Wn	tyWYnw|�|�|�d��ddlm}|�t	jjd�|�t	jj|j�|��|�t|�|jg��d
�dS)a

        Warnings emitted by a function defined in a file which has been renamed
        since it was initially compiled can still be flushed.

        This is testing the code which specifically supports working around the
        unfortunate behavior of CPython to write a .py source file name into
        the .pyc files it generates and then trust that it is correct in
        various places.  If source files are renamed, .pyc files may not be
        regenerated, but they will contain incorrect filenames.
        rsrtrurvs	module.pyrwr)�modulery)�invalidate_cachesstwisted_renamed_helper�twisted_renamed_helperrN)rrzr{r|r}r~rr�r�rJr�r�r�ryr�r�r�	importlibr��ImportError�moveTo�siblingr�r�r�rrr)rr�r�r�r�rrr�test_renamedSource3s4�
�
�z%FlushWarningsTests.test_renamedSourcecCs,ddd�}|�|�t|�|g��d�dS)a�
        In Python 3.6 the dis.findlinestarts documented behaviour
        was changed such that the reported lines might not be sorted ascending.
        In Python 3.10 PEP 626 introduced byte-code change such that the last
        line of a function wasn't always associated with the last byte-code.
        In the past flushWarning was not detecting that such a function was
        associated with any warnings.
        rcSs |r|rt�d�dS	dSdS)Nrord)r(r)rrrr�ys
�zCFlushWarningsTests.test_offendingFunctions_deep_branch.<locals>.fooN)rrrm)rr�rrr�#test_offendingFunctions_deep_branchos

z6FlushWarningsTests.test_offendingFunctions_deep_branchN)rrrrr$r*r+r3r8r9rrr^r_r`rjrnrrr�r�r�rrrrr/s&




<rc@rO)�FakeWarningNrPrrrrr��rRr�c@s@eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dS)�CollectWarningsTestsz(
    Tests for L{_collectWarnings}.
    cs�d��ddd��tddd��g�����fdd�}t�j|�|��d	d
�|��dj��|��dj��|��djt���|��dd�|�t��d
�dS)zS
        L{_collectWarnings} calls the observer with each emitted warning.
        zdummy calls observer warningNrTrr5rlcs6��d�t���t���t�����d�dS)N�call�	returning)�appendr
rr��eventsr/r1�thirdMessagerr�f�s




z2CollectWarningsTests.test_callsObserver.<locals>.frr�r:r��)rUrr�rr�strr)rr�rr�r�test_callsObserver�sz'CollectWarningsTests.test_callsObservercCs:t�}|�td|�tdd�tjd�|�|��d�dS)z�
        Any warnings emitted by a call to a function passed to
        L{_collectWarnings} are not actually emitted to the warning system.
        rGcS�dS�Nr��xrrr�<lambda>��z6CollectWarningsTests.test_suppresses.<locals>.<lambda>�textrHN)rrIrJrr
rrrL)rrMrrr�test_suppresses�sz$CollectWarningsTests.test_suppressescsXg�t����fdd�}tdd�|ddddd	�}|��d
ddd	�fg�|�|��dS)z�
        L{_collectWarnings} returns the result of calling the callable passed to
        it with the parameters given.
        cs��||f��Sr�)r�)�args�kwargs��	arguments�valuerrr��sz2CollectWarningsTests.test_callsFunction.<locals>.fcSr�r�rr�rrrr��r�z9CollectWarningsTests.test_callsFunction.<locals>.<lambda>rr(r5�d)r)�c)rr(N)�objectrrr>)rr�rCrr�r�test_callsFunction�sz'CollectWarningsTests.test_callsFunctioncCsdbdd�}t�d�|�g}t|j|�|�t|�d�|�|djd�|�t|���d�dS)z�
        Subsequent emissions of a warning from a particular source site can be
        collected by L{_collectWarnings}.  In particular, the per-module
        emitted-warning cache should be bypassed (I{__warningregistry__}).
        cSst�d�dS)Nr�rdrrrrr���z>CollectWarningsTests.test_duplicateWarningCollected.<locals>.f�defaultrrr�N)	�__warningregistry__r
rWrr�rrrr)rr�r�rrr�test_duplicateWarningCollected�s
z3CollectWarningsTests.test_duplicateWarningCollectedcCs,t�}|tj|<|�tjj|�|��dS)z�
        L{_collectWarnings}'s behavior is not altered by the presence of an
        object which cannot have attributes set on it as a value in
        C{sys.modules}.
        N)r�rJr�r�r�r��r�keyrrr�test_immutableObject�s
z)CollectWarningsTests.test_immutableObjectcsni�G�fdd�d�}t�}t�}||��|<t�}t�}||��|<t��|�||||ht�����dS)a�
        If the dictionary passed to L{_setWarningRegistryToNone} changes size
        partway through the process, C{_setWarningRegistryToNone} continues to
        set C{__warningregistry__} to L{None} on the rest of the values anyway.


        This might be caused by C{sys.modules} containing something that's not
        really a module and imports things on setattr.  py.test does this, as
        does L{twisted.python.deprecate.deprecatedModuleAttribute}.
        cs eZdZdd�Z�fdd�ZdS)zKCollectWarningsTests.test_setWarningRegistryChangeWhileIterating.<locals>.AcSs||jd<dS)N�_key)�__dict__r�rrr�__init__�r�zTCollectWarningsTests.test_setWarningRegistryChangeWhileIterating.<locals>.A.__init__csd�|j<dSr�)r�)rr��item�r�rr�__setattr__�r�zWCollectWarningsTests.test_setWarningRegistryChangeWhileIterating.<locals>.A.__setattr__N)rrrr�r�rr�rr�A�sr�N)r�rrr �keys)rr��key1�key2�key3�key4rr�r�+test_setWarningRegistryChangeWhileIterating�s z@CollectWarningsTests.test_setWarningRegistryChangeWhileIteratingN)
rrrrr�r�r�r�r�r�rrrrr��s
r�)rrJr
�ior�unittestr�twisted.python.filepathr�twisted.trial._synctestrr�twisted.trial.unittestrrrrUr�r�rrrr�<module>sZ

Anon7 - 2022
AnonSec Team