ó
‹²,]c           @   s  d  Z  y d d l m Z m Z Wn' e k
 rI d d l m Z m Z n Xd d l m Z d d l m	 Z	 d d l
 m Z d d l Z d d l m Z d d l m Z d d	 l m Z e j d
 „  ƒ Z d „  Z e d d ƒ e j j e d k d d ƒd „  ƒ ƒ Z e d d ƒ e j j e d k d d ƒd „  ƒ ƒ Z e j j e d k d d ƒd „  ƒ Z e d k r}e j ƒ  n  d S(   s/   
Tests for the Spyder `help` plugn, `help.py`.
iÿÿÿÿ(   t   Mockt	   MagicMock(   t   PYQT_VERSION(   t   QWidget(   t	   WEBENGINEN(   t   flaky(   t   Help(   t   default_info_responsec         C   su   d t  f d „  ƒ  Y} t d | ƒ  ƒ } | j j j } t rO | j ƒ  | _ n | j ƒ  j ƒ  | _ |  j	 | ƒ | S(   s   Help plugin fixturet   MainMockc           B   s   e  Z d  „  Z RS(   c         S   s'   | d k s | d k r d  St ƒ  Sd  S(   Nt
   ipyconsolet   editor(   t   NoneR    (   t   selft   attr(    (    s=   lib/python2.7/site-packages/spyder/plugins/tests/test_help.pyt   __getattr__'   s    (   t   __name__t
   __module__R   (    (    (    s=   lib/python2.7/site-packages/spyder/plugins/tests/test_help.pyR   &   s   t   parent(
   R   R   t	   rich_textt   webviewt   _webviewR   t   paget   _webpaget	   mainFramet	   addWidget(   t   qtbotR   t   help_pluginR   (    (    s=   lib/python2.7/site-packages/spyder/plugins/tests/test_help.pyR   "   s    c         C   sV   t  rB d „  } |  j | ƒ y | t k SWqR t k
 r> t SXn | |  j ƒ  k Sd S(   s*   Check if some text is present in a widget.c         S   s
   |  a  d  S(   N(   t   html(   t   data(    (    s=   lib/python2.7/site-packages/spyder/plugins/tests/test_help.pyt   callback?   s    N(   R   t   toHtmlR   t	   NameErrort   False(   t   widgett   textR   (    (    s=   lib/python2.7/site-packages/spyder/plugins/tests/test_help.pyt
   check_text<   s    	t   max_runsi   s   5.10t   reasons   Segfaults in PyQt 5.10+c            s0   ˆ  j  t ƒ  ƒ | j ‡  f d †  d d ƒd S(   s`   
    Test that no docs message is shown when instrospection plugins
    can't get any info.
    c              s   t  ˆ  j d ƒ S(   Ns   No documentation available(   R#   R   (    (   R   (    s=   lib/python2.7/site-packages/spyder/plugins/tests/test_help.pyt   <lambda>V   s   	t   timeouti   N(   t   render_sphinx_docR   t	   waitUntil(   R   R   (    (   R   s=   lib/python2.7/site-packages/spyder/plugins/tests/test_help.pyt   test_no_docs_messageN   s    c            sJ   t  ƒ  } d | d <d | d <ˆ  j | ƒ | j ‡  f d †  d d ƒd S(	   sj   
    Test that no further docs message is shown when instrospection
    plugins can get partial info.
    t   foot   names   (x, y)t   argspecc              s   t  ˆ  j d ƒ S(   Ns"   No further documentation available(   R#   R   (    (   R   (    s=   lib/python2.7/site-packages/spyder/plugins/tests/test_help.pyR&   g   s   	R'   i¸  N(   R   R(   R)   (   R   R   t   info(    (   R   s=   lib/python2.7/site-packages/spyder/plugins/tests/test_help.pyt   test_no_further_docs_message[   s    	

c         C   s¹   t  ƒ  } t | j j _ | ƒ  } t ƒ  } | |  _ | |  _ |  j ƒ  | j d ƒ | j	 d k sh t
 ‚ t | j j _ | ƒ  } | |  _ |  j ƒ  | j d ƒ | j	 d k sµ t
 ‚ d S(   sE   Test fix for #6317 : 'Show tutorial' opens the help plugin if closed.id   i   i   N(   R   R    t   return_valuet	   isVisibleR    t
   dockwidgett   show_rich_textt   show_tutorialt   waitt
   call_countt   AssertionErrort   True(   R   R   t   MockDockwidgett   mockDockwidget_instancet   mock_show_rich_text(    (    s=   lib/python2.7/site-packages/spyder/plugins/tests/test_help.pyt'   test_help_opens_when_show_tutorial_unitl   s    					
		
t   __main__(   t   __doc__t   unittest.mockR    R   t   ImportErrort   mockt   qtpyR   t   qtpy.QtWidgetsR   t   qtpy.QtWebEngineWidgetsR   t   pytestR   t   spyder.plugins.helpR   t    spyder.utils.introspection.utilsR   t   fixtureR   R#   t   markt   skipifR*   R/   R<   R   t   main(    (    (    s=   lib/python2.7/site-packages/spyder/plugins/tests/test_help.pyt   <module>   s(   	**'