ó
‹²,]c        	   @   sH  d  Z  d d l Z d d l j Z d d l Z d d l Z y d d l m Z m	 Z	 Wn' e
 k
 r| d d l m Z m	 Z	 n Xd d l Z d d l Z d d l m Z d d l m Z d d l Z d d l m Z d d l Z d d l m Z m Z d d l m Z m Z m Z m Z d d	 l m Z d d
 l  m! Z! d d l" m# Z# m$ Z$ m% Z% m& Z& d d l' m( Z( d d l) m* Z* d d l+ Z+ d d l, m- Z- m. Z. d d l/ m0 Z0 d d l1 m2 Z2 d d l3 m4 Z4 m5 Z5 d d l6 m7 Z7 d d l8 m9 Z9 d d l: m; Z; d d l< m= Z= d d l> m? Z? d d l@ mA ZA mB ZB d d lC mD ZD d d lE mF ZF eA s~d d lG mH ZH d d lI mJ ZJ n d d lK mH ZH mJ ZJ e jL e jM e jN ƒ  e jO eP ƒ ƒ ƒ ZQ d ZR d ZS d ZT e jU ƒ  ZV d d  „ ZX d! „  ZY d" „  ZZ d# d$ e[ d% „ Z\ d& „  Z] e j^ d' „  ƒ Z_ e j` ja e j` jb e d( d) ƒ e j` jc e jd d* k paeA d+ d, ƒd- „  ƒ ƒ ƒ ƒ Ze e j` ja e j` jf d. i dp d2 6g d3 eg ƒd4 „  ƒ ƒ Zh e j` ja e d( d) ƒ e j` jc e ji d5 k  d+ d6 ƒe j` jf d. i d7 d8 eg f d2 6g d3 eg ƒd9 „  ƒ ƒ ƒ ƒ Zj e j` ja e d( d) ƒ e j` jc eA d+ d: ƒd; „  ƒ ƒ ƒ Zk e j` ja e d( d) ƒ e j` jb d< „  ƒ ƒ ƒ Zl e j` ja d= „  ƒ Zm e j` ja e j` jn e j` jc eA oæe jo jp d> d ƒ d k d+ d? ƒd@ „  ƒ ƒ ƒ Zq e j` ja e d( d) ƒ e j` jc e jd d* k p1eA d+ dA ƒdB „  ƒ ƒ ƒ Zr e j` ja e d( d) ƒ e j` jc e jo jp d> d ƒ d k p‘e js dC k d+ dD ƒdE „  ƒ ƒ ƒ Zt e j` ja e d( d) ƒ e j` jc e jd d* k rßeA pëe js dC k d+ dF ƒdG „  ƒ ƒ ƒ Zu e j` ja e d( d) ƒ dH „  ƒ ƒ Zv e j` ja e d( d) ƒ e j` jc e jd d* k d+ dI ƒdJ „  ƒ ƒ ƒ Zw e j` ja e d( d) ƒ e j` jf dK dL dM g ƒ e j` jc e js dC k d+ dN ƒdO „  ƒ ƒ ƒ ƒ Zx e j` ja e d( d) ƒ e j` jf dK dL dM g ƒ e j` jc e js dC k d+ dN ƒdP „  ƒ ƒ ƒ ƒ Zy e j` ja e d( d) ƒ e j` jc e jd d* k pueF dQ ƒ pue js dC k d+ dR ƒdS „  ƒ ƒ ƒ Zz e j` ja e d( d) ƒ e j` jc e jd d* k d+ dT ƒdU „  ƒ ƒ ƒ Z{ e j` ja e d( d) ƒ e j` jc e jd d* k d+ dI ƒdV „  ƒ ƒ ƒ Z| e j` ja e d( d) ƒ e j` jc e js dC k d+ dN ƒdW „  ƒ ƒ ƒ Z} e j` ja e d( d) ƒ e j` jc e jd d* k pªe jo jp d> d ƒ d k pªe d+ dX ƒdY „  ƒ ƒ ƒ Z~ e j` ja e d( d) ƒ dZ „  ƒ ƒ Z e j` ja e d( d) ƒ d[ „  ƒ ƒ Z€ e d( d) ƒ e j` jc e jd d* k pU	e jo jp d> d ƒ d k	 oU	e d\ k d+ d] ƒd^ „  ƒ ƒ Z e j` ja e d( d) ƒ e j` jc e jd d* k d+ dI ƒd_ „  ƒ ƒ ƒ Z‚ e j` ja e d( d) ƒ e j` jc e jd d* k d+ dI ƒd` „  ƒ ƒ ƒ Zƒ e j` ja e d( d) ƒ e j` jc e jd d* k d+ dI ƒda „  ƒ ƒ ƒ Z„ e j` ja e d( d) ƒ e j` jc e jd d* k d+ dI ƒdb „  ƒ ƒ ƒ Z… e j` ja e d( d) ƒ e j` jc e jd d* k p±
