%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/twisted/test/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/twisted/test/__pycache__/test_sob.cpython-312.pyc

�

Ϫ�f#����ddlZddlZddlmZddlmZddlmZddlm	Z	ddl
mZGd�de	j�Z
d	d
dd	d
gd	d
igZGd�d
�ZGd�dej �Zy)�N)�dedent)�sob)�	Ephemeral)�
components)�unittestc��eZdZy)�DummyN��__name__�
__module__�__qualname__���7/usr/lib/python3/dist-packages/twisted/test/test_sob.pyr	r	���rr	��hello)rrc��eZdZy)�
FakeModuleNr
rrrrrrrrc�N�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
y)
�PersistTestsc��tD]~}tj|d�}dj�D]S}|j	|�|jd|z��tjd|z|�}|j||��U��y)N��
source picklezpersisttest.��filename)�objectsr�
Persistent�split�setStyle�save�load�assertEqual)�self�o�p�style�o1s     r�
testStyleszPersistTests.testStyles!s}���	(�A����q�"�%�A�(�.�.�0�
(���
�
�5�!������ 6��7��X�X�n�u�4�e�<��� � ��B�'�	
(�	(rc�,�t�}d|_|jtjtj
|d��dj
�D]�}tj|�j|�tj|�jd|z��tjd|z|�}|j|j|j�|jtj|�j|���y)N��lalarzlala.r)r	�foo�setComponentr�IPersistablerrr r!r"r#r')r$r%r'r(s    r�testStylesBeingSetzPersistTests.testStylesBeingSet*s����G�����	���s�'�'�����6�)B�C�$�*�*�,�	@�E����Q��(�(��/����Q��$�$�g��o�$�>����'�E�/�5�1�B����Q�U�U�B�F�F�+����S�-�-�b�1�7�7��?�	@rc�v�tjdd�}|jt|jdd��y)z?
        Calling save() with a passphrase is an error.
        N�objectzfilename.pickle�abc)�
passphrase)r�
Persistant�assertRaises�	TypeErrorr!)r$r&s  r�testPassphraseErrorz PersistTests.testPassphraseError5s0��
�N�N�4��*�����)�Q�V�V�->�5��Qrc��gd�}tj|d�}dj�D]�}|j|�|j	�tj
d|dz|�}|j
||�dj�D]G}|j	|�tj
d|zdz|dz|�}|j
||��I��y)	N�r��r2rz	object.tarz	lala lolozobject-z.ta)rrrr r!r"r#)r$r%r&r'r(�tags      r�	testNameszPersistTests.testNames<s������N�N�1�h�'��$�*�*�,�	(�E�
�J�J�u��
�F�F�H����+��a��0�%�8�B����Q��#�"�(�(�*�
(�����s���X�X�i�#�o��5��a��@�%�H��� � ��B�'�
(�	(rc��tdd�5}|jd�ddd�tjdd�}|j	|gd��y#1swY�4xYw)Nzpersisttest.python�wzfoo=[1,2,3] r-r:)�open�writer�loadValueFromFiler#)r$�fr%s   r�
testPythonzPersistTests.testPythonIsS��
�&��
,�	$��
�G�G�N�#�	$��!�!�"6��>������I�&�	$�	$�s�A�Ac�T�|jttjd�|j	dtjd��|j	dtjd��|j	dtjd��|j	dtjd��|j	dtjd��|j	d	tjd
��|j	d	tjd��y)Nz	file.blah�pythonzfile.pyzfile.tacz	file.etac�picklezfile.tapz	file.etap�sourcezfile.tasz	file.etas)r6�KeyErrorr�	guessTyper#�r$s r�testTypeGuesserzPersistTests.testTypeGuesserOs������(�C�M�M�;�?�����3�=�=��#;�<�����3�=�=��#<�=�����3�=�=��#=�>�����3�=�=��#<�=�����3�=�=��#=�>�����3�=�=��#<�=�����3�=�=��#=�>rc�T�d|j_|j�}tj|�tj
j
|d�}dat|d�5}|jtd��ddd�tj|d�}|j|t�|j|dd�|j|dd	�|jtt �|jtj"t �by#1swY��xYw)
z�
        L{_EverythingEphermal.__getattr__} will proxy the __main__ module as an
        L{Ephemeral} object, and during load will be transparent, but after
        load will return L{Ephemeral} objects from any accessed attributes.
        rzpersisttest.ee_getattrNr@a�
            app = []
            import __main__
            app.append(__main__.testMainModGetattr == 1)
            try:
                __main__.somethingElse
            except AttributeError:
                app.append(True)
            else:
                app.append(False)
            from twisted.test import test_sob
            test_sob.mainWhileLoading = __main__
            rIrzExpected attribute not set.zUnexpected attribute set.)�fakeMain�testMainModGetattr�mktemp�os�mkdir�path�join�mainWhileLoadingrArBrrr"�assertIsInstance�list�
