ó
‹²,]c           @   s­   d  Z  d d l j Z d d l Z d d l Z y d d l m Z Wn! e k
 rd d d l	 m Z n Xd d l
 m Z d d l m Z e j d „  ƒ Z d „  Z d „  Z d S(	   s   Tests for the Editor plugin.iÿÿÿÿN(   t   Mock(   t   QWidget(   t   qapplicationc         c   s˜   t  ƒ  | j d t ƒ  ƒ d d l m } | j d t ƒ  ƒ d t f d „  ƒ  Y} | | ƒ  ƒ } |  j | ƒ | j ƒ  | |  f V| j j	 j
 ƒ  d S(   s   Set up the Editor plugin.s   spyder.dependenciesiÿÿÿÿ(   t   Editors!   spyder.plugins.editor.add_actionst   MainMockc           B   s   e  Z d  „  Z d „  Z RS(   c         S   sC   | j  d ƒ r g  S| d k r8 t ƒ  } d  | j _ | St ƒ  Sd  S(   Nt   actionst   projects(   t   endswithR    t   Nonet   get_active_projectt   return_value(   t   selft   attrR   (    (    s?   lib/python2.7/site-packages/spyder/plugins/tests/test_editor.pyt   __getattr__!   s    	c          W   s   g  S(   N(    (   t   args(    (    s?   lib/python2.7/site-packages/spyder/plugins/tests/test_editor.pyt   get_spyder_pythonpath+   s    (   t   __name__t
   __module__R   R   (    (    (    s?   lib/python2.7/site-packages/spyder/plugins/tests/test_editor.pyR       s   	
N(   R   t   setattrR    t   spyder.plugins.editorR   R   t	   addWidgett   showt   introspectort   plugin_managert   close(   t   qtbott   monkeypatchR   R   t   editor(    (    s?   lib/python2.7/site-packages/spyder/plugins/tests/test_editor.pyt   setup_editor   s    
c         C   sÙ   |  \ } } | j  j | d ƒ | j  j | d ƒ d d d d g | j _ | j d d ƒ | j j d	 k sr t ‚ | j j d
 d d d ƒ s“ t ‚ | j j d
 d d d ƒ s´ t ‚ | j j d
 d d d ƒ sÕ t ‚ d S(   sù   Test editor.renamed_tree().

    This tests that the file renaming functions are called correctly,
    but does not test that all the renaming happens in File Explorer,
    Project Explorer, and Editor widget as those aren't part of the plugin.
    t   get_filenamest   renameds   /test/directory/file1.pys   /test/directory/file2.txts   /home/spyder/testing/file3.pys   /test/directory/file4.rsts   /test/directorys	   /test/diri   t   sourcet   dests   test/dir/file1.pys   test/dir/file2.txts   test/dir/file4.rstN(	   t   patcht   objectR   R
   t   renamed_treeR   t
   call_countt   AssertionErrort   called_with(   R   t   mockerR   R   (    (    s?   lib/python2.7/site-packages/spyder/plugins/tests/test_editor.pyt   test_renamed_tree7   s    c         C   s˜   |  \ } } | j  } t j | t j t j | ƒ d ƒ ƒ | j ƒ  | j ƒ  } | j d d ƒ } | so t	 ‚ t j t j t j | ƒ d ƒ | ƒ d S(   sF   
    Test that new files can be opened when no template is found.
    s   template.py.oldt   soft   eofN(
   t   TEMPLATE_PATHt   shutilt   movet   ospt   joint   dirnamet   newt   get_focus_widgett   get_textR%   (   R   R   R   t   templatet   code_editort   contents(    (    s?   lib/python2.7/site-packages/spyder/plugins/tests/test_editor.pyt   test_no_templateP   s    	%
(   t   __doc__t   os.patht   pathR.   R,   t   pytestt   unittest.mockR    t   ImportErrort   mockt   qtpy.QtWidgetsR   t   spyder.utils.qthelpersR   t   fixtureR   R(   R7   (    (    (    s?   lib/python2.7/site-packages/spyder/plugins/tests/test_editor.pyt   <module>   s   	