Your IP : 216.73.216.196


Current Path : /opt/alt/python310/lib64/python3.10/test/__pycache__/
Upload File :
Current File : //opt/alt/python310/lib64/python3.10/test/__pycache__/test_webbrowser.cpython-310.pyc

o

0�ib*�@s\ddlZddlZddlZddlZddlZddlmZddlmZddlm	Z	ddlm
Z
dZdZGdd	�d	ej
�ZGd
d�d�ZGdd
�d
eej�ZGdd�deej�ZGdd�deej�ZGdd�deej�ZGdd�deej�ZGdd�deej�ZGdd�deej�ZGdd�deej�ZGdd�dej�ZGdd�dej�Zed kr�e��dSdS)!�N)�mock)�support)�
import_helper)�	os_helperzhttp://www.example.com�testc@seZdZdd�Zddd�ZdS)�	PopenMockcC�dS�Nr���selfr
r
�;/opt/alt/python310/lib64/python3.10/test/test_webbrowser.py�poll�zPopenMock.pollNcCrr	r
)rZsecondsr
r
r
�waitrzPopenMock.wait�N)�__name__�
__module__�__qualname__rrr
r
r
r
rsrc@seZdZegid�dd�ZdS)�CommandTestMixin)�args�kwc
Cs�t�}t�|td|�|jtd�}t||�|i|��tjjdd}|�	|dt�|�
d�|D]}	|�|	|�|�
|�|	��q2|�	||�dS)ajGiven a web browser instance method name along with arguments and
        keywords for same (which defaults to the single argument URL), creates
        a browser instance from the class pointed to by self.browser, calls the
        indicated instance method with the indicated arguments, and compares
        the resulting options and arguments passed to Popen by the browser
        instance against the 'options' and 'args' lists.  Options are compared
        in a position independent fashion, and the arguments are compared in
        sequence order to whatever is left over after removing the options.

        �Popen)�namerN)