assertTruer�
somethingElse)r$�dirnamerrD�loadeds     r�testEverythingEphemeralGetattrz+PersistTests.testEverythingEphemeralGetattrYs���,-��
�
�(��+�+�-��
������7�7�<�<��)A�B�� ��
�(�C�
 �	�A�
�G�G����
�	�&���(�H�-�����f�d�+�����q�	�#@�A�����q�	�#>�?����.�	�:����.�<�<�i�H��3	�	�s�%D�D'c���d|j_|j�}tj|�tj
j
|d�}t|d�5}|jd�|jd�|jd�ddd�tj|d�|j|jjd�y#1swY�FxYw)	zU
        Verify that _EverythingEphemeral.__setattr__ won't affect __main__.
        rzpersisttest.ee_setattrr@zimport __main__
z __main__.testMainModSetattr = 2
zapp = None
NrI)rO�testMainModSetattrrQrRrSrTrUrArBrr"r#�r$r[rrDs    r�testEverythingEphemeralSetattrz+PersistTests.testEverythingEphemeralSetattr�s���,-��
�
�(��+�+�-��
������7�7�<�<��)A�B��
�(�C�
 �	$�A�
�G�G�'�(�
�G�G�7�8�
�G�G�N�#�	$�
	����8�$�������9�9�1�=�	$�	$�s�#4C�C%c��|j�}tj|�tjj	|d�}t|d�5}|j
d�ddd�|jttj|d�|jttjd�t�y#1swY�`xYw)zW
        Test that an exception during load() won't cause _EE to mask __main__
        zpersisttest.ee_exceptionr@zraise ValueError
NrI�__main__)rQrRrSrTrUrArBr6�
ValueErrorrr"r#�type�sys�modulesrr`s    r� testEverythingEphemeralExceptionz-PersistTests.testEverythingEphemeralException�s����+�+�-��
������7�7�<�<��)C�D��
�(�C�
 �	*�A�
�G�G�(�)�	*�	
���*�c�h�h��(�C�����c�k�k�*�5�6�
�C�		*�	*�s�C�Cc�x�tjd|_t�x|_tjd<y)zi
        Replace the __main__ module with a fake one, so that it can be mutated
        in tests
        rcN)rfrg�realMainrrOrLs r�setUpzPersistTests.setUp�s+��
���J�/��
�2<�,�>��
����J�/rc�>�|jtjd<y)z8
        Restore __main__ to its original value
        rcN)rjrfrgrLs r�tearDownzPersistTests.tearDown�s��#'�-�-����J�rN)rrr
r)r0r8r>rErMr]rarhrkrmrrrrr s=��(�	@�R�(�'�?�(�T>�&D�?�0rr)rRrf�textwrapr�twisted.persistedr�twisted.persisted.stylesr�twisted.pythonr�
twisted.trialr�
Componentizedr	rr�TestCaserrrr�<module>rusl��

�
��!�.�%�"�	�J�$�$�	�
�����L���L���	�	�P0�8�$�$�P0r

Zerion Mini Shell 1.0