ó
ç'ÊUc           @   sc   d  d l  m Z d  d l m Z d  d l m Z d  d l m Z d e e e j f d „  ƒ  YZ	 d S(   iÿÿÿÿ(   t   unittest(   t   defer(   t   SiteTest(   t   ProcessTestt	   ShellTestc           B   sž   e  Z d  Z e j d „  ƒ Z e j d „  ƒ Z e j d „  ƒ Z e j d „  ƒ Z e j d „  ƒ Z	 e j d „  ƒ Z
 e j d „  ƒ Z e j d „  ƒ Z RS(	   t   shellc         c   s5   |  j  d d g ƒ V\ } } } d | k s1 t ‚ d  S(   Ns   -ct   items   {}(   t   executet   AssertionError(   t   selft   _t   out(    (    s<   /home/travis/build/scrapy/scrapy/tests/test_command_shell.pyt
   test_empty   s    c         c   sA   |  j  |  j d ƒ d d g ƒ V\ } } } d | k s= t ‚ d  S(   Ns   /texts   -cs   response.bodyt   Works(   R   t   urlR   (   R	   R
   R   (    (    s<   /home/travis/build/scrapy/scrapy/tests/test_command_shell.pyt   test_response_body   s    +c         c   sA   |  j  |  j d ƒ d d g ƒ V\ } } } d | k s= t ‚ d  S(   Ns   /texts   -cs   type(response)t   TextResponse(   R   R   R   (   R	   R
   R   (    (    s<   /home/travis/build/scrapy/scrapy/tests/test_command_shell.pyt   test_response_type_text   s    +c         c   sA   |  j  |  j d ƒ d d g ƒ V\ } } } d | k s= t ‚ d  S(   Ns   /htmls   -cs   type(response)t   HtmlResponse(   R   R   R   (   R	   R
   R   (    (    s<   /home/travis/build/scrapy/scrapy/tests/test_command_shell.pyt   test_response_type_html   s    +c         c   sK   d } |  j  |  j d ƒ d | g ƒ V\ } } } |  j | j ƒ  d ƒ d  S(   Ns7   response.xpath("//p[@class='one']/text()").extract()[0]s   /htmls   -cR   (   R   R   t   assertEqualt   strip(   R	   t   xpathR
   R   (    (    s<   /home/travis/build/scrapy/scrapy/tests/test_command_shell.pyt   test_response_selector_html    s    +c         c   sE   |  j  |  j d ƒ d d g ƒ V\ } } } |  j | j ƒ  d ƒ d  S(   Ns   /enc-gb18030s   -cs   response.encodingt   gb18030(   R   R   R   R   (   R	   R
   R   (    (    s<   /home/travis/build/scrapy/scrapy/tests/test_command_shell.pyt   test_response_encoding_gb18030&   s    +c         c   sJ   |  j  |  j d ƒ d d g ƒ V\ } } } | j ƒ  j d ƒ sF t ‚ d  S(   Ns	   /redirects   -cs   response.urls   /redirected(   R   R   R   t   endswithR   (   R	   R
   R   (    (    s<   /home/travis/build/scrapy/scrapy/tests/test_command_shell.pyt   test_redirect+   s    +c         c   sT   |  j  d ƒ } d } |  j d | j | ƒ g ƒ V\ } } } |  j | d | ƒ d  S(   Ns   /texts>   fetch('{0}') or fetch(response.request.replace(method='POST'))s   -ci    (   R   R   t   formatR   (   R	   R   t   codet   errcodeR   R
   (    (    s<   /home/travis/build/scrapy/scrapy/tests/test_command_shell.pyt   test_request_replace0   s    ((   t   __name__t
   __module__t   commandR   t   inlineCallbacksR   R   R   R   R   R   R   R   (    (    (    s<   /home/travis/build/scrapy/scrapy/tests/test_command_shell.pyR      s   N(
   t   twisted.trialR    t   twisted.internetR   t   scrapy.utils.testsiteR   t   scrapy.utils.testprocR   t   TestCaseR   (    (    (    s<   /home/travis/build/scrapy/scrapy/tests/test_command_shell.pyt   <module>   s   