
    
8dp                         d dl Z d dlZd dlZd dlmZ d dlmZmZ d dlmZ ddl	m
Z
 ej                            e
d           G d	 d
e j                              ZdS )    N)QT6)	QtWidgetsQtGui)JupyterWidget   )
no_displayzDoesn't work without a displayreasonc                       e Zd Zed             Zed             Zd Zej        	                    e
j                            d           d          d             Zd Zd	S )
TestJupyterWidgetc                     t           j                                        | _        | j        t          j        g           | _        | j                            d           dS )z3 Create the application for the test case.
        NF)r   QApplicationinstance_appsetQuitOnLastWindowClosedclss    Clib/python3.11/site-packages/qtconsole/tests/test_jupyter_widget.py
setUpClasszTestJupyterWidget.setUpClass   sP     )22448 -b11CH**511111    c                 B    t           j                                         dS )z Exit the application.
        N)r   r   quitr   s    r   tearDownClasszTestJupyterWidget.tearDownClass   s     	##%%%%%r   c                 4   t          d          }|                     |j                            d                                          d           d|_        |                     |j                            d                                          d           dS )z$ Test changing stylesheets.
        richkind   z#000000monokaiz#ffffffN)r   assertEqual_ansi_processor	get_colornamesyntax_style)selfws     r   test_stylesheet_changedz)TestJupyterWidget.test_stylesheet_changed   s     v&&& 	*44R88==??KKK #*44R88==??KKKKKr   linuxzWorks only on Linuxr	   c                 .   t          d          }|                    d           |                    d           d|_        d|_        t          dd          }|                    |j        |d	
           |j        }|	                                }| 
                    |                                d           | 
                    |                                d           t          s,d}| 
                    |                                |           dS dS )z4 Test displaying output from other clients.
        r   r   zHeader
r   z[other] defaultza = 1 + 1
b = range(10))execution_countcodeT)before_prompt   zIHeader

[other] In [1]: a = 1 + 1
           ...: b = range(10)

In [2]: u  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
p, li { white-space: pre-wrap; }
</style></head><body style=" font-family:'Monospace'; font-size:9pt; font-weight:400; font-style:normal;">
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Header</p>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#000080;">[other] In [</span><span style=" font-weight:600; color:#000080;">1</span><span style=" color:#000080;">]:</span> a = 1 + 1</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#000080;">           ...:</span> b = range(10)</p>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#000080;">In [</span><span style=" font-weight:600; color:#000080;">2</span><span style=" color:#000080;">]:</span> </p></body></html>N)r   _append_plain_text_show_interpreter_promptother_output_prefixr$   dict_append_custom_insert_other_input_controldocumentr    
blockCounttoPlainTextr   toHtml)r%   r&   msgcontrolr6   htmls         r   test_other_outputz#TestJupyterWidget.test_other_output+   s1   
 v&&&	Z(((	""1%%% *"+
 
 
 	
.4HHH*##%%,,..222--//	 	 	  	6	d  X__..55555	6 	6r   c                    t          d          }|                    d           |j        }d}|                    |           ||                                vsJ |                                }|                                }|                    |dz
             |                    t          j
        j        t          j
        j                   |                    |           d |_        |                                 t           j                                        }|                                |k    sJ |                                 d}||                                v sJ dS )	z1Test copy/paste removes partial and full prompts.r   r   r   z    if True:
        print('a')   c                      dS )NT rA   r   r   <lambda>z:TestJupyterWidget.test_copy_paste_prompt.<locals>.<lambda>l   s    4 r   z'In [1]: if True:
   ...:     print('a')N)r   r0   r5   _set_input_bufferr8   _get_prompt_cursorpositionsetPositionmovePositionr   QTextCursorEnd
KeepAnchorsetTextCursorhasFocuscopyr   r   	clipboardtextpaste)r%   r&   r;   r,   cursorposrN   expecteds           r   test_copy_paste_promptz(TestJupyterWidget.test_copy_paste_prompt[   sS   v&&&	""1%%%*1	D!!!7..000000%%''oo37###E-1!-8	: 	: 	:f%%%'<	*4466	~~4''''				=7..00000000r   N)__name__
__module____qualname__classmethodr   r   r'   pytestmarkskipifsysplatform
startswithr=   rT   rA   r   r   r   r      s         2 2 [2 & & [&

L 
L 
L [CL33G<<<4  6 6,6 ,66 6,6\1 1 1 1 1r   r   )unittestr\   rY   qtpyr   r   r   qtconsole.jupyter_widgetr    r   rZ   r[   TestCaser   rA   r   r   <module>rd      s     



        ! ! ! ! ! ! ! ! 2 2 2 2 2 2       J'GHHd1 d1 d1 d1 d1) d1 d1 IHd1 d1 d1r   