403Webshell
Server IP : 217.160.0.135  /  Your IP : 216.73.217.85
Web Server : Apache
System : Linux www 6.18.52-i1-ampere #1203 SMP Mon Sep 14 18:29:59 CEST 2026 aarch64
User : sws1074145052 ( 1074145052)
PHP Version : 8.3.32
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /usr/lib/python3/dist-packages/IPython/extensions/tests/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/lib/python3/dist-packages/IPython/extensions/tests/__pycache__/test_autoreload.cpython-311.pyc
�

�@�c�H��L�dZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
mZddlm
cmZddlmZddlmZddlmZmZddlmZej��dkrejd	d
���d�ZGd
�d��ZGd�de��Zd�ZGd�de��ZdS)z Tests for autoreload extension.
�N)�StringIO)�TestCase)�AutoreloadMagics)�EventManager�pre_run_cell)�skipif_not_numpy�PyPyz;Current autoreload implementation is extremely slow on PyPyT)�allow_module_levelc��dS�N�)�a�kws  �J/usr/lib/python3/dist-packages/IPython/extensions/tests/test_autoreload.py�<lambda>r,s����c�6�eZdZd�ZexZZd�Zd�Zd�Z	dd�Z
dS)�	FakeShellc���i|_|j|_i|_t|dth��|_t
|���|_|j�d|jj��dS)Nr)�shell)	�ns�user_ns�user_ns_hiddenrr�eventsr�auto_magics�register��selfs r�__init__zFakeShell.__init__0sg������w��� ���"�4�.�,�)G�H�H���+�$�7�7�7�������^�T�-=�-J�K�K�K�K�Krc��|j�d��t||j��|j���dS)Nr)r�trigger�execrr�post_execute_hook)r�codes  r�run_codezFakeShell.run_code:sE������N�+�+�+��T�4�<� � � ���*�*�,�,�,�,�,rc�:�|j�|��dSr)r�update)r�itemss  r�pushzFakeShell.push?s������u�����rc�:�|j�|��dSr)r�
autoreload)r�	parameters  r�magic_autoreloadzFakeShell.magic_autoreloadBs����#�#�I�.�.�.�.�.rNc�p�|j�||���|j���dS)N��stream)r�aimportr#)rr,r0s   r�
magic_aimportzFakeShell.magic_aimportEs9���� � ��6� �:�:�:���*�*�,�,�,�,�,rr)�__name__�
__module__�__qualname__r�noop�register_magics�set_hookr%r)r-r2r
rrrr/ss������L�L�L�"&�%�O�h�-�-�-�
���/�/�/�-�-�-�-�-�-rrc�<�eZdZdZdZdZdZd�Zd�Zd�Z	d�Z
d�ZdS)	�Fixturez&Fixture for creating test module filesN�#abcdefghijklmopqrstuvwxyz0123456789c���tj��|_ttj��|_tj�d|j��t��|_	dS)Nr)
�tempfile�mkdtemp�test_dir�list�sys�path�old_sys_path�insertrrrs r�setUpz
Fixture.setUpQsI�� �(�*�*��
� ���N�N��������4�=�)�)�)��[�[��
�
�
rc��tj|j��|jt_d|_d|_d|_dSr)�shutil�rmtreer?rCrArBrrs r�tearDownzFixture.tearDownWs8���
�d�m�$�$�$��$�����
� �����
�
�
rc���dd�tj|jd����z}|tjvr
tj|=tj�|j|dz��}||fS)N�tmpmod_��z.py)	�join�random�sample�filename_charsrA�modules�osrBr?)r�module_name�	file_names   r�
get_modulezFixture.get_module_se���"�'�'�&�-��8K�R�*P�*P�"Q�"Q�Q���#�+�%�%���K�(��G�L�L����e�0C�D�D�	��I�%�%rc���tj|��}tjd��t	|dd���5}|�|��ddd��dS#1swxYwYdS)a+
        Write a file, and force a timestamp difference of at least one second

        Notes
        -----
        Python's .pyc files record the timestamp of their compilation
        with a time resolution of one second.

        Therefore, we need to force a timestamp difference between .py
        and .pyc, without having the .py file be timestamped in the
        future, and without changing the timestamp of the .pyc file
        (because that is stored in the file).  The only reliable way
        to achieve this seems to be to sleep.
        g�������?�w�utf-8��encodingN)�textwrap�dedent�time�sleep�open�write)r�filename�content�fs    r�
