HEX
Server: Apache
System: Linux zacp120.webway.host 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
User: govancoz (1003)
PHP: 8.3.26
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: //usr/local/lib/python3.7/test/__pycache__/test_atexit.cpython-37.opt-1.pyc
B

��g?�@s�ddlZddlZddlZddlZddlZddlmZddlmZdd�Z	dd�Z
dd	�Zd
d�Zdd
�Z
dd�Zdd�ZGdd�dej�ZejGdd�dej��Zedkr�e��dS)�N)�support)�
script_helpercCstd�dS)N�h1)�print�rr�,/usr/local/lib/python3.7/test/test_atexit.pyr
srcCstd�dS)N�h2)rrrrrr
srcCstd�dS)N�h3)rrrrrr	sr	cOstd||�dS)N�h4)r)�args�kwargsrrrr
sr
cCst�dS)N)�	TypeErrorrrrr�raise1srcCst�dS)N)�SystemErrorrrrr�raise2srcCst�dS)N)�
SystemExitrrrr�exitsrc@s|eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�ZdS)�GeneralTestcCs4tj|_tj|_t��|_|jt_t_t�	�dS)N)
�sys�stdout�save_stdout�stderr�save_stderr�io�StringIO�stream�atexit�_clear)�selfrrr�setUp"s

zGeneralTest.setUpcCs|jt_|jt_t��dS)N)rrrrrrr)rrrr�tearDown)szGeneralTest.tearDowncCsBt�t�t�t�tjtddd�t��|�|j��d�dS)N��abc)�kwz"h4 (4,) {'kw': 'abc'}
h4 () {}
h1
)r�registerrr
�_run_exitfuncs�assertEqualr�getvalue)rrrr�	test_args.s

zGeneralTest.test_argscCs4t�dd�dddd�dD�dd�|�ttj�dS)NcSsdS)N�rrrrr�<lambda>9�z*GeneralTest.test_badargs.<locals>.<lambda>rcss|]
}|VqdS)Nr)�.0�xrrr�	<genexpr>9sz+GeneralTest.test_badargs.<locals>.<genexpr>)r)�)rr$�assertRaisesr
r%)rrrr�test_badargs8s"zGeneralTest.test_badargscCs<t�t�t�t�t�t�t��|�|j��d�dS)Nz	h3
h2
h1
)	rr$rrr	r%r&rr')rrrr�
test_order<s



zGeneralTest.test_ordercCs&t�t�t�t�|�ttj�dS)N)rr$rrr0r
r%)rrrr�
test_raiseEs

zGeneralTest.test_raisecCs2t�dd��|�ttj�|�d|j���dS)NcSsddS)Nr)rrrrrrr*Or+z5GeneralTest.test_raise_unnormalized.<locals>.<lambda>�ZeroDivisionError)rr$r0r4r%�assertInrr')rrrr�test_raise_unnormalizedLsz#GeneralTest.test_raise_unnormalizedcCs.t�t�|�ttj�|�|j��d�dS)N�)	rr$rr0rr%r&rr')rrrr�	test_exitTs
zGeneralTest.test_exitcCs�dd�}dd�}dd�}t�|�t�|�t�|�|�ttj�|j��}|�|�d�d�|�	d	|�|�	d
|�|�	d|�dS)NcSsdddS)Nr)rrrrrr�f]sz,GeneralTest.test_print_tracebacks.<locals>.fcSsdddS)Nr)rrrrrr�g_sz,GeneralTest.test_print_tracebacks.<locals>.gcSsdddS)Nr)rrrrrr�hasz,GeneralTest.test_print_tracebacks.<locals>.hr4�z# onez# twoz# three)
rr$r0r4r%rr'r&�countr5)rr9r:r;rrrr�test_print_tracebacks[s



z!GeneralTest.test_print_tracebackscsJdg��fdd�}xtd�D]}t�|�qWt��|��dd�dS)Nrcs�dd7<dS)Nrr)rr)�arr�incpsz$GeneralTest.test_stress.<locals>.inc�)�rangerr$r%r&)rr@�ir)r?r�test_stressnszGeneralTest.test_stresscs@dg��fdd�}t�|�t��t��|��dd�dS)Nrcs�dd7<dS)Nrr)rr)r?rrr@{sz#GeneralTest.test_clear.<locals>.inc)rr$rr%r&)rr@r)r?r�
test_clearys
zGeneralTest.test_clearcsjdg��fdd�}�fdd�}xtd�D]}t�|�q(Wt�|�t�|�t��|��dd�dS)Nrcs�dd7<dS)Nrr)rr)r?rrr@�sz(GeneralTest.test_unregister.<locals>.inccs�dd8<dS)Nrr)rr)r?rr�dec�sz(GeneralTest.test_unregister.<locals>.decr!���)rBrr$�
unregisterr%r&)rr@rFrCr)r?r�test_unregister�s

zGeneralTest.test_unregistercCsNg}t�|jd�t��|�|dg�t�|j�t��|�|dg�dS)N�)rr$�appendr%r&rH)r�lrrr�test_bound_methods�szGeneralTest.test_bound_methodscCs:d}t�d|�}|�|j����ddg�|�|j�dS)Nz�if 1:
            import atexit

            def f(msg):
                print(msg)

            atexit.register(f, "one")
            atexit.register(f, "two")
            z-cZtwoZone)rZassert_python_okr&�out�decode�
splitlinesZassertFalse�err)r�codeZresrrr�
test_shutdown�s
zGeneralTest.test_shutdownN)�__name__�
__module__�__qualname__rr r(r1r2r3r6r8r>rDrErIrMrSrrrrr s
	
rc@s$eZdZdd�Zdd�Zdd�ZdS)�SubinterpreterTestcCs6t��}d}t�|�}|�|d�|�t��|�dS)Nz�if 1:
            import atexit
            def f():
                pass
            atexit.register(f)
            del atexit
            r)r�_ncallbacksr�run_in_subinterpr&)r�nrR�retrrr�test_callbacks_leak�s

z&SubinterpreterTest.test_callbacks_leakcCs6t��}d}t�|�}|�|d�|�t��|�dS)Nz�if 1:
            import atexit
            def f():
                pass
            atexit.register(f)
            atexit.__atexit = atexit
            r)rrXrrYr&)rrZrRr[rrr�test_callbacks_leak_refcycle�s

z/SubinterpreterTest.test_callbacks_leak_refcyclecCsTd}t��\}}d�|�}t�|�}t�|�|�t�|t|��|�t�|�dS)NsThe test has passed!z�if 1:
            import os
            import atexit
            def callback():
                os.write({:d}, b"The test has passed!")
            atexit.register(callback)
        )	�os�pipe�formatrrY�closer&�read�len)rZexpected�r�wrRr[rrr�(test_callback_on_subinterpreter_teardown�s


z;SubinterpreterTest.test_callback_on_subinterpreter_teardownN)rTrUrVr\r]rfrrrrrW�srW�__main__)rZunittestrrr^ZtestrZtest.supportrrrr	r
rrrZTestCaserZcpython_onlyrWrT�mainrrrr�<module>s&
4