ó
…¾^Yc           @` s†   d  Z  d d l m Z m Z m Z d d l Z d d l Z d Z d Z d Z	 d d „ Z d „  Z d	 „  Z d d d
 „ Z d „  Z d S(   s²   
Utilities for truncating assertion output.

Current default behaviour is to truncate assertion explanations at
~8 terminal lines, unless running in "-vv" mode or running on CI.
i    (   t   absolute_importt   divisiont   print_functionNi   iP   s   use '-vv' to showc         C` s   t  | ƒ r t |  ƒ S|  S(   sQ   
    Truncate this assertion explanation if the given test item is eligible.
    (   t   _should_truncate_itemt   _truncate_explanation(   t   explanationt   itemt
   max_length(    (    s:   /tmp/pip-build-hU8Cw8/pytest/_pytest/assertion/truncate.pyt   truncate_if_required   s    
c         C` s#   |  j  j j } | d k  o" t ƒ  S(   sC   
    Whether or not this test item is eligible for truncation.
    i   (   t   configt   optiont   verboset   _running_on_ci(   R   R   (    (    s:   /tmp/pip-build-hU8Cw8/pytest/_pytest/assertion/truncate.pyR      s    c          C` s    d d g }  t  d „  |  Dƒ ƒ S(   s0   Check if we're currently running on a CI system.t   CIt   BUILD_NUMBERc         s` s   |  ] } | t  j k Vq d  S(   N(   t   ost   environ(   t   .0t   var(    (    s:   /tmp/pip-build-hU8Cw8/pytest/_pytest/assertion/truncate.pys	   <genexpr>&   s    (   t   any(   t   env_vars(    (    s:   /tmp/pip-build-hU8Cw8/pytest/_pytest/assertion/truncate.pyR   #   s    c         C` s)  | d	 k r t } n  | d	 k r* t } n  t d j |  ƒ ƒ } t |  ƒ | k ra | | k ra |  S|  |  } t | | ƒ } | d d | d <t |  ƒ t | ƒ } | d 7} d } | d k rÔ | d j | ƒ 7} n | d j | ƒ 7} | d j t ƒ 7} | j t	 j
 j d ƒ t	 j
 j | ƒ g ƒ | S(
   sç   
    Truncate given list of strings that makes up the assertion explanation.

    Truncates to either 8 lines, or 640 characters - whichever the input reaches
    first. The remaining lines will be replaced by a usage message.
    t    iÿÿÿÿs   ...i   s   ...Full output truncateds    ({0} line hidden)s    ({0} lines hidden)s   , {0}N(   t   Nonet   DEFAULT_MAX_LINESt   DEFAULT_MAX_CHARSt   lent   joint   _truncate_by_char_countt   formatt	   USAGE_MSGt   extendt   pyt   builtint   _totext(   t   input_linest	   max_linest	   max_charst   input_char_countt   truncated_explanationt   truncated_line_countt   msg(    (    s:   /tmp/pip-build-hU8Cw8/pytest/_pytest/assertion/truncate.pyR   )   s*    		

c         C` s®   t  d j |  ƒ ƒ | k r |  Sd } xD t |  ƒ D]6 \ } } | t  | ƒ | k rX Pn  | t  | ƒ 7} q2 W|  |  } |  | } | r | | } | |  } n  | j | ƒ | S(   NR   i    (   R   R   t	   enumeratet   append(   R"   R$   t   iterated_char_countt   iterated_indext
   input_linet   truncated_resultt
   final_linet   final_line_truncate_point(    (    s:   /tmp/pip-build-hU8Cw8/pytest/_pytest/assertion/truncate.pyR   S   s    


i€  (   t   __doc__t
   __future__R    R   R   R   R   R   R   R   R   R   R   R   R   R   (    (    (    s:   /tmp/pip-build-hU8Cw8/pytest/_pytest/assertion/truncate.pyt   <module>   s   			*