rrZpatch�
subprocess�
browser_class�CMD_NAME�getattrrZ	call_args�assertEqual�pop�assertIn�index)
rZmethrr�options�	arguments�popen�browserZ
popen_argsZoptionr
r
r
�_tests
zCommandTestMixin._testN)rrr�URLr&r
r
r
r
rsrc@�eZdZejZdd�ZdS)�GenericBrowserCommandTestcC�|jdgtgd�dS�N�open�r"r#�r&r'rr
r
r
�	test_open7�
�z#GenericBrowserCommandTest.test_openN)rrr�
webbrowser�GenericBrowserrr/r
r
r
r
r)3�r)c@r()�BackgroundBrowserCommandTestcCr*r+r.rr
r
r
r/Ar0z&BackgroundBrowserCommandTest.test_openN)rrrr1ZBackgroundBrowserrr/r
r
r
r
r4=r3r4c@�2eZdZejZdd�Zdd�Zdd�Zdd�Z	d	S)
�ChromeCommandTestcCr*r+r.rr
r
r
r/Kr0zChromeCommandTest.test_opencC�|jdtdd�gtgd�dS�Nr,F�Z	autoraise�rr"r#�r&�dictr'rr
r
r
�test_open_with_autoraise_falseP�
�z0ChromeCommandTest.test_open_with_autoraise_falsecC�|jddgtgd�dS�N�open_newz--new-windowr-r.rr
r
r
�
test_open_newU�
�zChromeCommandTest.test_open_newcCr*�N�open_new_tabr-r.rr
r
r
�test_open_new_tabZr0z#ChromeCommandTest.test_open_new_tabN)
rrrr1ZChromerr/r=rBrFr
r
r
r
r6G�r6c@r5)
�MozillaCommandTestcCr*r+r.rr
r
r
r/dr0zMozillaCommandTest.test_opencCr7r8r;rr
r
r
r=ir>z1MozillaCommandTest.test_open_with_autoraise_falsecC�|jdgdtgd�dS)NrAz-new-windowr-r.rr
r
r
rBn�
�z MozillaCommandTest.test_open_newcCrI)NrEz-new-tabr-r.rr
r
r
rFsrJz$MozillaCommandTest.test_open_new_tabN)
rrrr1ZMozillarr/r=rBrFr
r
r
r
rH`rGrHc@r5)
�NetscapeCommandTestcC� |jdddgd�t�gd�dS)Nr,�-raise�-remote�openURL({})r-�r&�formatr'rr
r
r
r/}�

�zNetscapeCommandTest.test_opencCs(|jdtdd�ddgd�t�gd�dS)Nr,Fr9�-noraiserNrOr:)r&r<rQr'rr
r
r
r=�s

�z2NetscapeCommandTest.test_open_with_autoraise_falsecCrL)NrArMrN�openURL({},new-window)r-rPrr
r
r
rB�rRz!NetscapeCommandTest.test_open_newcCrL)NrErMrN�openURL({},new-tab)r-rPrr
r
r
rF�rRz%NetscapeCommandTest.test_open_new_tabN)
rrrr1ZNetscaperr/r=rBrFr
r
r
r
rKyrGrKc@r5)
�GaleonCommandTestcCr?)Nr,�-nr-r.rr
r
r
r/�rCzGaleonCommandTest.test_opencCs"|jdtdd�ddgtgd�dS)Nr,Fr9rSrWr:r;rr
r
r
r=�s
�z0GaleonCommandTest.test_open_with_autoraise_falsecCr?)NrA�-wr-r.rr
r
r
rB�rCzGaleonCommandTest.test_open_newcCr?)NrErXr-r.rr
r
r
rF�rCz#GaleonCommandTest.test_open_new_tabN)
rrrr1ZGaleonrr/r=rBrFr
r
r
r
rV�rGrVc@r5)
�OperaCommandTestcCr*r+r.rr
r
r
r/�r0zOperaCommandTest.test_opencCr7r8r;rr
r
r
r=�r>z/OperaCommandTest.test_open_with_autoraise_falsecCr?r@r.rr
r
r
rB�rCzOperaCommandTest.test_open_newcCr*rDr.rr
r
r
rF�r0z"OperaCommandTest.test_open_new_tabN)
rrrr1ZOperarr/r=rBrFr
r
r
r
rY�rGrYc@r5)
�ELinksCommandTestcC�|jddgd�t�gd�dS�Nr,rNrOr-rPrr
r
r
r/�s


�zELinksCommandTest.test_opencCr[r\rPrr
r
r
r=��

�z0ELinksCommandTest.test_open_with_autoraise_falsecCr[)NrArNrTr-rPrr
r
r
rB�r]zELinksCommandTest.test_open_newcCr[)NrErNrUr-rPrr
r
r
rF�r]z#ELinksCommandTest.test_open_new_tabN)
rrrr1ZElinksrr/r=rBrFr
r
r
r
rZ�srZc@s<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)�BrowserRegistrationTestcCs tj|_gt_tj|_it_dSr)r1�	_tryorder�_saved_tryorder�	_browsers�_saved_browsersrr
r
r
�setUp�s
zBrowserRegistrationTest.setUpcCs|jt_|jt_dSr)r`r1r_rbrarr
r
r
�tearDown�sz BrowserRegistrationTest.tearDowncCs�Gdd�d�}g}i}|�tj|�|�tj|�t�d|�dg}|dg|d<|�tj|�|�tj|�|�}|durGtjd|||d�nt�d||�|rUddg}nddg}||g|d<|�tj|�|�tj|�dS)Nc@�eZdZdS)zCBrowserRegistrationTest._check_registration.<locals>.ExampleBrowserN�rrrr
r
r
r
�ExampleBrowser��rg�Example1�example1Zexample2��	preferred)rr1r_ra�register)rrlrgZexpected_tryorderZexpected_browsers�instancer
r
r
�_check_registration�s,
�
z+BrowserRegistrationTest._check_registrationcC�|jdd�dS)NFrk�rorr
r
r
�
test_register�z%BrowserRegistrationTest.test_registercCs|jdd�dS)Nrkrqrr
r
r
�test_register_default
rsz-BrowserRegistrationTest.test_register_defaultcCrp)NTrkrqrr
r
r
�test_register_preferred
rsz/BrowserRegistrationTest.test_register_preferredN)	rrrrcrdrorrrtrur
r
r
r
r^�sr^c@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�
ImportTestcCs�t�d�}|�|j�|�|j�Gdd�d�}|�d|�|�|j�|�|jdd�|�|j�|�	d|j�|�|jd|dg�dS)Nr1c@re)z0ImportTest.test_register.<locals>.ExampleBrowserNrfr
r
r
r
rgrhrgri���rj)
r�import_fresh_module�assertIsNoner_�assertFalserarmZ
assertTruerr )rr1rgr
r
r
rrs
zImportTest.test_registercCsht�d�}|�|j�|�|j�|�|j��
|�d�Wd�n1s'wY|�	|j�dS)Nr1Zfakebrowser)
rrxryr_rzraZassertRaises�Error�getZassertIsNotNone)rr1r
r
r
�test_get s
�zImportTest.test_getcCs@t�d�}tj�tj���}|�|d|�	|��|�
tj�dS)Nr1)rrx�os�path�basename�sys�
executable�lowerrmr2r|)rr1rr
r
r
�test_synthesize)s
zImportTest.test_synthesizec
Cs�t�d�}z|��j}Wn|jtfy(}z
|�t|��WYd}~nd}~wwt�	��}||d<t�d�}|��Wd�dS1sFwYdS)Nr1�BROWSER)
rrxr|rr{�AttributeError�skipTest�strr�EnvironmentVarGuard)rr1r%�err�envr
r
r
�test_environment/s
��


"�zImportTest.test_environmentc
Cst�d�}z|��|�|jd�j}Wn|jttfy1}z
|�t	|��WYd}~nd}~wwt
���}||d<t�d�}|�|��j|�Wd�n1sSwYt
���}t
j|d<t�d�}|�|��jt
j�Wd�dS1s|wYdS)Nr1rwr�)rrxr|r_rr{r��
IndexErrorr�r�rr�rr�r�)rr1Zleast_preferred_browserr�r�r
r
r
�test_environment_preferred:s$
��

�


"�z%ImportTest.test_environment_preferredN)rrrrrr}r�r�r�r
r
r
r
rvs	rv�__main__)r1Zunittestr~r�rrrrZtest.supportrrr'rZ	MagicMockrrZTestCaser)r4r6rHrKrVrYrZr^rvr�mainr
r
r
r
�<module>s4	

5<