write_filezFixture.write_filefs����/�'�*�*���
�4�����(�C�'�
2�
2�
2�	�a�
�G�G�G����	�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	�	s�A�A"�%A"c���tj|��}|���\}}t|dd���5}|�|��ddd��n#1swxYwY||fS)NrXrYrZ)r\r]rVr`ra)rr$�mod_name�mod_fnrds     r�
new_modulezFixture.new_module}s�����t�$�$���?�?�,�,���&�
�&�#��
0�
0�
0�	�A�
�G�G�D�M�M�M�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	����s�A � A$�'A$)r3r4r5�__doc__r?rCrQrErIrVrerir
rrr:r:Jst������0�0��H��L�:�N�!�!�!����&�&�&����. � � � � rr:c��|jj}t|dd��}tj|}|�d��D]}t||��}�|S)z;
    Original issue comes from pickle; hence the name.
    r4N�.)�	__class__r3�getattrrArR�split)�obj�namerT�obj2�subpaths     r�pickle_get_current_classrt�sZ���=�!�D��#�|�T�2�2�K��;�{�#�D��:�:�c�?�?�&�&���t�W�%�%����Krc�P�eZdZd�Zd�Zd�Zed���Zd�Zdd�Z	d�Z
d	�Zd
S)�TestAutoreloadc��|�tjd����\}}|j�d��|j�|��|�|tjd����tjd|zd���5|j�	d��ddd��dS#1swxYwYdS)Nz�
                                from enum import Enum
                                class MyEnum(Enum):
                                    A = 'A'
                                    B = 'B'
                            �2a
                                from enum import Enum
                                class MyEnum(Enum):
                                    A = 'A'
                                    B = 'B'
                                    C = 'C'
                            �[autoreload of %s failed:�stderr��channel�pass)
rir\r]rr-r2re�tt�AssertNotPrintsr%�rrgrhs   r�test_reload_enumsz TestAutoreload.test_reload_enums�s)���?�?��O� �
�
�	
�	
���&�	
�
�#�#�C�(�(�(��
� � ��*�*�*������O� �
�
�	
�	
�	
��
�
(�8�
3�h�
�
�
�	(�	(�
�J����'�'�'�	(�	(�	(�	(�	(�	(�	(�	(�	(�	(�	(�	(����	(�	(�	(�	(�	(�	(s� C�C�Cc�F�|j�d��|�d��\}}d|jjvsJ�d|jjvsJ�|j�d|z��|j�d��|�|d��|jjd}|j�d��t
|��}t||��sJ�|j�d	��|j�d
��dS)Nrxzd
            class Test():
                def meth(self):
                    return "old"
        �test�resultzfrom %s import Testz
test = Test()zd
            class Test():
                def meth(self):
                    return "new"
        r}z
import picklezp = pickle.dumps(test))rr-rirr%rert�
isinstance)rrgrh�test_object�
test_classs     r�test_reload_class_typez%TestAutoreload.test_reload_class_type�s1���
�#�#�C�(�(�(��?�?�
�
�
���&��T�Z�]�*�*�*�*��t�z�}�,�,�,�,��
���1�H�<�=�=�=��
���O�,�,�,�����
�	
�	
�	
��j�m�F�+��	
�
���F�#�#�#�-�k�:�:�
��+�z�2�2�2�2�2�	
�
���O�,�,�,��
���4�5�5�5�5�5rc�F�|j�d��|�tjd����\}}|j�d|z��|j�d��|j�d��|�t��5|j�d��ddd��n#1swxYwY|�t��5|j�d��ddd��n#1swxYwY|j�d��|�t��5|j�d	��ddd��n#1swxYwY|�|tjd
����|j�d��dD�]G}|j�|�d
���|�t��5|j�|�d���ddd��n#1swxYwY|�t��5|j�|�d���ddd��n#1swxYwY|j�|�d���|j�|�d���|�t��5|j�|�d���ddd��n#1swxYwY��IdS)Nrxa�
                                class MyClass:

                                    def __init__(self, a=10):
                                        self.a = a
                                        self.b = 22 
                                        # self.toto = 33

                                    def square(self):
                                        print('compute square')
                                        return self.a*self.a
                            �from %s import MyClasszfirst = MyClass(5)zfirst.square()zfirst.cube()zfirst.power(5)zfirst.bz
