î
ªÍ X€  ã               @   sÉ   d  d l  m 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 d  d l m Z Gd d	 „  d	 e e ƒ ƒ Z e d
 ƒ Gd d „  d e e e ƒ ƒ ƒ Z d S)é    )Úunicode_literalsN)Úcontextmanager)ÚLiveServerTestCaseÚtag)Úimport_string)Úwith_metaclass)Úcapfirstc                   sL   e  Z d  Z g  Z d Z ‡  f d d †  Z e d d „  ƒ Z d d „  Z ‡  S)ÚSeleniumTestCaseBaseNc       	         s  t  t |  ƒ j |  | | | ƒ } | j sJ t d d „  | j ƒ  Dƒ ƒ rN | S| j rô | j d } | | _ t j | j	 } xp | j d d … D][ } |  j |  t
 d t | ƒ | f ƒ | f i | d 6| j	 d 6ƒ } t | | j | ƒ q‘ W| St j d	 ƒ | ƒ S)
z¤
        Dynamically create new classes and add them to the test module when
        multiple browsers specs are provided (e.g. --selenium=firefox,chrome).
        c             s   s0   |  ]& \ } } | j  d  ƒ o' t | ƒ Vq d S)ÚtestN)Ú
startswithÚcallable)Ú.0ÚnameÚvalue© r   úB/home/ubuntu/projects/ifolica/build/django/django/test/selenium.pyú	<genexpr>   s    z/SeleniumTestCaseBase.__new__.<locals>.<genexpr>r   é   Nz%s%sÚbrowserÚ
__module__zNo browsers specified.)Úsuperr	   Ú__new__r   ÚanyÚitemsÚbrowsersÚsysÚmodulesr   Ústrr   ÚsetattrÚ__name__ÚunittestÚskip)	Úclsr   ÚbasesÚattrsZ
test_classZfirst_browserÚmoduler   Zbrowser_test_class)Ú	__class__r   r   r      s     !)		zSeleniumTestCaseBase.__new__c             C   s   t  d | ƒ S)Nz)selenium.webdriver.%s.webdriver.WebDriver)r   )r"   r   r   r   r   Úimport_webdriver2   s    z%SeleniumTestCaseBase.import_webdriverc             C   s   |  j  |  j ƒ ƒ  S)N)r'   r   )Úselfr   r   r   Úcreate_webdriver6   s    z%SeleniumTestCaseBase.create_webdriver)	r   r   Ú__qualname__r   r   r   Úclassmethodr'   r)   r   r   )r&   r   r	      s
   r	   Úseleniumc                   sX   e  Z d  Z d Z e ‡  f d d †  ƒ Z e ‡  f d d †  ƒ Z e d d „  ƒ Z ‡  S)ÚSeleniumTestCaseé
   c                s9   |  j  ƒ  |  _ |  j j |  j ƒ t t |  ƒ j ƒ  d  S)N)r)   r,   Úimplicitly_waitÚimplicit_waitr   r-   Ú
setUpClass)r"   )r&   r   r   r1   >   s    zSeleniumTestCase.setUpClassc                s6   t  |  d ƒ r |  j j ƒ  n  t t |  ƒ j ƒ  d  S)Nr,   )Úhasattrr,   Úquitr   r-   Ú_tearDownClassInternal)r"   )r&   r   r   r4   D   s    z'SeleniumTestCase._tearDownClassInternalc             c   s4   |  j  j d ƒ z	 d VWd |  j  j |  j ƒ Xd S)z8Context manager that disables the default implicit wait.r   N)r,   r/   r0   )r(   r   r   r   Údisable_implicit_waitM   s    	z&SeleniumTestCase.disable_implicit_wait)	r   r   r*   r0   r+   r1   r4   r   r5   r   r   )r&   r   r-   :   s   	r-   )Ú
__future__r   r   r    Ú
contextlibr   Zdjango.testr   r   Zdjango.utils.module_loadingr   Zdjango.utils.sixr   Zdjango.utils.textr   Útyper	   r-   r   r   r   r   Ú<module>   s   -