Your IP : 216.73.216.196


Current Path : /opt/alt/python37/lib64/python3.7/test/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib64/python3.7/test/__pycache__/test_webbrowser.cpython-37.pyc

B

� f�)�@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/python37/lib64/python3.7/test/test_webbrowser.py�pollszPopenMock.pollNcCsdS)Nrr)rZsecondsrrr�waitszPopenMock.wait)N)�__name__�
__module__�__qualname__r	r
rrrrrsrc@seZdZegid�dd�ZdS)�CommandTestMixin)�args�kwc
Cs�t�}t�|td|�|jtd�}t||�||�tjjdd}|�	|dt�|�
d�x(|D] }	|�|	|�|�
|�|	��qbW|�	||�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�getattrr�	call_args�assertEqual�pop�assertIn�index)
rZmethrr�options�	arguments�popen�browserZ
popen_argsZoptionrrr�_tests

zCommandTestMixin._testN)rrr
�URLr rrrrrsrc@seZdZejZdd�ZdS)�GenericBrowserCommandTestcCs|jdgtgd�dS)N�open)rr)r r!)rrrr�	test_open5sz#GenericBrowserCommandTest.test_openN)rrr
�
webbrowser�GenericBrowserrr$rrrrr"1sr"c@seZdZejZdd�ZdS)�BackgroundBrowserCommandTestcCs|jdgtgd�dS)Nr#)rr)r r!)rrrrr$?sz&BackgroundBrowserCommandTest.test_openN)rrr
r%ZBackgroundBrowserrr$rrrrr';sr'c@s2eZdZejZdd�Zdd�Zdd�Zdd�Z	d	S)
�ChromeCommandTestcCs|jdgtgd�dS)Nr#)rr)r r!)rrrrr$IszChromeCommandTest.test_opencCs|jdtdd�gtgd�dS)Nr#F)�	autoraise)rrr)r �dictr!)rrrr�test_open_with_autoraise_falseNsz0ChromeCommandTest.test_open_with_autoraise_falsecCs|jddgtgd�dS)N�open_newz--new-window)rr)r r!)rrrr�
test_open_newSszChromeCommandTest.test_open_newcCs|jdgtgd�dS)N�open_new_tab)rr)r r!)rrrr�test_open_new_tabXsz#ChromeCommandTest.test_open_new_tabN)
rrr
r%ZChromerr$r+r-r/rrrrr(Es
r(c@s2eZdZejZdd�Zdd�Zdd�Zdd�Z	d	S)
�MozillaCommandTestcCs|jdgtgd�dS)Nr#)rr)r r!)rrrrr$bszMozillaCommandTest.test_opencCs|jdtdd�gtgd�dS)Nr#F)r))rrr)r r*r!)rrrrr+gsz1MozillaCommandTest.test_open_with_autoraise_falsecCs|jdgdtgd�dS)Nr,z-new-window)rr)r r!)rrrrr-lsz MozillaCommandTest.test_open_newcCs|jdgdtgd�dS)Nr.z-new-tab)rr)r r!)rrrrr/qsz$MozillaCommandTest.test_open_new_tabN)
rrr
r%ZMozillarr$r+r-r/rrrrr0^s
r0c@s2eZdZejZdd�Zdd�Zdd�Zdd�Z	d	S)
�NetscapeCommandTestcCs |jdddgd�t�gd�dS)Nr#z-raisez-remotezopenURL({}))rr)r �formatr!)rrrrr${szNetscapeCommandTest.test_opencCs(|jdtdd�ddgd�t�gd�dS)Nr#F)r)z-noraisez-remotezopenURL({}))rrr)r r*r2r!)rrrrr+�sz2NetscapeCommandTest.test_open_with_autoraise_falsecCs |jdddgd�t�gd�dS)Nr,z-raisez-remotezopenURL({},new-window))rr)r r2r!)rrrrr-�sz!NetscapeCommandTest.test_open_newcCs |jdddgd�t�gd�dS)Nr.z-raisez-remotezopenURL({},new-tab))rr)r r2r!)rrrrr/�sz%NetscapeCommandTest.test_open_new_tabN)
rrr
r%ZNetscaperr$r+r-r/rrrrr1ws
r1c@s2eZdZejZdd�Zdd�Zdd�Zdd�Z	d	S)
�GaleonCommandTestcCs|jddgtgd�dS)Nr#z-n)rr)r r!)rrrrr$�szGaleonCommandTest.test_opencCs"|jdtdd�ddgtgd�dS)Nr#F)r)z-noraisez-n)rrr)r r*r!)rrrrr+�sz0GaleonCommandTest.test_open_with_autoraise_falsecCs|jddgtgd�dS)Nr,z-w)rr)r r!)rrrrr-�szGaleonCommandTest.test_open_newcCs|jddgtgd�dS)Nr.z-w)rr)r r!)rrrrr/�sz#GaleonCommandTest.test_open_new_tabN)
rrr
r%ZGaleonrr$r+r-r/rrrrr3�s
r3c@s2eZdZejZdd�Zdd�Zdd�Zdd�Z	d	S)
�OperaCommandTestcCs|jdgtgd�dS)Nr#)rr)r r!)rrrrr$�szOperaCommandTest.test_opencCs|jdtdd�gtgd�dS)Nr#F)r))rrr)r r*r!)rrrrr+�sz/OperaCommandTest.test_open_with_autoraise_falsecCs|jddgtgd�dS)Nr,z--new-window)rr)r r!)rrrrr-�szOperaCommandTest.test_open_newcCs|jdgtgd�dS)Nr.)rr)r r!)rrrrr/�sz"OperaCommandTest.test_open_new_tabN)
rrr
r%ZOperarr$r+r-r/rrrrr4�s
r4c@s2eZdZejZdd�Zdd�Zdd�Zdd�Z	d	S)
�ELinksCommandTestcCs|jddgd�t�gd�dS)Nr#z-remotezopenURL({}))rr)r r2r!)rrrrr$�s
zELinksCommandTest.test_opencCs|jddgd�t�gd�dS)Nr#z-remotezopenURL({}))rr)r r2r!)rrrrr+�sz0ELinksCommandTest.test_open_with_autoraise_falsecCs|jddgd�t�gd�dS)Nr,z-remotezopenURL({},new-window))rr)r r2r!)rrrrr-�szELinksCommandTest.test_open_newcCs|jddgd�t�gd�dS)Nr.z-remotezopenURL({},new-tab))rr)r r2r!)rrrrr/�sz#ELinksCommandTest.test_open_new_tabN)
rrr
r%ZElinksrr$r+r-r/rrrrr5�s
r5c@s<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)�BrowserRegistrationTestcCs tj|_gt_tj|_it_dS)N)r%�	_tryorder�_saved_tryorder�	_browsers�_saved_browsers)rrrr�setUp�szBrowserRegistrationTest.setUpcCs|jt_|jt_dS)N)r8r%r7r:r9)rrrr�tearDown�sz BrowserRegistrationTest.tearDowncCs�Gdd�d�}g}i}|�tj|�|�tj|�t�d|�dg}|dg|d<|�tj|�|�tj|�|�}|dk	r�tjd|||d�nt�d||�|r�ddg}nddg}||g|d<|�tj|�|�tj|�dS)Nc@seZdZdS)zCBrowserRegistrationTest._check_registration.<locals>.ExampleBrowserN)rrr
rrrr�ExampleBrowser�sr=�Example1�example1Zexample2)�	preferred)rr%r7r9�register)rr@r=Zexpected_tryorderZexpected_browsers�instancerrr�_check_registration�s*