first.totoa�
                            class MyClass:

                                def __init__(self, a=10):
                                    self.a = a
                                    self.b = 11

                                def power(self, p):
                                    print('compute power '+str(p))
                                    return self.a**p
                            zsecond = MyClass(5)>�first�secondz	.power(5)z.cube()z	.square()z.bz.az.toto)	rr-rir\r]r%�assertRaises�AttributeErrorre)rrgrh�object_names    r�test_reload_class_attributesz+TestAutoreload.test_reload_class_attributes�s{���
�#�#�C�(�(�(��?�?��O� �

�

�
�
���&� 	
�
���4�x�?�@�@�@��
���0�1�1�1��
���,�-�-�-�
�
�
�~�
.�
.�	0�	0��J����/�/�/�	0�	0�	0�	0�	0�	0�	0�	0�	0�	0�	0����	0�	0�	0�	0�
�
�
�~�
.�
.�	2�	2��J��� 0�1�1�1�	2�	2�	2�	2�	2�	2�	2�	2�	2�	2�	2����	2�	2�	2�	2��
���I�&�&�&�
�
�
�~�
.�
.�	.�	.��J����-�-�-�	.�	.�	.�	.�	.�	.�	.�	.�	.�	.�	.����	.�	.�	.�	.�
	
�����O�
 �
�
�	
�	
�	
�"	
�
���1�2�2�2�.�		;�		;�K��J���;� 9� 9� 9�:�:�:��"�"�>�2�2�
=�
=��
�#�#�{�$;�$;�$;�<�<�<�
=�
=�
=�
=�
=�
=�
=�
=�
=�
=�
=����
=�
=�
=�
=��"�"�>�2�2�
?�
?��
�#�#�{�$=�$=�$=�>�>�>�
?�
?�
?�
?�
?�
?�
?�
?�
?�
?�
?����
?�
?�
?�
?��J���;� 2� 2� 2�3�3�3��J���;� 2� 2� 2�3�3�3��"�"�>�2�2�
;�
;��
�#�#�{�$9�$9�$9�:�:�:�
;�
;�
;�
;�
;�
;�
;�
;�
;�
;�
;����
;�
;�
;�
;��		;�		;sl�0C�C�C�<D#�#D'�*D'�"F	�	F
�F
�H<�<I	�I	�!J�J	�J	�*L�L	�L	c���|j�d��|�tjd����\}}|j�d|z��|j�d��|�|tjd����tjd|zd���5|j�d	��ddd��dS#1swxYwYdS)
Nrxz�
                                import numpy as np
                                class MyClass:
                                    a = (np.array((.1, .2)),
                                         np.array((.2, .3)))
                            r�zfirst = MyClass()z�
                                import numpy as np
                                class MyClass:
                                    a = (np.array((.3, .4)),
                                         np.array((.5, .6)))
                            ryrzr{r})	rr-rir\r]r%rer~rr�s   r�test_comparing_numpy_structuresz.TestAutoreload.test_comparing_numpy_structuressH���
�#�#�C�(�(�(��?�?��O� �
�
�	
�	
���&�	
�
���4�x�?�@�@�@��
���/�0�0�0�	
�����O� �
�
�
	
�
	
�
	
��
�
(�8�
3�h�
�
�
�	(�	(�
�J����'�'�'�	(�	(�	(�	(�	(�	(�	(�	(�	(�	(�	(�	(����	(�	(�	(�	(�	(�	(s�=C%�%C)�,C)c��|j�d��d}|�tj|����\}}|j�d|�d���|j�d��|�t��5|j�d��ddd��n#1swxYwY|�t��5|j�d��ddd��n#1swxYwY|�t��5|j�d��ddd��n#1swxYwYd	}|�|tj|����|j�d��|j�d
|�d���|j�d��|j�d��|j�d��d
}|�|tj|����|j�d��|j�d��|j�d��|j�d��|j�d��d}|�tj|����\}}d|�d�}|�|tj|����|j�d��|j�d��|j�d��|j�d��dS)N�3z#
        def func1(): pass
        zfrom z	 import *zfunc1()zfunc2()z