eA d+ dc ƒdd „  ƒ ƒ ƒ Z† e j` ja e d( d) ƒ e j` jc eA d+ dc ƒde „  ƒ ƒ ƒ Z‡ e j` ja e d( d) ƒ e j` jc e jo jp d> d ƒ d k pMe js dC k d+ df ƒdg „  ƒ ƒ ƒ Zˆ e j` ja e d( d) ƒ dh „  ƒ ƒ Z‰ e d( d) ƒ di „  ƒ ZŠ e d( d) ƒ e j` ja dj „  ƒ ƒ Z‹ e d( d) ƒ e j` ja e j` jc e jo jp d> d ƒ d k d+ dk ƒdl „  ƒ ƒ ƒ ZŒ dm „  Z dn „  ZŽ e do k rDe j ƒ  n  d S(q   s   
Tests for the main window.
iÿÿÿÿN(   t   Mockt	   MagicMock(   t   flaky(   t   KernelManager(   t   assert_array_equal(   t   PYQT5t   PYQT_VERSION(   t   Qtt   QTimert   QEventt   QUrl(   t   QTest(   t   QImage(   t   QApplicationt   QFileDialogt	   QLineEditt   QTabBar(   t	   WEBENGINE(   t   compare_images(   t   __trouble_url__t   __project_url__(   t   start(   t
   MainWindow(   t   get_home_dirt   get_module_path(   t   CONF(   t	   TabFilter(   t   ObjectComboBox(   t   RunConfiguration(   t
   check_text(   t   PY2t   to_text_string(   t   SpyderKernelSpec(   t   is_module_installed(   t   urlopen(   t   URLError(   R"   R#   i N  i0u  i¸  c         C   s‚   t  j ƒ  } xo | D]g } t | t ƒ r | d k	 rD | j | ƒ n  | j t ƒ d } | j | ƒ t	 j
 | t j ƒ q q Wd S(   s5   Open a file using the Editor and its open file dialogi    N(   R   t   topLevelWidgetst
   isinstanceR   t   Nonet   setDirectoryt   findChildrenR   t   setTextR   t   keyClickR   t	   Key_Enter(   t   main_windowt   fnamet	   directoryt   top_level_widgetst   wt   input_field(    (    s?   lib/python2.7/site-packages/spyder/app/tests/test_mainwindow.pyt   open_file_in_editorW   s    c         C   s.   x' |  j  D] } | j ƒ  | k r
 | Sq
 Wd S(   s>   Get a reference to the thirdparty plugin with the title given.N(   t   thirdparty_pluginst   get_plugin_title(   R,   t   plugin_titlet   plugin(    (    s?   lib/python2.7/site-packages/spyder/app/tests/test_mainwindow.pyt   get_thirdparty_pluginc   s    c            sl   |  j  | j ƒ  | j d ƒ Wd QX|  j ‡  f d †  d t ƒ| j ƒ  |  j | t j d t j	 ƒd S(   s!   Reset state after a run code tests	   %reset -fNc              s   ˆ  j  j j ƒ  d k S(   Ni    (   t   editort   modelt   rowCount(    (   t   nsb(    s?   lib/python2.7/site-packages/spyder/app/tests/test_mainwindow.pyt   <lambda>n   t    t   timeoutt   modifier(
   t
   waitSignalt   executedt   executet	   waitUntilt   EVAL_TIMEOUTt   setFocusR*   R   t   Key_Homet   ControlModifier(   t   qtbott   shellt   code_editorR;   (    (   R;   s?   lib/python2.7/site-packages/spyder/app/tests/test_mainwindow.pyt   reset_run_codej   s
    
i<   t   pythonc         K   s   t  d | ƒ } | r$ t ƒ  | _ n  | j |   | j ƒ  } | j ƒ  y | j d |  ƒ Wn( t k
 r… | j ƒ  | j	 ƒ  ‚  n X| | f S(   s5   Start a new kernel, and return its Manager and Clientt   kernel_nameR>   (
   R   R    t   _kernel_spect   start_kernelt   clientt   start_channelst   wait_for_readyt   RuntimeErrort   stop_channelst   shutdown_kernel(   t   startup_timeoutRM   t	   spykernelt   kwargst   kmt   kc(    (    s?   lib/python2.7/site-packages/spyder/app/tests/test_mainwindow.pyt   start_new_kernels   s    


c         C   sf   | j  t ƒ } xP | D]H } x? t | j ƒ  ƒ D]+ } | j | ƒ t |  ƒ k r/ | | f Sq/ Wq Wd S(   N(   NN(   R(   R   t   ranget   countt   tabTextt   strR&   (   t   tab_namet   windowt   all_tabbarst   current_tabbart	   tab_index(    (    s?   lib/python2.7/site-packages/spyder/app/tests/test_mainwindow.pyt   find_desired_tab_in_window†   s    c            s   t  j d d d ƒ |  j j d ƒ } | r; d t j d <n( y t j j d ƒ Wn t k
 rb n X|  j j d ƒ } | r‘ t  j d d t ƒ n t  j d d t	 ƒ y< |  j
 } t | t ƒ rß d	 | k rß t  j | d	 Œ  n  Wn t k
 ró n Xt j ƒ  ‰  ‡  f d
 †  } |  j | ƒ ˆ  S(   s   Main Window fixturet   ipython_consoles   pylab/backendi    t   use_introspectiont   Truet   SPY_TEST_USE_INTROSPECTIONt   single_instancet   maint
   spy_configc              s   ˆ  j  ƒ  d  S(   N(   t   close(    (   Ra   (    s?   lib/python2.7/site-packages/spyder/app/tests/test_mainwindow.pyt   close_window¶   s    (   R   t   sett   nodet
   get_markert   ost   environt   popt   KeyErrorRh   t   Falset   paramR%   t   dictt   AttributeErrorR   Rk   t   addfinalizer(   t   requestRg   Rj   Rw   Rn   (    (   Ra   s?   lib/python2.7/site-packages/spyder/app/tests/test_mainwindow.pyR,   ’   s,    	t   max_runsi   t   ntt   reasons/   Times out on AppVeyor and fails on PY3/PyQt 5.6c            sA  d } |  j  j d d d | ƒ |  j  j ƒ  } | j | ƒ | j d ƒ | j d ƒ | j ‰  ˆ  j ƒ  sq t ‚ | j	 | t
 j d d ƒ| j	 | t
 j d d	 ƒ| j ‡  f d
 †  d d ƒ| j	 | t
 j d d	 ƒ| j	 | t
 j ƒ ˆ  j ƒ  sþ t ‚ | j	 | t
 j d d	 ƒ| j	 | t
 j d d	 ƒ|  j  j ƒ  d S(   sE   Test that the calltip in editor is hidden when matching ')' is found.s   a = [1,2,3]
(maxR-   s   test.pyt   texti   i   t   delayi¸  iè  c              s
   ˆ  j  ƒ  S(   N(   t	   isVisible(    (   t   calltip(    s?   lib/python2.7/site-packages/spyder/app/tests/test_mainwindow.pyR<   ×   R=   R>   N(   R8   t   newt   get_focus_widgett   set_textt
   go_to_linet   move_cursort   calltip_widgetR   t   AssertionErrort   keyPressR   t   Key_ParenLeftt   Key_ARC   t   Key_ParenRightt	   Key_SpaceR+   t
   close_file(   R,   RH   R   RJ   (    (   R‚   s?   lib/python2.7/site-packages/spyder/app/tests/test_mainwindow.pyt   test_calltipÂ   s"    	R,   Rk   t   openglt   softwareRl   t   indirectc         C   s,   |  j  d ƒ s t ‚ t j d d d ƒ d S(   sE   
    Test that we are setting the selected OpenGL implementation
    R’   Rk   R‘   t	   automaticN(   t   _test_setting_openglR‰   R   Ro   (   R,   RH   (    (    s?   lib/python2.7/site-packages/spyder/app/tests/test_mainwindow.pyt   test_opengl_implementationâ   s    s   1.14.0s    This only happens in Numpy 1.14+t   variable_explorert   minmaxc            s®   |  j  j ƒ  ‰  ˆ  j } | j ‡  f d †  d t ƒ| j ˆ  j ƒ  ˆ  j d ƒ Wd QX| j d ƒ d | j	 ƒ  k s t
 ‚ d | j	 ƒ  k s— t
 ‚ t j d d	 t ƒ d S(
   s©   
    Test that we filter a warning shown when an array contains nan
    values and the Variable Explorer option 'Show arrays min/man'
    is on.

    For issue 7063
    c              s   ˆ  j  d  k	 S(   N(   t   _prompt_htmlR&   (    (   RI   (    s?   lib/python2.7/site-packages/spyder/app/tests/test_mainwindow.pyR<   ü   R=   R>   s)   import numpy as np; A=np.full(16, np.nan)Niè  t   warningt   WarningR—   R˜   (   t
   ipyconsolet   get_current_shellwidgett   _controlRC   t   SHELL_TIMEOUTR@   RA   RB   t   waitt   toPlainTextR‰   R   Ro   Rv   (   R,   RH   t   control(    (   RI   s?   lib/python2.7/site-packages/spyder/app/tests/test_mainwindow.pyt   test_filter_numpy_warningî   s    	s   Times out in PY2c            s…  |  j  j ƒ  ‰  | j ‡  f d †  d t ƒ|  j } | j j j } t rX | j	 ƒ  ‰ n | j	 ƒ  j
 ƒ  ‰ | j ˆ  j ƒ  ˆ  j d ƒ Wd QX| j j ƒ  | j | j d d d ƒ| j ‡ f d †  d d	 ƒ| j | j d
 d d ƒ| j ‡ f d †  d d	 ƒ| j j d ƒ | j | j d d d ƒ| j ‡ f d †  d d	 ƒ| j | j d
 d d ƒ| j ‡ f d †  d d	 ƒd S(   sP   
    Test that Help can display docstrings for names typed in its combobox.
    c              s   ˆ  j  d  k	 S(   N(   R™   R&   (    (   RI   (    s?   lib/python2.7/site-packages/spyder/app/tests/test_mainwindow.pyR<     R=   R>   s   import numpy as npNt   numpyR€   id   c              s   t  ˆ  d ƒ S(   Nt   NumPy(   R   (    (   t   webpage(    s?   lib/python2.7/site-packages/spyder/app/tests/test_mainwindow.pyR<   *  R=   ip  s   .arangec              s   t  ˆ  d ƒ S(   Nt   arange(   R   (    (   R¦   (    s?   lib/python2.7/site-packages/spyder/app/tests/test_mainwindow.pyR<   0  R=   R=   t   npc              s   t  ˆ  d ƒ S(   NR¥   (   R   (    (   R¦   (    s?   lib/python2.7/site-packages/spyder/app/tests/test_mainwindow.pyR<   9  R=   c              s   t  ˆ  d ƒ S(   NR§   (   R   (    (   R¦   (    s?   lib/python2.7/site-packages/spyder/app/tests/test_mainwindow.pyR<   ?  R=   (   Rœ   R   RC   RŸ   t   helpt	   rich_textt   webviewt   _webviewR   t   paget	   mainFrameR@   RA   RB   t   combot   selectedt	   keyClickst   set_current_text(   R,   RH   t   help_pluginR«   (    (   RI   R¦   s?   lib/python2.7/site-packages/spyder/app/tests/test_mainwindow.pyt   test_get_help_combo  s(    	c            s+  |  j  j ƒ  ‰  ˆ  j } | j ‡  f d †  d t ƒ|  j } | j j j } t	 ra | j
 ƒ  ‰ n | j
 ƒ  j ƒ  ‰ | j | d ƒ | j ƒ  | j ‡ f d †  d d ƒ| j d ƒ |  j j ƒ  |  j j ƒ  } |  j j ƒ  } | j d ƒ | j t d ƒ ƒ | j ƒ  | j ‡ f d †  d d ƒd	 S(
   sS   
    Test that Help works when called from the Editor and the IPython console.
    c              s   ˆ  j  d  k	 S(   N(   R™   R&   (    (   RI   (    s?   lib/python2.7/site-packages/spyder/app/tests/test_mainwindow.pyR<   K  R=   R>   t   runfilec              s   t  ˆ  d ƒ S(   Nt	   namespace(   R   (    (   R¦   (    s?   lib/python2.7/site-packages/spyder/app/tests/test_mainwindow.pyR<   ]  R=   ip  i¸  R\   c              s   t  ˆ  d ƒ S(   NR\   (   R   (    (   R¦   (    s?   lib/python2.7/site-packages/spyder/app/tests/test_mainwindow.pyR<   m  R=   N(   Rœ   R   Rž   RC   RŸ   R©   Rª   R«   R¬   R   R­   R®   R±   t   inspect_current_objectR    R8   Rƒ   R„   t   get_current_editorstackR…   R‡   t   len(   R,   RH   R¢   R³   R«   RJ   t   editorstack(    (   RI   R¦   s?   lib/python2.7/site-packages/spyder/app/tests/test_mainwindow.pyt   test_get_helpB  s(    		

c         C   s    |  j  } t | j d ƒ ƒ } | j d | ƒ d |  _ |  j ƒ  |  j } d | k s\ t ‚ d | k sn t ‚ d | k s€ t ‚ d | k s’ t ‚ | j ƒ  d S(   s,   Test window title with non-ascii characters.u   æ¸¬è©¦t   pathu   Ø§Ø®ØªØ¨Ø§Ø±u   Spyderu   PythonN(	   t   projectsR   t   mkdirt   open_projectt   window_titlet   set_window_titlet
   base_titleR‰   t   close_project(   R,   t   tmpdirR½   R¼   t   title(    (    s?   lib/python2.7/site-packages/spyder/app/tests/test_mainwindow.pyt   test_window_titlep  s    		
	t   CIs3   It's not meant to be run outside of CIs in Python 2c      	      s[  |  j  j ƒ  } |  j j ƒ  ‰  | j ‡  f d †  d t ƒt j t d ƒ ƒ } d j	 d | ƒ } | j
 ˆ  j ƒ  ˆ  j | ƒ Wd QXˆ  j d ƒ s t ‚ | j ƒ  } | j d ƒ j d	 ƒ } | j | ƒ | j
 ˆ  j ƒ ! ˆ  j d
 j	 t | ƒ ƒ ƒ Wd QX| j d ƒ | j ƒ  | d k s,t ‚ | j ƒ  j ƒ  | k sJt ‚ |  j  j ƒ  d S(   s.   Test single instance mode and for %edit magic.c              s   ˆ  j  d  k	 S(   N(   R™   R&   (    (   RI   (    s?   lib/python2.7/site-packages/spyder/app/tests/test_mainwindow.pyR<     R=   R>   t   spydersò   import sys
sys.path.append(r'{spy_dir_str}')
from spyder.config.base import get_conf_path
from spyder.utils.external import lockfile
lock_file = get_conf_path('spyder.lock')
lock = lockfile.FilesystemLock(lock_file)
lock_created = lock.lock()t   spy_dir_strNt   lock_createdt   foos   bar.pys   %edit {}i¸  i   (   R8   R¸   Rœ   R   RC   RŸ   t   ospt   dirnameR   t   formatR@   RA   RB   t	   get_valueR‰   t   get_stack_countR¾   t   joint   writeR   R    t   get_current_editorR¡   R   (   R,   RH   RÄ   Rº   t   spy_dirt	   lock_codet	   n_editorst   p(    (   RI   s?   lib/python2.7/site-packages/spyder/app/tests/test_mainwindow.pyt#   test_single_instance_and_edit_magicˆ  s$    		"s   It fails sometimesc            s¡  |  j  j ƒ  ‰  | j ‡  f d †  d t ƒˆ  j } |  j d } |  j j | ƒ } |  j j	 ƒ  t
 j t d ƒ } |  j j | ƒ |  j j ƒ  } | j d d ƒ | j d ƒ | j | t j ƒ | j d ƒ ˆ  j ƒ  | j d ƒ ˆ  j j d	 ƒ | j d ƒ d
 | j ƒ  k st ‚ ˆ  j j d ƒ | j d ƒ | j d d ƒ | j d ƒ | j | t j ƒ | j d ƒ ˆ  j sƒt ‚ |  j j	 ƒ  |  j j ƒ  d S(   sA   Test that we move to the first breakpoint if there's one present.c              s   ˆ  j  d  k	 S(   N(   R™   R&   (    (   RI   (    s?   lib/python2.7/site-packages/spyder/app/tests/test_mainwindow.pyR<   ¶  R=   R>   i    s	   script.pyt   line_numberi
   iô  iè  t   lists   1--> 10 arr = np.array(li)t   exiti   N(   Rœ   R   RC   RŸ   Rž   t   debug_toolbar_actionst   debug_toolbart   widgetForActionR8   t   clear_all_breakpointsRÌ   RÑ   t   LOCATIONt   loadR„   t   add_remove_breakpointR    t
   mouseClickR   t
   LeftButtont   clear_consolet   kernel_clientt   inputR¡   R‰   t   _readingR   (   R,   RH   R¢   t   debug_actiont   debug_buttont	   test_fileRJ   (    (   RI   s?   lib/python2.7/site-packages/spyder/app/tests/test_mainwindow.pyt   test_move_to_first_breakpoint¯  s6    	
t   darwins3   It's not meant to be run locally and fails in macOSc            s'  t  j d d g  ƒ t j t d ƒ } |  j j | ƒ |  j j ƒ  } t ƒ  j	 ƒ  } t
 | d <t | d <| | f } t  j d d | g ƒ |  j j ƒ  ‰  | j ‡  f d †  d t ƒ| j | t j ƒ | j d ƒ | j ˆ  j ƒ  ˆ  j d	 ƒ Wd
 QXˆ  j d ƒ t ƒ  k st ‚ t | j d ƒ ƒ } t
 | d <t
 | d <t | d <| | d <| | f } t  j d d | g ƒ |  j j ƒ  ‰  | j ‡  f d †  d t ƒ| j | t j ƒ | j d ƒ | j ˆ  j ƒ  ˆ  j d	 ƒ Wd
 QXˆ  j d ƒ | k st ‚ |  j j ƒ  t  j d d g  ƒ d
 S(   s   Test runconfig workdir options.t   runt   configurationss	   script.pyt   file_dirt   cw_dirc              s   ˆ  j  d  k	 S(   N(   R™   R&   (    (   RI   (    s?   lib/python2.7/site-packages/spyder/app/tests/test_mainwindow.pyR<   þ  R=   R>   iô  s$   import os; current_dir = os.getcwd()Nt   current_dirt   test_dirt	   fixed_dirt   dirc              s   ˆ  j  d  k	 S(   N(   R™   R&   (    (   RI   (    s?   lib/python2.7/site-packages/spyder/app/tests/test_mainwindow.pyR<     R=   (   R   Ro   RÌ   RÑ   Rà   R8   Rá   R„   R   t   getRv   Rh   Rœ   R   RC   RŸ   R*   R   t   Key_F5R    R@   RA   RB   RÏ   R   R‰   R_   R¾   R   (   R,   RH   RÄ   Rë   RJ   t   rct   config_entryt   temp_dir(    (   RI   s?   lib/python2.7/site-packages/spyder/app/tests/test_mainwindow.pyt   test_runconfig_workdirè  s@    





s   It's failing therec   	         s1  t  j t d ƒ } |  j j | ƒ |  j j ƒ  } t ƒ  j ƒ  } t | d <| d <| | f } t	 j
 d d | g ƒ | j | t j ƒ | j d ƒ |  j j ƒ  ‰  ˆ  j } | j ‡  f d †  d t ƒ|  j j ƒ  } t |  j j ƒ  ƒ d	 k sø t ‚ |  j j d
 | g k st ‚ |  j j j d ƒ d k s7t ‚ | j d ƒ | j j j ƒ  d k sbt ‚ | j ƒ  } d | k r“d | k pd | k s™t ‚ | j ˆ  j ƒ  ˆ  j  d ƒ Wd QX| j | t j ƒ | j d ƒ ˆ  j! d ƒ sõt ‚ d | j ƒ  k st ‚ |  j j" ƒ  t	 j
 d d g  ƒ d S(   s(   Test running code in dedicated consoles.s	   script.pyt   currentt   systermRî   Rï   iô  c              s   ˆ  j  d  k	 S(   N(   R™   R&   (    (   RI   (    s?   lib/python2.7/site-packages/spyder/app/tests/test_mainwindow.pyR<   7  R=   R>   i   R=   i   s   script.py/Ai   Rµ   t   Pythont   IPythons   zz = -1Nt   zz(#   RÌ   RÑ   Rà   R8   Rá   R„   R   Rö   Rv   R   Ro   R*   R   R÷   R    Rœ   R   Rž   RC   RŸ   t   variableexplorerR¹   t   get_clientsR‰   t	   filenamest	   tabwidgetR^   R9   R:   R¡   R@   RA   RB   t
   is_definedR   (	   R,   RH   Rë   RJ   Rø   Rù   R¢   R;   R   (    (   RI   s?   lib/python2.7/site-packages/spyder/app/tests/test_mainwindow.pyt   test_dedicated_consoles   s8    	!!+c            s¶  t  ƒ  \ } } |  j j | j d d d ƒ |  j j ƒ  ‰  | j ‡  f d †  d t ƒ| j ˆ  j	 ƒ  ˆ  j
 d ƒ Wd QX|  j j t ƒ |  j j ƒ  } | j d ƒ | j j j ƒ  d k sÆ t ‚ t  d t ƒ \ } } |  j j | j d d d ƒ |  j j ƒ  ‰  | j ‡  f d †  d t ƒ| j ˆ  j	 ƒ  ˆ  j
 d ƒ Wd QX|  j j t ƒ |  j j ƒ  } | j d ƒ | j j j ƒ  d	 k s’t ‚ | j d
 t ƒ | j d
 t ƒ d S(   sE   Test that only Spyder kernels are connected to the Variable Explorer.c              s   ˆ  j  d  k	 S(   N(   R™   R&   (    (   RI   (    s?   lib/python2.7/site-packages/spyder/app/tests/test_mainwindow.pyR<   ^  R=   R>   s   a = 10Niô  i    RW   c              s   ˆ  j  d  k	 S(   N(   R™   R&   (    (   RI   (    s?   lib/python2.7/site-packages/spyder/app/tests/test_mainwindow.pyR<   m  R=   i   t   now(   R[   Rœ   t   _create_client_for_kernelt   connection_fileR&   R   RC   RŸ   R@   RA   RB   R  t   visibility_changedRh   R„   R    R8   R9   R:   R‰   RU   (   R,   RH   RY   RZ   R;   t   spykmt   spykc(    (   RI   s?   lib/python2.7/site-packages/spyder/app/tests/test_mainwindow.pyt"   test_connection_to_external_kernelT  s0    

s!   It times out sometimes on Windowsc            s  |  j  j ƒ  ‰ | j ‡ f d †  d t ƒ| j ˆ j ƒ  ˆ j d ƒ Wd QX|  j j t	 ƒ |  j j
 ƒ  ‰  | j ‡  f d †  d t ƒˆ  j j ƒ  ˆ  j j ƒ  | j t j ƒ  d ƒ | j t j ƒ  t j ƒ | j d ƒ ˆ j d ƒ d	 k sý t ‚ d S(
   sC   Test that variable types can't be changed in the Variable Explorer.c              s   ˆ  j  d  k	 S(   N(   R™   R&   (    (   RI   (    s?   lib/python2.7/site-packages/spyder/app/tests/test_mainwindow.pyR<   ƒ  R=   R>   s   a = 10Nc              s   ˆ  j  j j ƒ  d k S(   Ni    (   R8   R9   R:   (    (   R;   (    s?   lib/python2.7/site-packages/spyder/app/tests/test_mainwindow.pyR<   Š  R=   s   's'iè  t   ai
   (   Rœ   R   RC   RŸ   R@   RA   RB   R  R
  Rh   R„   RD   R8   RE   t	   edit_itemR±   R   t   focusWidgetR*   R   R+   R    RÏ   R‰   (   R,   RH   (    (   R;   RI   s?   lib/python2.7/site-packages/spyder/app/tests/test_mainwindow.pyt   test_change_types_in_varexp|  s    t   test_directoryu   non_ascii_Ã±_Ã­_Ã§u   test_dirs   It fails on macOSc            sê   |  j  } |  j j } |  j j ƒ  ‰  | j ‡  f d †  d t ƒt | j | ƒ ƒ } | j	 ˆ  j
 ƒ  ˆ  j d j | ƒ ƒ Wd QX| j d ƒ t j | j d ƒ t j | ƒ k s¼ t ‚ t j | j ƒ  ƒ t j | ƒ k sæ t ‚ d S(   su   
    Test synchronization with working directory and File Explorer when
    changing cwd in the IPython console.
    c              s   ˆ  j  d  k	 S(   N(   R™   R&   (    (   RI   (    s?   lib/python2.7/site-packages/spyder/app/tests/test_mainwindow.pyR<   ¥  R=   R>   u   %cd {}Niè  iÿÿÿÿ(   t   workingdirectoryt   explorert
   treewidgetRœ   R   RC   RŸ   R   R¾   R@   RA   RB   RÎ   R    RÌ   t   normpatht   historyR‰   t   get_current_folder(   R,   RH   RÄ   R  t   wdirR  Rú   (    (   RI   s?   lib/python2.7/site-packages/spyder/app/tests/test_mainwindow.pyt   test_change_cwd_ipython_console—  s    		+c            sÂ   |  j  } |  j } |  j j ƒ  ‰  | j ‡  f d †  d t ƒt | j | ƒ ƒ } | j | ƒ | j	 d ƒ t
 j | j d ƒ t
 j | ƒ k s— t ‚ t
 j | ƒ t
 j ˆ  j ƒ k s¾ t ‚ d S(   s}   
    Test synchronization with working directory and IPython console when
    changing directories in the File Explorer.
    c              s   ˆ  j  d  k	 S(   N(   R™   R&   (    (   RI   (    s?   lib/python2.7/site-packages/spyder/app/tests/test_mainwindow.pyR<   Ä  R=   R>   iè  iÿÿÿÿN(   R  R  Rœ   R   RC   RŸ   R   R¾   t   chdirR    RÌ   R  R  R‰   t   _cwd(   R,   RH   RÄ   R  R  R  Rú   (    (   RI   s?   lib/python2.7/site-packages/spyder/app/tests/test_mainwindow.pyt   test_change_cwd_explorer¶  s    			+t   Cythons6   Hard to test on Windows and macOS and Cython is neededc            s*  |  j  j ƒ  } |  j  j t j t d ƒ ƒ | j | t j ƒ |  j	 j ƒ  ‰  | j
 ‡  f d †  d t ƒ|  j j ƒ  } | j d ƒ d k s“ t ‚ t | | | ˆ  ƒ |  j  j ƒ  |  j  j t j t d ƒ ƒ | j | t j ƒ | j
 ‡  f d †  d t ƒ| j d ƒ d k st ‚ |  j  j ƒ  d	 S(
   s6   Test all the different ways we have to run Cython codes   pyx_script.pyxc              s   ˆ  j  j j ƒ  d k S(   Ni   (   R8   R9   R:   (    (   R;   (    s?   lib/python2.7/site-packages/spyder/app/tests/test_mainwindow.pyR<   ê  R=   R>   R  i _7 s   pyx_lib_import.pyc              s   ˆ  j  j j ƒ  d k S(   Ni   (   R8   R9   R:   (    (   R;   (    s?   lib/python2.7/site-packages/spyder/app/tests/test_mainwindow.pyR<   ý  R=   t   bN(   R8   R„   Rá   RÌ   RÑ   Rà   R*   R   R÷   R  RC   t   COMPILE_AND_EVAL_TIMEOUTRœ   R   RÏ   R‰   RK   R   (   R,   RH   RJ   RI   (    (   R;   s?   lib/python2.7/site-packages/spyder/app/tests/test_mainwindow.pyt   test_run_cython_codeÔ  s     	s   It fails on Windows.c   
      C   sU  |  j  } |  j j ƒ  } t | j d ƒ ƒ } t j t d ƒ } t j	 | t j | d ƒ ƒ | j
 | j ƒ  | j | ƒ Wd QX| j j d ƒ } | j j | ƒ | j | j t j ƒ d | j ƒ  k sÑ t ‚ | j j t j | d ƒ ƒ d | j ƒ  k st ‚ | j ƒ  j ƒ  } t j d k r/d }	 n d }	 | |	 k sGt ‚ | j ƒ  d S(   s7   Test that notebooks are open from the Project explorer.t   tests   notebook.ipynbNs   untitled0.pys   5.4.0sH   #!/usr/bin/env python
# coding: utf-8

# In[1]:


1 + 1


# In[ ]:





s%   
# coding: utf-8

# In[1]:


1 + 1


(   R½   R8   R¸   R   R¾   RÌ   RÑ   Rà   t   shutilt   copyR@   t   sig_project_loadedt   _create_projectR  t	   get_indext   setCurrentIndexR*   R   R+   t   get_current_filenameR‰   t   convert_notebookRÓ   R¡   t	   nbconvertt   __version__RÃ   (
   R,   RH   RÄ   R½   Rº   t   project_dirt   nbt   idxt	   file_textt   expected_text(    (    s?   lib/python2.7/site-packages/spyder/app/tests/test_mainwindow.pyt)   test_open_notebooks_from_project_explorer  s&    		c            s*  |  j  j ƒ  ‰  ˆ  j } | j ‡  f d †  d t ƒ|  j j ƒ  t j t	 d ƒ } |  j j
 | ƒ |  j d } |  j j | ƒ } | j | t j ƒ | j d ƒ |  j j ƒ  } | j d d ƒ | j d ƒ ˆ  j j d	 ƒ | j d ƒ d
 j | ƒ | j ƒ  k st ‚ |  j j ƒ  |  j j ƒ  d S(   s9   Test that new breakpoints are set in the IPython console.c              s   ˆ  j  d  k	 S(   N(   R™   R&   (    (   RI   (    s?   lib/python2.7/site-packages/spyder/app/tests/test_mainwindow.pyR<   ?  R=   R>   s	   script.pyi    iè  RÙ   i   iô  R  s#   1   breakpoint   keep yes   at {}:6N(   Rœ   R   Rž   RC   RŸ   R8   Rß   RÌ   RÑ   Rà   Rá   RÜ   RÝ   RÞ   Rã   R   Rä   R    R„   Râ   Ræ   Rç   RÎ   R¡   R‰   R   (   R,   RH   R¢   Rë   Ré   Rê   RJ   (    (   RI   s?   lib/python2.7/site-packages/spyder/app/tests/test_mainwindow.pyt   test_set_new_breakpoints7  s$    	!c            s´  | j  d ƒ j d ƒ } t | ƒ } t j t j t d ƒ | ƒ |  j j ƒ  ‰ | j	 ‡ f d †  d t
 ƒ|  j j | ƒ |  j j ƒ  } | j ƒ  | j | t j d t j ƒ|  j j ƒ  ‰  | j | t j ƒ | j	 ‡  f d †  d t ƒˆ j d ƒ d	 k s	t ‚ ˆ j d
 ƒ d d d g k s-t ‚ t ˆ j d ƒ t j d d d g ƒ ƒ t | ˆ | ˆ  ƒ x: t | j ƒ  ƒ D]& } | j | t j ƒ | j d ƒ q{W| j	 ‡  f d †  d t ƒˆ j d ƒ d	 k sÜt ‚ ˆ j d
 ƒ d d d g k s t ‚ t ˆ j d ƒ t j d d d g ƒ ƒ t | ˆ | ˆ  ƒ x= t d ƒ D]/ } | j | t j  d t j! ƒ| j d ƒ qHW| j	 ‡  f d †  d t ƒˆ j d ƒ d	 k s²t ‚ ˆ j d
 ƒ d d d g k sÖt ‚ t ˆ j d ƒ t j d d d g ƒ ƒ t | ˆ | ˆ  ƒ | j | t j  d t j ƒ| j	 ‡  f d †  d t ƒˆ j d ƒ d	 k sdt ‚ | j | t j  d t j ƒˆ  j j" j# ƒ  d k sžt ‚ t | ˆ | ˆ  ƒ | j | t j  d t j! ƒ| j | t j  d t j! ƒ| j	 ‡  f d †  d t ƒ| j$ ˆ j% ƒ  ˆ j& d ƒ Wd QX| j	 ‡  f d †  d t ƒ| j | t j  d t j' ƒ| j	 ‡  f d †  d t ƒˆ j d
 ƒ d d d g k s£t ‚ |  j j( ƒ  d S(   s/   Test all the different ways we have to run codeu,   runtest's folder Ã¨Ã¡Ã¯Ã¼ Ã˜Î±Ã´Ã¥ å­—åˆ†è¯¯u-   runtest's file Ã¨Ã¡Ã¯Ã¼ Ã˜Î±Ã´Ã¥ å­—åˆ†è¯¯.pys	   script.pyc              s   ˆ  j  d  k	 S(   N(   R™   R&   (    (   RI   (    s?   lib/python2.7/site-packages/spyder/app/tests/test_mainwindow.pyR<   i  R=   R>   R?   c              s   ˆ  j  j j ƒ  d k S(   Ni   (   R8   R9   R:   (    (   R;   (    s?   lib/python2.7/site-packages/spyder/app/tests/test_mainwindow.pyR<   z  R=   R  i
   t   lii   i   i   t   arrid   c              s   ˆ  j  j j ƒ  d k S(   Ni   (   R8   R9   R:   (    (   R;   (    s?   lib/python2.7/site-packages/spyder/app/tests/test_mainwindow.pyR<   Š  R=   c              s   ˆ  j  j j ƒ  d k S(   Ni   (   R8   R9   R:   (    (   R;   (    s?   lib/python2.7/site-packages/spyder/app/tests/test_mainwindow.pyR<   š  R=   c              s   ˆ  j  j j ƒ  d k S(   Ni   (   R8   R9   R:   (    (   R;   (    s?   lib/python2.7/site-packages/spyder/app/tests/test_mainwindow.pyR<   ¨  R=   c              s   ˆ  j  j j ƒ  d k S(   Ni   (   R8   R9   R:   (    (   R;   (    s?   lib/python2.7/site-packages/spyder/app/tests/test_mainwindow.pyR<   º  R=   s	   %reset -fNc              s   ˆ  j  j j ƒ  d k S(   Ni    (   R8   R9   R:   (    (   R;   (    s?   lib/python2.7/site-packages/spyder/app/tests/test_mainwindow.pyR<   Á  R=   c              s   ˆ  j  j j ƒ  d k S(   Ni   (   R8   R9   R:   (    (   R;   (    s?   lib/python2.7/site-packages/spyder/app/tests/test_mainwindow.pyR<   Ç  R=   ()   R¾   RÑ   R   R#  t   copyfileRÌ   Rà   Rœ   R   RC   RŸ   R8   Rá   R„   RE   R*   R   RF   RG   R  R÷   RD   RÏ   R‰   R   R¨   t   arrayRK   R\   t
   blockCountt   Key_F9R    t
   Key_Returnt   ShiftModifierR9   R:   R@   RA   RB   t   AltModifierR   (   R,   RH   RÄ   R×   t   filepathRJ   t   _(    (   R;   RI   s?   lib/python2.7/site-packages/spyder/app/tests/test_mainwindow.pyt   test_run_code]  s`    
$($($($st   It times out sometimes on Windows, it's not meant to be run outside of a CI and it segfaults too frequently in PyQt5c            s^   t  j d ‡  f d †  ƒ ˆ  j j ƒ  ˆ  j j ƒ  ˆ  j j ƒ  } | j ƒ  d k sZ t ‚ d S(   ss   
    This tests that opening files in a new editor window
    is working as expected.

    Test for issue 4085
    iÐ  c              s   t  ˆ  d d t ƒS(   Ns	   script.pyR.   (   R2   Rà   (    (   R,   (    s?   lib/python2.7/site-packages/spyder/app/tests/test_mainwindow.pyR<   Ü  s   i   N(   R   t
   singleShotR8   t   create_new_windowRá   R¸   RÐ   R‰   (   R,   RH   Rº   (    (   R,   s?   lib/python2.7/site-packages/spyder/app/tests/test_mainwindow.pyt$   test_open_files_in_new_editor_windowÎ  s
    c            sŒ   |  j  j ƒ  ‰  | j ‡  f d †  d t ƒt j t d ƒ } |  j j | ƒ |  j j	 ƒ  } | j
 ƒ  } | j ƒ  j t ƒ | j d ƒ d S(   sA   Test closing spyder when there is a file with modifications open.c              s   ˆ  j  d  k	 S(   N(   R™   R&   (    (   RI   (    s?   lib/python2.7/site-packages/spyder/app/tests/test_mainwindow.pyR<   ñ  R=   R>   s	   script.pyi¸  N(   Rœ   R   RC   RŸ   RÌ   RÑ   Rà   R8   Rá   R¸   RÓ   t   documentt   setModifiedRh   R    (   R,   RH   Rë   Rº   R8   (    (   RI   s?   lib/python2.7/site-packages/spyder/app/tests/test_mainwindow.pyt   test_close_when_file_is_changedë  s    c         C   s}   |  j  j ƒ  j ƒ  |  j } |  j j | ƒ } | j | t j ƒ |  j  j	 sS t
 ‚ | j | t j ƒ |  j  j	 sy t
 ‚ d S(   s3   Test that the maximize button is working correctly.N(   R8   R„   RE   t   maximize_actiont   main_toolbarRÞ   Rã   R   Rä   t   ismaximizedR‰   (   R,   RH   t
   max_actiont
   max_button(    (    s?   lib/python2.7/site-packages/spyder/app/tests/test_mainwindow.pyt   test_maximize_minimize_pluginsþ  s    	s   5.9sA   It times out on Windows and segfaults in our CIs with PyQt >= 5.9c            sN  |  j  j ƒ  ‰ | j ‡ f d †  d t ƒ| j ˆ j ƒ  ˆ j d ƒ Wd QX|  j j ƒ  ‰  | j ‡  f d †  d t	 ƒˆ  j
 j ƒ  ˆ  j
 j ƒ  t ˆ  j
 j j j ƒ  ƒ d } ˆ  j
 j j | d } |  j  j ƒ  j ƒ  | j ˆ j ƒ  ˆ j d ƒ Wd QX| j ‡  f d	 †  d t	 ƒ| j } | j | t j ƒ | j d
 ƒ d S(   s  
    Test for a segfault when these steps are followed:

    1. Open an object present in the Variable Explorer (e.g. a list).
    2. Delete that object in its corresponding console while its
       editor is still opem.
    3. Closing that editor by pressing its *Ok* button.
    c              s   ˆ  j  d  k	 S(   N(   R™   R&   (    (   RI   (    s?   lib/python2.7/site-packages/spyder/app/tests/test_mainwindow.pyR<   !  R=   R>   s   myobj = [1, 2, 3]Nc              s   ˆ  j  j j ƒ  d k S(   Ni    (   R8   R9   R:   (    (   R;   (    s?   lib/python2.7/site-packages/spyder/app/tests/test_mainwindow.pyR<   '  R=   i    R8   s	   del myobjc              s   ˆ  j  j j ƒ  d k S(   Ni    (   R8   R9   R:   (    (   R;   (    s?   lib/python2.7/site-packages/spyder/app/tests/test_mainwindow.pyR<   1  R=   i¸  (   Rœ   R   RC   RŸ   R@   RA   RB   R  R„   RD   R8   RE   R  RÚ   t   delegatet   _editorst   keyst	   btn_closeRã   R   Rä   R    (   R,   RH   t   obj_editor_idt
   obj_editort	   ok_widget(    (   R;   RI   s?   lib/python2.7/site-packages/spyder/app/tests/test_mainwindow.pyt   test_issue_4066  s"    	c            sÊ   |  j  j ƒ  ‰ | j ‡ f d †  d t ƒ| j ˆ j ƒ  ˆ j d ƒ Wd QX|  j j t	 ƒ |  j j
 ƒ  ‰  | j ‡  f d †  d t ƒˆ  j j ƒ  ˆ  j j ƒ  |  j  j
 ƒ  j ƒ  | j d ƒ d S(   s!  
    Test for errors when editing inline values in the Variable Explorer
    and then moving to another plugin.

    Note: Errors for this test don't appear related to it but instead they
    are shown down the road. That's because they are generated by an
    async C++ RuntimeError.
    c              s   ˆ  j  d  k	 S(   N(   R™   R&   (    (   RI   (    s?   lib/python2.7/site-packages/spyder/app/tests/test_mainwindow.pyR<   I  R=   R>   s   a = 10Nc              s   ˆ  j  j j ƒ  d k S(   Ni    (   R8   R9   R:   (    (   R;   (    s?   lib/python2.7/site-packages/spyder/app/tests/test_mainwindow.pyR<   P  R=   i¸  (   Rœ   R   RC   RŸ   R@   RA   RB   R  R
  Rh   R„   RD   R8   RE   R  R    (   R,   RH   (    (   R;   RI   s?   lib/python2.7/site-packages/spyder/app/tests/test_mainwindow.pyt   test_varexp_edit_inline;  s    c            sg  |  j  j ƒ  } |  j j ƒ  ‰  ˆ  j } | j ‡  f d †  d t ƒ|  j j ƒ  t	 j
 t d ƒ } |  j j | ƒ |  j d } |  j j | ƒ } | j | t j ƒ | j d ƒ |  j j ƒ  } | j d d ƒ | j d ƒ | j | d	 ƒ | j | t j ƒ | j d ƒ | j j j ƒ  d
 k s+t ‚ | j | d ƒ | j | t j ƒ | j d ƒ | j j j ƒ  d k syt ‚ | j | d ƒ | j | t j ƒ | j d ƒ | j | d ƒ | j | t j ƒ | j d ƒ | j j j ƒ  d k s÷t ‚ | j | d ƒ | j | t j ƒ | j d ƒ ˆ  j ƒ  d | j ƒ  k sIt ‚ |  j j ƒ  |  j j ƒ  d S(   s<   Test that c and n Pdb commands update the Variable Explorer.c              s   ˆ  j  d  k	 S(   N(   R™   R&   (    (   RI   (    s?   lib/python2.7/site-packages/spyder/app/tests/test_mainwindow.pyR<   e  R=   R>   s	   script.pyi    iè  RÙ   i   iô  t   ci   t   ni   i   s   In [2]:N(   R  R„   Rœ   R   Rž   RC   RŸ   R8   Rß   RÌ   RÑ   Rà   Rá   RÜ   RÝ   RÞ   Rã   R   Rä   R    Râ   R±   R*   R+   R9   R:   R‰   Rå   R¡   R   (   R,   RH   R;   R¢   Rë   Ré   Rê   RJ   (    (   RI   s?   lib/python2.7/site-packages/spyder/app/tests/test_mainwindow.pyt   test_c_and_n_pdb_commands[  sH    	
c            s@  |  j  j ƒ  } |  j j ƒ  ‰  | j ‡  f d †  d t ƒ|  j j ƒ  t j	 t
 d ƒ } |  j j | ƒ |  j d } |  j j | ƒ } | j | t j ƒ | j d ƒ ˆ  j j d ƒ | j d ƒ |  j d } |  j j | ƒ } | j | t j ƒ | j d ƒ | j j j ƒ  d k s"t ‚ |  j j ƒ  |  j j ƒ  d	 S(
   s0   Test that we correctly stop a debugging session.c              s   ˆ  j  d  k	 S(   N(   R™   R&   (    (   RI   (    s?   lib/python2.7/site-packages/spyder/app/tests/test_mainwindow.pyR<   §  R=   R>   s	   script.pyi    iè  RV  i   i   N(   R  R„   Rœ   R   RC   RŸ   R8   Rß   RÌ   RÑ   Rà   Rá   RÜ   RÝ   RÞ   Rã   R   Rä   R    Ræ   Rç   R9   R:   R‰   R   (   R,   RH   R;   Rë   Ré   Rê   t   stop_debug_actiont   stop_debug_button(    (   RI   s?   lib/python2.7/site-packages/spyder/app/tests/test_mainwindow.pyt   test_stop_dbgž  s&    c            s*  |  j  j ƒ  ‰  | j ‡  f d †  d t ƒ|  j  j ƒ  } | j ƒ  | j ˆ  j ƒ  ˆ  j d ƒ Wd QX|  j	 d } |  j
 j | ƒ } | j | t j ƒ | j d ƒ |  j j t j ƒ  d t d t ƒ| j d ƒ | j | d	 ƒ | j | t j ƒ | j d ƒ t j ƒ  | j ƒ  k s&t ‚ d S(
   sS   
    Test that using the Working directory toolbar is working while debugging.
    c              s   ˆ  j  d  k	 S(   N(   R™   R&   (    (   RI   (    s?   lib/python2.7/site-packages/spyder/app/tests/test_mainwindow.pyR<   Ñ  R=   R>   s	   import osNi    iè  t   browsing_historyt   refresh_explorers   os.getcwd()(   Rœ   R   RC   RŸ   R„   RE   R@   RA   RB   RÜ   RÝ   RÞ   Rã   R   Rä   R    R  R  t   tempfilet
   gettempdirRv   Rh   R±   R*   R+   R¡   R‰   (   R,   RH   R¢   Ré   Rê   (    (   RI   s?   lib/python2.7/site-packages/spyder/app/tests/test_mainwindow.pyt   test_change_cwd_dbgÈ  s$    
s   It times out sometimesc            sý   |  j  j ƒ  } |  j j ƒ  ‰  | j ‡  f d †  d t ƒ|  j j ƒ  } | j ƒ  | j ˆ  j ƒ  ˆ  j	 d ƒ Wd QX|  j
 d } |  j j | ƒ } | j | t j ƒ | j d ƒ | j d d ƒ | j d ƒ ˆ  j j ƒ  j d	 ƒ d
 k sù t ‚ d S(   s-   Test that %varexp is working while debugging.c              s   ˆ  j  d  k	 S(   N(   R™   R&   (    (   RI   (    s?   lib/python2.7/site-packages/spyder/app/tests/test_mainwindow.pyR<   ù  R=   R>   s   li = [1, 2, 3]Ni    iè  R4  t   plots   img srci   (   R  R„   Rœ   R   RC   RŸ   RE   R@   RA   RB   RÜ   RÝ   RÞ   Rã   R   Rä   R    R`  Rž   t   toHtmlR]   R‰   (   R,   RH   R;   R¢   Ré   Rê   (    (   RI   s?   lib/python2.7/site-packages/spyder/app/tests/test_mainwindow.pyt   test_varexp_magic_dbgð  s    
c   
   
      sW  t  j d d ƒ t k s t ‚ t t  j d d ƒ ƒ } t t  j d d ƒ ƒ } t t  j d d ƒ ƒ } |  j j ƒ  ‰  |  j j ƒ  } | j ‡  f d †  d t	 ƒ|  j j
 ƒ  } | j ƒ  | j ˆ  j ƒ  ˆ  j d | | | f ƒ Wd	 QXˆ  j j ƒ  } t j d
 | ƒ j d ƒ } ˆ  j | ƒ }	 t |	 t ƒ s:t ‚ |	 j d ƒ t d d d ƒ d	 k set ‚ t  j d d t ƒ d	 ˆ  _ | j ƒ  | j ‡  f d †  d t	 ƒ| j ˆ  j ƒ  ˆ  j d | | | f ƒ Wd	 QXˆ  j j ƒ  } t j d
 | ƒ j d ƒ } ˆ  j | ƒ }	 t |	 t ƒ s(t ‚ |	 j d ƒ t d d d ƒ d	 k sSt ‚ d	 S(   sÇ   
    Test that the option to set bbox_inches to 'tight' or 'None' is
    working when plotting inline in the IPython console. By default, figures
    are plotted inline with bbox_inches='tight'.
    Rf   s   pylab/inline/bbox_inchess   pylab/inline/resolutions   pylab/inline/widths   pylab/inline/heightc              s   ˆ  j  d  k	 S(   N(   R™   R&   (    (   RI   (    s?   lib/python2.7/site-packages/spyder/app/tests/test_mainwindow.pyR<   $  R=   R>   s  import matplotlib.pyplot as plt
fig, ax = plt.subplots()
fig.set_size_inches(%f, %f)
ax.set_position([0.25, 0.25, 0.5, 0.5])
ax.set_xticks(range(10))
ax.xaxis.set_ticklabels([])
ax.set_yticks(range(10))
ax.yaxis.set_ticklabels([])
ax.tick_params(axis='both', length=0)
for loc in ax.spines:
    ax.spines[loc].set_color('#000000')
    ax.spines[loc].set_linewidth(2)
ax.axis([0, 9, 0, 9])
ax.plot(range(10), color='#000000', lw=2)
fig.savefig('savefig_bbox_inches_tight.png',
            bbox_inches='tight',
            dpi=%f)Ns   <img src="(.+?)" /></p>i   s   inline_bbox_inches_tight.pngs   savefig_bbox_inches_tight.pnggš™™™™™¹?c              s   ˆ  j  d  k	 S(   N(   R™   R&   (    (   RI   (    s?   lib/python2.7/site-packages/spyder/app/tests/test_mainwindow.pyR<   U  R=   s  import matplotlib.pyplot as plt
fig, ax = plt.subplots()
fig.set_size_inches(%f, %f)
ax.set_position([0.25, 0.25, 0.5, 0.5])
ax.set_xticks(range(10))
ax.xaxis.set_ticklabels([])
ax.set_yticks(range(10))
ax.yaxis.set_ticklabels([])
ax.tick_params(axis='both', length=0)
for loc in ax.spines:
    ax.spines[loc].set_color('#000000')
    ax.spines[loc].set_linewidth(2)
ax.axis([0, 9, 0, 9])
ax.plot(range(10), color='#000000', lw=2)
fig.savefig('savefig_bbox_inches_None.png',
            bbox_inches=None,
            dpi=%f)s   inline_bbox_inches_None.pngs   savefig_bbox_inches_None.png(   R   Rö   Rh   R‰   t   floatRœ   R   t   get_current_clientRC   RŸ   R„   RE   R@   RA   RB   Rž   Ra  t   ret   searcht   groupt
   _get_imageR%   R   t   saveR   R&   Ro   Rv   R™   t   restart_kernel(
   R,   RH   t   fig_dpit	   fig_widtht
   fig_heightRP   R¢   t   htmlt   img_namet   qimg(    (   RI   s?   lib/python2.7/site-packages/spyder/app/tests/test_mainwindow.pyt(   test_tight_layout_option_for_inline_plot  sJ    

		
	s;   It's not meant to be run outside of a CI and fails in macOSc         C   sœ  t  j t d d ƒ } t  j | d ƒ } t  j | ƒ sF t j | ƒ n  t  j | ƒ sq t | d ƒ } | j ƒ  n  t	 r• t  j t d d d d ƒ } n t  j t d d d ƒ } t  j t d d d d ƒ } t  j | d	 ƒ } t  j | ƒ sù t j | ƒ n  t  j | ƒ s$t | d ƒ } | j ƒ  n  t  j | d ƒ }	 t  j | ƒ sUt j | ƒ n  t  j |	 ƒ s€t |	 d ƒ }
 |
 j ƒ  n  |  j
 j | ƒ |  j
 j |	 ƒ |  j ƒ  t j d
 k rþ|  j j j ƒ  j ƒ  j d d ƒ j ƒ  } | j d d ƒ j ƒ  } n |  j j j ƒ  j ƒ  } | | k s(t ‚ |  j } |  j | j ƒ  d | j ƒ  ƒ |  j ƒ  t	 r˜|  j ƒ  |  j j j ƒ  j ƒ  } d | k s˜t ‚ n  d S(   sA   Test the use of shorten paths when necessary in the fileswitcher.t
   temp_dir_at   temp_bs   c.pys   w+t   temp_ct   temp_dt   temp_et
   temp_dir_fs   a.pyR}   s   \t   /i   s   ...N(   RÌ   RÑ   t   TEMP_DIRECTORYt   isdirRr   t   makedirst   isfilet   openRm   R   R8   Rá   t   open_fileswitchert   namet   fileswitcherRÚ   t   currentItemR   t   replacet   lowerR‰   t   window_sizet   resizet   widtht   height(   R,   RH   t   dir_bt
   filename_bt   file_ct   dir_dt   dir_et
   filename_et   file_et
   filename_dt   file_dt	   item_textt   size(    (    s?   lib/python2.7/site-packages/spyder/app/tests/test_mainwindow.pyt   test_fileswitcher}  sL    
*	 

c            sù   |  j  j ƒ  ‰  | j ‡  f d †  d t ƒt |  d ƒ } t j t d ƒ } |  j j	 | ƒ |  j j
 ƒ  } | j | t j ƒ | j d ƒ | j
 ƒ  ‰ | j ‡ f d †  d t ƒˆ j } | d sÌ t ‚ t | d ƒ d k sè t ‚ |  j j ƒ  d	 S(
   s9   This tests that the Pylint plugin is working as expected.c              s   ˆ  j  d  k	 S(   N(   R™   R&   (    (   RI   (    s?   lib/python2.7/site-packages/spyder/app/tests/test_mainwindow.pyR<   º  R=   R>   s   Static code analysiss   script_pylint.pyi¸  c              s   ˆ  j  d  k	 S(   N(   t   resultsR&   (    (   R  (    s?   lib/python2.7/site-packages/spyder/app/tests/test_mainwindow.pyR<   Ê  R=   s   C:i   N(   Rœ   R   RC   RŸ   R7   RÌ   RÑ   Rà   R8   Rá   R„   R*   R   t   Key_F8R    R”  R‰   R¹   R   (   R,   RH   t   pylintRë   RJ   t   result_content(    (   RI   R  s?   lib/python2.7/site-packages/spyder/app/tests/test_mainwindow.pyt   test_run_static_code_analysis´  s     	c         C   sÕ   t  d t ƒ } | ƒ  } t | _ t ƒ  } | ƒ  } d } |  j | | ƒ t j | ƒ | j j d k sn t ‚ | j j	 t
 ƒ y t d d d ƒWn t k
 r¥ n, Xy t t
 d d ƒWn t k
 rÐ ‚  n Xd S(   s<   Test that the troubleshooting menu item calls the valid URL.t   specs&   spyder.app.mainwindow.QDesktopServicesi   s   https://www.github.comR>   N(   R   R   t	   __class__R    t   setattrt   trouble_guidet   openUrlt
   call_countR‰   t   called_once_withR   R"   t	   ExceptionR#   (   t   monkeypatcht   MockMainWindowt   mockMainWindow_instancet   MockQDesktopServicest   mockQDesktopServices_instancet   attr_to_patch(    (    s?   lib/python2.7/site-packages/spyder/app/tests/test_mainwindow.pyt&   test_troubleshooting_menu_item_and_urlÔ  s$    				c         C   s›   t  ƒ  } t j | j j _ d | j j _ | ƒ  } |  j t ƒ d } t | |  ƒ } d | _
 t | _ | j d | ƒ s t ‚ | j j d k s— t ‚ d S(   sE   Test for #5813 ; event filter handles None indicies when moving tabs.i    i   N(   R   R	   t	   MouseMovet   return_valuet   typet   posR(   R   R   R&   t
   from_indexRh   t   movingt   eventFilterR‰   Rž  (   R,   t	   MockEventt   mockEvent_instancet   test_tabbart   test_tabfilter(    (    s?   lib/python2.7/site-packages/spyder/app/tests/test_mainwindow.pyt   test_tabfilter_typeerror_fullð  s    				s'   It's not meant to be run outside of CIsc            sW  d } |  j  j ƒ  ‰  | j ‡  f d †  d t ƒd } x3 |  j j ƒ  D]" } | j ƒ  | k rG | } PqG qG Wy |  j j	 ƒ  Wn t
 k
 r‘ n X| j d ƒ t | |  ƒ \ } } | d k rÌ | d k sÒ t ‚ t |  j ƒ  t ƒ sî t ‚ | j ƒ  st ‚ |  j j ƒ  | j d ƒ t | |  ƒ \ } } d | | f k sHt ‚ | | j ƒ  k s`t ‚ t |  j ƒ  t ƒ s{t ‚ | j ƒ  st ‚ | j | j ƒ  d | j ƒ  ƒ | j d ƒ t | |  ƒ \ } } d | | f k sèt ‚ | | j ƒ  k s t ‚ t |  j ƒ  t ƒ st ‚ | j ƒ  s.t ‚ |  j j ƒ  | j d ƒ t | |  ƒ \ } } d | | f k sut ‚ | | j ƒ  k st ‚ t |  j ƒ  t ƒ s¨t ‚ | j ƒ  sºt ‚ | j d ƒ |  j j ƒ  t | |  ƒ \ } } | j d ƒ d | | f k st ‚ | | j ƒ  k s&t ‚ t |  j ƒ  t ƒ sAt ‚ | j ƒ  sSt ‚ d S(   sE   Test fix for #6317 : 'Show tutorial' opens the help plugin if closed.t   Helpc              s   ˆ  j  d  k	 S(   N(   R™   R&   (    (   RI   (    s?   lib/python2.7/site-packages/spyder/app/tests/test_mainwindow.pyR<     R=   R>   iô  i   N(   Rœ   R   RC   RŸ   R&   t   plugins_menut   actionsR   R©   t   plugin_closedR   R    Re   R‰   R%   R  R   t	   isCheckedt   show_tutorialt   currentIndexR(  R]   (   R,   RH   t   HELP_STRt   help_pane_menuitemt   actiont   help_tabbart
   help_index(    (   RI   s?   lib/python2.7/site-packages/spyder/app/tests/test_mainwindow.pyt'   test_help_opens_when_show_tutorial_full  s`    c         C   s3  d } d } d } t  d } t d t ƒ } | ƒ  } t | _ | | j _ t ƒ  } | ƒ  } d }	 |  j |	 | ƒ t | d | ƒ }
 t j | d | d	 d d
 t
 ƒ| j j d k s¼ t ‚ | j j |
 ƒ t | d | d | ƒ }
 t j | d | d	 | d
 t
 ƒ| j j d k st ‚ | j j |
 ƒ d S(   s:   Test that report_issue sends the data, and to correct url.s*   This is an example error report body text.s   Uncreative issue title heres   Auto-generated text.s   /issues/newR™  s&   spyder.app.mainwindow.QDesktopServicess   ?body=t   bodyRÅ   t   open_webpagei   s   &title=i   N(   R   R   R   Rš  t   render_issueR©  R›  R
   t   report_issueR&   Rh   R  Rž  R‰   t   called_with(   R¡  RÁ  RÅ   t   body_autogeneratedt   target_url_baseR¢  R£  R¤  R¥  R¦  t
   target_url(    (    s?   lib/python2.7/site-packages/spyder/app/tests/test_mainwindow.pyt   test_report_issue_urlG  s.    
				c          C   sÙ   d }  d } t  d t ƒ } | ƒ  } t | _ t j | ƒ } t | ƒ t k sT t ‚ t | ƒ d k sl t ‚ t j | |  | ƒ } t | ƒ t k s™ t ‚ t | ƒ d k s± t ‚ |  | k sÃ t ‚ | | k sÕ t ‚ d S(   s=   Test that render issue works without errors and returns text.s   This is a test descriptions   An error occured. Oh no!R™  id   N(   R   R   Rš  RÃ  Rª  R_   R‰   R¹   (   t   test_descriptiont   test_tracebackR¢  R£  t   test_issue_1t   test_issue_2(    (    s?   lib/python2.7/site-packages/spyder/app/tests/test_mainwindow.pyt   test_render_issueh  s    			t   __main__(   Rk   R‘   R’   (‘   t   __doc__Rr   t   os.pathR¼   RÌ   R#  R]  t   unittest.mockR    R   t   ImportErrort   mockRe  t   sysR   t   jupyter_client.managerR   R¤   R¨   t   numpy.testingR   t   pytestt   qtpyR   R   t   qtpy.QtCoreR   R   R	   R
   t   qtpy.QtTestR   t
   qtpy.QtGuiR   t   qtpy.QtWidgetsR   R   R   R   t   qtpy.QtWebEngineWidgetsR   t   matplotlib.testing.compareR   R+  RÈ   R   R   t
   spyder.appR   t   spyder.app.mainwindowR   t   spyder.config.baseR   R   t   spyder.config.mainR   t   spyder.pluginsR   t   spyder.plugins.helpR   t   spyder.plugins.runconfigR   t   spyder.plugins.tests.test_helpR   t   spyder.py3compatR   R   t   spyder.utils.ipython.kernelspecR    t   spyder.utils.programsR!   t   urllib.requestR"   t   urllib.errorR#   t   urllib2t   realpathRÑ   t   getcwdRÍ   t   __file__Rà   RŸ   R   RD   R^  Ry  R&   R2   R7   RK   Rv   R[   Re   t   fixtureR,   t   markt   slowRg   t   skipifR  R   t   parametrizeRh   R–   R,  R£   R´   R»   RÆ   Rj   Rs   Rö   RØ   Rì   t   platformRû   R  R  R  R  R  R!  R2  R3  R?  RB  RE  RK  RS  RT  RW  RZ  R_  Rb  Rq  R“  R˜  R§  R³  RÀ  RÉ  RÎ  t   __name__Rk   (    (    (    s?   lib/python2.7/site-packages/spyder/app/tests/test_mainwindow.pyt   <module>   s:  ""*				0			1	@	'3	,		*$	67	35	-1	'	0	3	3	%/	0.	0$	0o	9		'&	0	0A	0(	0&	6	'j	34		$B	!	