Your IP : 216.73.216.85


Current Path : /opt/alt/python39/lib64/python3.9/test/__pycache__/
Upload File :
Current File : //opt/alt/python39/lib64/python3.9/test/__pycache__/test_webbrowser.cpython-39.pyc

a

XC?h�)�@sBddlZddlZddlZddlZddlZddlmZddlmZdZdZ	Gdd�dej
�ZGdd	�d	�ZGd
d�deej
�ZGdd
�d
eej
�ZGdd�deej
�ZGdd�deej
�ZGdd�deej
�ZGdd�deej
�ZGdd�deej
�ZGdd�deej
�ZGdd�dej
�ZGdd�dej
�Zedk�r>e��dS)�N)�mock)�supportzhttp://www.example.com�testc@seZdZdd�Zddd�ZdS)�	PopenMockcCsdS�Nr���selfrr�9/opt/alt/python39/lib64/python3.9/test/test_webbrowser.py�pollszPopenMock.pollNcCsdSrr)r	Zsecondsrrr
�waitszPopenMock.wait)N)�__name__�
__module__�__qualname__rrrrrr
rsrc@seZdZegid�dd�ZdS)�CommandTestMixin)�args�kwc
Cs�t�}t�|td|�|jtd�}t||�|i|��tjjdd}|�	|dt�|�
d�|D] }	|�|	|�|�
|�|	��qd|�	||�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_argsZoptionrrr
�_tests
zCommandTestMixin._testN)r
rr�URLr!rrrr
rsrc@seZdZejZdd�ZdS)�GenericBrowserCommandTestcCs|jdgtgd�dS�N�open�rr�r!r"rrrr
�	test_open5s�z#GenericBrowserCommandTest.test_openN)r
rr�
webbrowser�GenericBrowserrr(rrrr
r#1sr#c@seZdZejZdd�ZdS)�BackgroundBrowserCommandTestcCs|jdgtgd�dSr$r'rrrr
r(?s�z&BackgroundBrowserCommandTest.test_openN)r
rrr)ZBackgroundBrowserrr(rrrr
r+;sr+c@s2eZdZejZdd�Zdd�Zdd�Zdd�Z	d	S)
�ChromeCommandTestcCs|jdgtgd�dSr$r'rrrr
r(Is�zChromeCommandTest.test_opencCs|jdtdd�gtgd�dS�Nr%F�Z	autoraise�rrr�r!�dictr"rrrr
�test_open_with_autoraise_falseNs�z0ChromeCommandTest.test_open_with_autoraise_falsecCs|jddgtgd�dS�N�open_newz--new-windowr&r'rrrr
�
test_open_newSs�zChromeCommandTest.test_open_newcCs|jdgtgd�dS�N�open_new_tabr&r'rrrr
�test_open_new_tabXs�z#ChromeCommandTest.test_open_new_tabN)
r
rrr)ZChromerr(r2r5r8rrrr
r,Es
r,c@s2eZdZejZdd�Zdd�Zdd�Zdd�Z	d	S)
�MozillaCommandTestcCs|jdgtgd�dSr$r'rrrr
r(bs�zMozillaCommandTest.test_opencCs|jdtdd�gtgd�dSr-r0rrrr
r2gs�z1MozillaCommandTest.test_open_with_autoraise_falsecCs|jdgdtgd�dS)Nr4z-new-windowr&r'rrrr
r5ls�z MozillaCommandTest.test_open_newcCs|jdgdtgd�dS)Nr7z-new-tabr&r'rrrr
r8qs�z$MozillaCommandTest.test_open_new_tabN)
r
rrr)ZMozillarr(r2r5r8rrrr
r9^s
r9c@s2eZdZejZdd�Zdd�Zdd�Zdd�Z	d	S)
�NetscapeCommandTestcCs |jdddgd�t�gd�dS)Nr%�-raise�-remote�openURL({})r&�r!�formatr"rrrr
r({s
�zNetscapeCommandTest.test_opencCs(|jdtdd�ddgd�t�gd�dS)Nr%Fr.�-noraiser<r=r/)r!r1r?r"rrrr
r2�s
�z2NetscapeCommandTest.test_open_with_autoraise_falsecCs |jdddgd�t�gd�dS)Nr4r;r<�openURL({},new-window)r&r>rrrr
r5�s
�z!NetscapeCommandTest.test_open_newcCs |jdddgd�t�gd�dS)Nr7r;r<�openURL({},new-tab)r&r>rrrr
r8�s
�z%NetscapeCommandTest.test_open_new_tabN)
r
rrr)ZNetscaperr(r2r5r8rrrr
r:ws
r:c@s2eZdZejZdd�Zdd�Zdd�Zdd�Z	d	S)
�GaleonCommandTestcCs|jddgtgd�dS)Nr%�-nr&r'rrrr
r(�s�zGaleonCommandTest.test_opencCs"|jdtdd�ddgtgd�dS)Nr%Fr.r@rDr/r0rrrr
r2�s�z0GaleonCommandTest.test_open_with_autoraise_falsecCs|jddgtgd�dS)Nr4�-wr&r'rrrr
r5�s�zGaleonCommandTest.test_open_newcCs|jddgtgd�dS)Nr7rEr&r'rrrr
r8�s�z#GaleonCommandTest.test_open_new_tabN)
r
rrr)ZGaleonrr(r2r5r8rrrr
rC�s
rCc@s2eZdZejZdd�Zdd�Zdd�Zdd�Z	d	S)
�OperaCommandTestcCs|jdgtgd�dSr$r'rrrr
r(�s�zOperaCommandTest.test_opencCs|jdtdd�gtgd�dSr-r0rrrr
r2�s�z/OperaCommandTest.test_open_with_autoraise_falsecCs|jddgtgd�dSr3r'rrrr
r5�s�zOperaCommandTest.test_open_newcCs|jdgtgd�dSr6r'rrrr
r8�s�z"OperaCommandTest.test_open_new_tabN)
r
rrr)ZOperarr(r2r5r8rrrr
rF�s
rFc@s2eZdZejZdd�Zdd�Zdd�Zdd�Z	d	S)
�ELinksCommandTestcCs|jddgd�t�gd�dS�Nr%r<r=r&r>rrrr
r(�s

�zELinksCommandTest.test_opencCs|jddgd�t�gd�dSrHr>rrrr
r2�s
�z0ELinksCommandTest.test_open_with_autoraise_falsecCs|jddgd�t�gd�dS)Nr4r<rAr&r>rrrr
r5�s
�zELinksCommandTest.test_open_newcCs|jddgd�t�gd�dS)Nr7r<rBr&r>rrrr
r8�s
�z#ELinksCommandTest.test_open_new_tabN)
r
rrr)ZElinksrr(r2r5r8rrrr
rG�s
rGc@s<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)�BrowserRegistrationTestcCs tj|_gt_tj|_it_dS�N)r)�	_tryorder�_saved_tryorder�	_browsers�_saved_browsersrrrr
�setUp�szBrowserRegistrationTest.setUpcCs|jt_|jt_dSrJ)rLr)rKrNrMrrrr
�tearDown�sz BrowserRegistrationTest.tearDowncCs�Gdd�d�}g}i}|�tj|�|�tj|�t�d|�dg}|dg|d<|�tj|�|�tj|�|�}|dur�tjd|||d�nt�d||�|r�ddg}nddg}||g|d<|�tj|�|�tj|�dS)Nc@seZdZdS)zCBrowserRegistrationTest._check_registration.<locals>.ExampleBrowserN�r
rrrrrr
�ExampleBrowser�srR�Example1�example1Zexample2��	preferred)rr)rKrM�register)r	rVrRZexpected_tryorderZexpected_browsers�instancerrr
�_check_registration�s,
�
z+BrowserRegistrationTest._check_registrationcCs|jdd�dS)NFrU�rYrrrr
�
test_registersz%BrowserRegistrationTest.test_registercCs|jdd�dS)NrUrZrrrr
�test_register_defaultsz-BrowserRegistrationTest.test_register_defaultcCs|jdd�dS)NTrUrZrrrr
�test_register_preferredsz/BrowserRegistrationTest.test_register_preferredN)	r
rrrOrPrYr[r\r]rrrr
rI�srIc@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�
ImportTestcCs�t�d�}|�|j�|�|j�Gdd�d�}|�d|�|�|j�|�|jdd�|�|j�|�	d|j�|�|jd|dg�dS)Nr)c@seZdZdS)z0ImportTest.test_register.<locals>.ExampleBrowserNrQrrrr
rRsrRrS���rT)
r�import_fresh_module�assertIsNonerK�assertFalserMrWZ
assertTruerr)r	r)rRrrr
r[s
zImportTest.test_registercCsht�d�}|�|j�|�|j�|�|j��|�d�Wd�n1sN0Y|�	|j�dS)Nr)Zfakebrowser)
rr`rarKrbrMZassertRaises�Error�getZassertIsNotNone)r	r)rrr
�test_gets
(zImportTest.test_getcCs@t�d�}tj�tj���}|�|d|�	|��|�
tj�dS)Nr))rr`�os�path�basename�sys�
executable�lowerrWr*rd)r	r)rrrr
�test_synthesize's
zImportTest.test_synthesizec
Cs�t�d�}z|��j}Wn8|jtfyP}z|�t|��WYd}~n
d}~00t���*}||d<t�d�}|��Wd�n1s�0YdS)Nr)�BROWSER)	rr`rdrrc�AttributeError�skipTest�str�EnvironmentVarGuard)r	r)r �err�envrrr
�test_environment-s
$

zImportTest.test_environmentc
Cst�d�}z|��|�|jd�j}Wn:|jttfyb}z|�t	|��WYd}~n
d}~00t�
��4}||d<t�d�}|�|��j|�Wd�n1s�0Yt�
��8}tj
|d<t�d�}|�|��jtj
�Wd�n1s�0YdS)Nr)r_rm)rr`rdrKrrcrn�
IndexErrorrorprqrrirj)r	r)Zleast_preferred_browserrrrsrrr
�test_environment_preferred8s
$

0


z%ImportTest.test_environment_preferredN)r
rrr[rerlrtrvrrrr
r^s
	r^�__main__)r)Zunittestrfrirrrrr"rZ	MagicMockrrZTestCaser#r+r,r9r:rCrFrGrIr^r
�mainrrrr
�<module>s,	

5<