t = Test()�numberz�
        def func1(): pass
        def func2(): pass
        class Test: pass
        number = 0
        from enum import Enum
        class TestEnum(Enum):
            A = 'a'
        zimport sys; sys.modules['z
'].func2()z
TestEnum.Aa%
        def func1(): return 'changed'
        def func2(): return 'changed'
        class Test:
            def new_func(self):
                return 'changed'
        number = 1
        from enum import Enum
        class TestEnum(Enum):
            A = 'a'
            B = 'added'
        zassert func1() == 'changed'zassert func2() == 'changed'z,t = Test(); assert t.new_func() == 'changed'zassert number == 1z"assert TestEnum.B.value == 'added'z�
        from enum import Enum
        class Ext(Enum):
            A = 'ext'
        def ext_func():
            return 'ext'
        class ExtTest:
            def meth(self):
                return 'ext'
        ext_int = 2
        z
        from z import *
        zassert Ext.A.value == 'ext'zassert ext_func() == 'ext'z't = ExtTest(); assert t.meth() == 'ext'zassert ext_int == 2)	rr-rir\r]r%r��	NameErrorre)	r�mod_codergrh�new_code�new_mod_code�new_mod_name�
new_mod_fn�current_mod_codes	         r�!test_autoload_newly_added_objectsz0TestAutoreload.test_autoload_newly_added_objects8s����
�#�#�C�(�(�(��� �?�?�8�?�8�+D�+D�E�E���&��
���7�H�7�7�7�8�8�8��
���I�&�&�&�
�
�
�y�
)�
)�	+�	+��J���	�*�*�*�	+�	+�	+�	+�	+�	+�	+�	+�	+�	+�	+����	+�	+�	+�	+�
�
�
�y�
)�
)�	.�	.��J����-�-�-�	.�	.�	.�	.�	.�	.�	.�	.�	.�	.�	.����	.�	.�	.�	.�
�
�
�y�
)�
)�	*�	*��J����)�)�)�	*�	*�	*�	*�	*�	*�	*�	*�	*�	*�	*����	*�	*�	*�	*�
��	
������� 9� 9�:�:�:�	
�
���I�&�&�&��
���L��L�L�L�M�M�M��
���L�)�)�)��
���H�%�%�%��
���L�)�)�)���	
������� 9� 9�:�:�:��
���9�:�:�:��
���9�:�:�:��
���J�K�K�K��
���0�1�1�1��
���@�A�A�A�
��$(�?�?�8�?�<�3P�3P�#Q�#Q� ��j�������	
������0@� A� A�B�B�B��
���9�:�:�:��
���8�9�9�9��
���E�F�F�F��
���1�2�2�2�2�2s6�C�C�C�%D�D�D�1E�E�ETc�$	�����	���d��\}}|r։j�d���j�|��t	��}�j�d|�����d|z|�������t��5�j�d��ddd��n#1swxYwYn��j�d���j�	d	|z��t	��}�j�d|�����
d
|���v����|�jj��tj
|��j���d��������	����	�fd�}|����|d
��t%jd|zd���5�j�	d��ddd��n#1swxYwYt%jd|zd���5�j�	d��ddd��n#1swxYwY|����|d������	�fd�}�j�	d��|��t+j|���j�	d��|��|r��j�d|z��t	��}�j�d|�����
d|z|���v���j�d��n�j�d����|d���j�	d���j�	d��|��|r�j�|��n�j�d���j�	d�����jd��dS)zt
        Functional test for the automatic reloader using either
        '%autoreload 1' or '%autoreload 2'
        a�
x = 9

z = 123  # this item will be deleted

def foo(y):
    return y + 3

class Baz(object):
    def __init__(self, x):
        self.x = x
    def bar(self, y):
        return self.x + y
    @property
    def quux(self):
        return 42
    def zzz(self):
        '''This method will be deleted below'''
        return 99

class Bar:    # old-style class: weakref doesn't work for it on Python < 2.7
    def foo(self):
        return 1
