ó
ē,]c           @   sē   d  Z  y d d l m Z Wn! e k
 r= d d l m Z n Xd d l m Z d d l Z d d l m	 Z	 d d l
 m Z e j d    Z d   Z e d	 k rŪ e j   n  d S(
   s   
Tests for the history log
iĸĸĸĸ(   t   Mock(   t   QWidgetN(   t
   HistoryLog(   t   to_text_stringc         C   s9   d t  f d     Y} t d |    } |  j |  | S(   s   History plugin fixturet   MainMockc           B   s   e  Z d    Z RS(   c         S   s   t    S(   N(   R    (   t   selft   attr(    (    s@   lib/python2.7/site-packages/spyder/plugins/tests/test_history.pyt   __getattr__$   s    (   t   __name__t
   __module__R   (    (    (    s@   lib/python2.7/site-packages/spyder/plugins/tests/test_history.pyR   #   s   t   parent(   R   R   t	   addWidget(   t   qtbotR   t   history(    (    s@   lib/python2.7/site-packages/spyder/plugins/tests/test_history.pyt   history_plugin   s    c         C   s°   |  j  d  } d } x+ t | d  D] } | d j |  } q& W| j d  } | j |  |  j t |   t | j    | k s t	  d | j   d k sŽ t	  d S(	   s.   Test that history is truncated at max_entries.t   max_entriest    i   s   {}
s
   history.pyt   0i    N(
   t
   get_optiont   ranget   formatt   joint   writet   add_historyR   t   lent	   readlinest   AssertionError(   R   t   tmpdirR   R   t   it   history_file(    (    s@   lib/python2.7/site-packages/spyder/plugins/tests/test_history.pyt   test_max_entries/   s    t   __main__(   t   __doc__t   unittest.mockR    t   ImportErrort   mockt   qtpy.QtWidgetsR   t   pytestt   spyder.plugins.historyR   t   spyder.py3compatR   t   fixtureR   R   R   t   main(    (    (    s@   lib/python2.7/site-packages/spyder/plugins/tests/test_history.pyt   <module>   s   	