z+BrowserRegistrationTest._check_registrationcCs|jdd�dS)NF)r@)rC)rrrr�
test_registersz%BrowserRegistrationTest.test_registercCs|jdd�dS)N)r@)rC)rrrr�test_register_defaultsz-BrowserRegistrationTest.test_register_defaultcCs|jdd�dS)NT)r@)rC)rrrr�test_register_preferredsz/BrowserRegistrationTest.test_register_preferredN)	rrr
r;r<rCrDrErFrrrrr6�sr6c@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>.ExampleBrowserN)rrr
rrrrr=sr=r>���r?)
r�import_fresh_module�assertIsNoner7�assertFalser9rAZ
assertTruerr)rr%r=rrrrDs
zImportTest.test_registerc	CsTt�d�}|�|j�|�|j�|�|j��|�d�WdQRX|�	|j�dS)Nr%Zfakebrowser)
rrIrJr7rKr9ZassertRaises�Error�getZassertIsNotNone)rr%rrr�test_gets
zImportTest.test_getcCs@t�d�}tj�tj���}|�|d|�	|��|�
tj�dS)Nr%)rrI�os�path�basename�sys�
executable�lowerrAr&rM)rr%rrrr�test_synthesize's
zImportTest.test_synthesizec
Cs�t�d�}y|��j}Wn6|jtfk
rN}z|�t|��Wdd}~XYnXt��� }||d<t�d�}|��WdQRXdS)Nr%�BROWSER)	rrIrMrrL�AttributeError�skipTest�str�EnvironmentVarGuard)rr%r�err�envrrr�test_environment-s
 

zImportTest.test_environmentc
Cs�t�d�}y|��|�|jd�j}Wn8|jttfk
r`}z|�t	|��Wdd}~XYnXt�
��*}||d<t�d�}|�|��j|�WdQRXt�
��.}tj
|d<t�d�}|�|��jtj
�WdQRXdS)Nr%rHrV)rrIrMr7rrLrW�
IndexErrorrXrYrZrrRrS)rr%Zleast_preferred_browserr[r\rrr�test_environment_preferred8s
 




z%ImportTest.test_environment_preferredN)rrr
rDrNrUr]r_rrrrrGs
	rG�__main__)r%ZunittestrOrRrrrrr!rZ	MagicMockrrZTestCaser"r'r(r0r1r3r4r5r6rGr�mainrrrr�<module>s,	

5<