�1rLr/zModules to reload:
%s�tmpmod_as318989e89dsNrxz	import %sz%Modules to reload:
all-except-skipped�	c� �����jd�����jd�����d��d������d��d����d��}����d��d����|�d��d����|jd����|���d������}������d����|���d��dS)	Nr��{r���
�*�c)	�assertEqual�x�z�foo�Baz�bar�quux�zzz�Bar�rprr�mod�old_foo�old_obj�old_obj2rs  �����r�check_module_contentsz>TestAutoreload._check_smoketest.<locals>.check_module_contents�sE������S�U�A�&�&�&����S�U�C�(�(�(����W�W�Q�Z�Z��+�+�+����S�W�W�Q�Z�Z��+�+�+��'�'�!�*�*�C����W�[�[��^�^�R�0�0�0����S�W�W�Q�Z�Z��,�,�,����S�X�r�*�*�*����S�W�W�Y�Y��+�+�+��7�7�9�9�D����X�\�\�^�^�Q�/�/�/����T�X�X�Z�Z��+�+�+�+�+rz
a syntax error
ryrzr{r}a
x = 10

def foo(y):
    return y + 4

class Baz(object):
    def __init__(self, x):
        self.x = x
    def bar(self, y):
        return self.x + y + 1
    @property
    def quux(self):
        return 43

class Bar:    # old-style class
    def foo(self):
        return 2
c������jd����t�d�������d��d������d��d����d��}����d��d����|�d��d�����jd����|jd����t�d	������t|d	��������}������d
����|���d
��dS)Nr�r�r�r�r���+r��)	r�r��assertFalse�hasattrr�r�r�r�r�r�s  �����rr�z>TestAutoreload._check_smoketest.<locals>.check_module_contents
s�������S�U�B�'�'�'����W�S�#�.�.�/�/�/����W�W�Q�Z�Z��+�+�+����S�W�W�Q�Z�Z��+�+�+��'�'�!�*�*�C����W�[�[��^�^�R�0�0�0����S�W�W�Q�Z�Z��,�,�,����W�\�2�.�.�.����S�X�r�*�*�*����W�W�e�4�4�5�5�5����W�S�%�0�0�1�1�1��7�7�9�9�D����X�\�\�^�^�Q�/�/�/����T�X�X�Z�Z��+�+�+�+�+r�-zModules to skip:
%sz-tmpmod_as318989e89ds�0z	
x = -99
i����)rirr-r2r�assertIn�getvaluer��ImportErrorr%�
assertTruerrArRr�r�r�rer~�AssertPrintsrrS�unlinkr�r�)
r�use_aimportrgrhr0r�r�r�r�r�s
`     @@@@r�_check_smoketestzTestAutoreload._check_smoketest�s�������� �?�?�
�
�
���&�<�	��J�'�'��,�,�,��J�$�$�X�.�.�.��Z�Z�F��J�$�$�R��$�7�7�7��M�M�3�h�>����AR�AR�S�S�S��"�"�;�/�/�
A�
A��
�(�(�)?�@�@�@�
A�
A�
A�
A�
A�
A�
A�
A�
A�
A�
A����
A�
A�
A�
A��
�J�'�'��,�,�,��J����h� 6�7�7�7��Z�Z�F��J�$�$�R��$�7�7�7��O�O�8�F�O�O�<M�<M�M�
�
�
�	
�
�
�h��
�
�.�.�.��k�(�#��
�'���'�'�!�*�*���7�7�9�9��	,�	,�	,�	,�	,�	,�	,�	,�	,�"	�����	
����
�	
�	
�	
��_�
(�8�
3�h�
�
�
�	(�	(�
�J����'�'�'�	(�	(�	(�	(�	(�	(�	(�	(�	(�	(�	(����	(�	(�	(�	(��
�
(�8�
3�h�
�
�
�	(�	(�
�J����'�'�'�	(�	(�	(�	(�	(�	(�	(�	(�	(�	(�	(����	(�	(�	(�	(�	�����
	
����
�	
�	
�	
�.	,�	,�	,�	,�	,�	,�	,�	,�	,�*	
�
���F�#�#�#������
	�	�&�����
���F�#�#�#������
�		-��J�$�$�S�8�^�4�4�4��Z�Z�F��J�$�$�R��$�7�7�7��O�O�3�h�>�6�?�?�CT�CT�T�U�U�U�
�J�$�$�%<�=�=�=�=��J�'�'��,�,�,�����
�	
�	
�	
�	
�
���F�#�#�#��
���F�#�#�#������
�	,��J�$�$�X�.�.�.�.��J�'�'��+�+�+��
���F�#�#�#�������$�$�$�$�$s6�C*�*C.�1C.�$I�I�I�/J�J�Jc�2�|�d���dS)NT�r��r�rs r�test_smoketest_aimportz%TestAutoreload.test_smoketest_aimportQs�����$��/�/�/�/�/rc�2�|�d���dS)NFr�r�rs r�test_smoketest_autoreloadz(TestAutoreload.test_smoketest_autoreloadTs�����%��0�0�0�0�0rN)T)r3r4r5r�r�r�rr�r�r�r�r�r
rrrvrv�s�������(�(�(�<"6�"6�"6�H;;�;;�;;�z�(�(���(�BQ3�Q3�Q3�fD%�D%�D%�D%�L0�0�0�1�1�1�1�1rrv) rjrS�platform�pytestrAr=r\rGrOr^�ior�IPython.testing.tools�testing�toolsr~�unittestr�IPython.extensions.autoreloadr�IPython.core.eventsrr�IPython.testing.decoratorsr�python_implementation�skipr6rr:rtrvr
rr�<module>r�s�����
�	�	�	�����
�
�
�
�
�
�
�
���������
�
�
�
�
�
�
�
�����������"�"�"�"�"�"�"�"�"�������:�:�:�:�:�:�:�:�:�:�:�:�:�:�7�7�7�7�7�7�!�8�!�#�#�v�-�-��F�K�E���������-�-�-�-�-�-�-�-�68 �8 �8 �8 �8 �h�8 �8 �8 �@	�	�	�1�1�1�1�1�W�1�1�1�1�1r

Youez - 2016 - github.com/yon3zu
LinuXploit