ó
:îÜWT	  c           @   sr   d  d l  m Z d  d l Z d  d l j j Z d  d l Z d  d l	 Z	 e j
 j Z d d d „  ƒ  YZ d „  Z d S(   iÿÿÿÿ(   t
   generatorsNt   TestSafeReprc           B   sG   e  Z d  „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   c         C   s  d } t  | ƒ } d } | | k } | sß t j d | f d | | f ƒ i d t j ƒ  k sl t j t  ƒ r{ t j t  ƒ n d d 6t j | ƒ d 6t j | ƒ d 6t j | ƒ d	 6} d i | d 6} t t j | ƒ ƒ ‚ n  d  } } } } t  d  ƒ } d } | | k } | sñt j d | f d | | f ƒ i d t j ƒ  k sWt j t  ƒ rft j t  ƒ n d d 6d t j ƒ  k sŽt j d  ƒ rt j d  ƒ n d d 6t j | ƒ d 6t j | ƒ d 6}	 d i |	 d 6}
 t t j |
 ƒ ƒ ‚ n  d  } } } d  S(   Ni   t   1s   ==s0   %(py4)s
{%(py4)s = %(py0)s(%(py2)s)
} == %(py7)st   safereprt   py0t   py2t   py4t   py7t    s   assert %(py9)st   py9t   Nones0   %(py3)s
{%(py3)s = %(py0)s(%(py1)s)
} == %(py6)st   py1t   py3t   py6s   assert %(py8)st   py8(   s   ==(   s0   %(py4)s
{%(py4)s = %(py0)s(%(py2)s)
} == %(py7)ss   assert %(py9)s(   s   ==(   s0   %(py3)s
{%(py3)s = %(py0)s(%(py1)s)
} == %(py6)ss   assert %(py8)s(
   R   t
   @pytest_art   _call_reprcomparet   @py_builtinst   localst   _should_repr_global_namet	   _safereprt   AssertionErrort   _format_explanationR
   (   t   selft   @py_assert1t   @py_assert3t   @py_assert6t   @py_assert5t   @py_format8t   @py_format10t   @py_assert2t   @py_assert4t   @py_format7t   @py_format9(    (    s?   /home/ronny/Projects/pytest-dev/py/testing/io_/test_saferepr.pyt   test_simple_repr
   s"         Œ       ³   c         C   s  t  d d d d ƒ} t | ƒ } d } | | k } | st j d | f d | | f ƒ i d t j ƒ  k s| t j t ƒ r‹ t j t ƒ n d d 6d	 t j ƒ  k s³ t j | ƒ rÂ t j | ƒ n d	 d
 6t j | ƒ d 6t j | ƒ d 6} d i | d 6} t t j	 | ƒ ƒ ‚ n  d  } } } t d d ƒ } | | k } | st j d | f d | | f ƒ i d	 t j ƒ  k sˆt j | ƒ r—t j | ƒ n d	 d 6d t j ƒ  k s¿t j | ƒ rÎt j | ƒ n d d 6}	 d i |	 d 6}
 t t j	 |
 ƒ ƒ ‚ n  d  } d  S(    Nt   xi2   t   maxsizei   s   ==s0   %(py3)s
{%(py3)s = %(py0)s(%(py1)s)
} == %(py6)st   lenR   t   sR   R   R   R   s   assert %(py8)sR   i
   s   ...s   %(py0)s == %(py2)st   expectedR   s   assert %(py4)sR   (   s   ==(   s0   %(py3)s
{%(py3)s = %(py0)s(%(py1)s)
} == %(py6)ss   assert %(py8)st
   xxxxxxxxxxs   xxxxxxxxxx...R(   (   s   ==(   s   %(py0)s == %(py2)ss   assert %(py4)s(   R   R%   R   R   R   R   R   R   R   R   R
   t   repr(   R   R&   R   R   R   R    R!   R'   R   t   @py_format3t   @py_format5(    (    s?   /home/ronny/Projects/pytest-dev/py/testing/io_/test_saferepr.pyt   test_maxsize   s         ³     “   c         C   sÍ  d d d „  ƒ  Y} t  d d | ƒ  f d d ƒ} t | ƒ } d } | | k } | s2t j d  | f d! | | f ƒ i d	 t j ƒ  k s˜ t j t ƒ r§ t j t ƒ n d	 d
 6d t j ƒ  k sÏ t j | ƒ rÞ t j | ƒ n d d 6t j | ƒ d 6t j | ƒ d 6} d" i | d 6} t t j	 | ƒ ƒ ‚ n  d  } } } g  } | d } d } | | k } | }	 | r“| d }
 d } |
 | k } | }	 n  |	 s§t j d# | f d$ | | f ƒ i t j | ƒ d 6t j | ƒ d 6} d i | d 6} | j | ƒ | rht j d% | f d& |
 | f ƒ i t j | ƒ d 6t j |
 ƒ d 6} d i | d 6} | j | ƒ n  t j | d ƒ i  } d' i | d 6} t t j	 | ƒ ƒ ‚ n  d  }	 } } } } }
 } } d  S((   Nt   Ac           B   s   e  Z d  „  Z RS(   c         S   s   t  d ƒ ‚ d  S(   Ns   ...(   t
   ValueError(   R   (    (    s?   /home/ronny/Projects/pytest-dev/py/testing/io_/test_saferepr.pyt   __repr__   s    (   t   __name__t
   __module__R/   (    (    (    s?   /home/ronny/Projects/pytest-dev/py/testing/io_/test_saferepr.pyR-      s   t   *i2   R$   i   s   ==s0   %(py3)s
{%(py3)s = %(py0)s(%(py1)s)
} == %(py6)sR%   R   R&   R   R   R   R   s   assert %(py8)sR   i    t   (iÿÿÿÿt   )s   %(py3)s == %(py6)ss   %(py8)ss   %(py11)s == %(py14)st   py14t   py11s   %(py16)st   py16s   assert %(py19)st   py19(    (   s   ==(   s0   %(py3)s
{%(py3)s = %(py0)s(%(py1)s)
} == %(py6)ss   assert %(py8)s(   s   ==(   s   %(py3)s == %(py6)s(   s   ==(   s   %(py11)s == %(py14)ss   assert %(py19)s(   R   R%   R   R   R   R   R   R   R   R   R
   t   appendt   _format_boolop(   R   R-   R&   R   R   R   R    R!   R   t   @py_assert0t   @py_assert10t   @py_assert13t   @py_assert12t   @py_format15t   @py_format17t   @py_format18t   @py_format20(    (    s?   /home/ronny/Projects/pytest-dev/py/testing/io_/test_saferepr.pyt   test_maxsize_error_on_instance   s@        ³    
     
   	  E    E      c         C   s  d f  d „  ƒ  Y} d t  f d „  ƒ  Y} d } d } t  | ƒ } | | ƒ } t | ƒ } | | k } | r¹t j d f | f d f | | f ƒ i t j | ƒ d	 6t j | ƒ d
 6t j | ƒ d 6d t j ƒ  k pá t j t ƒ ró t j t ƒ n d d 6d t j ƒ  k pt j | ƒ r*t j | ƒ n d d 6d t j ƒ  k pOt j t  ƒ rat j t  ƒ n d d 6t j | ƒ d 6t j | ƒ d 6}	 d d i |	 d 6}
 t t j	 |
 ƒ ƒ ‚ n  t
 } } } } } } t | d ƒ ƒ } d } | | k } | rt j d f | f d f | | f ƒ i t j | ƒ d 6d t j ƒ  k pSt j | ƒ ret j | ƒ n d d 6} d d i | d 6} t t j	 | ƒ ƒ ‚ n  t
 } } t j j j d d f k  rd } d } | | ƒ } t | ƒ } | | k } | rÿt j d f | f d f | | f ƒ i t j | ƒ d 6t j | ƒ d 6d t j ƒ  k p^t j t ƒ rpt j t ƒ n d d 6d t j ƒ  k p•t j | ƒ r§t j | ƒ n d d 6t j | ƒ d  6t j | ƒ d! 6} d d" i | d# 6} t t j	 | ƒ ƒ ‚ n  t
 } } } } } nSd } d } | | ƒ } t | ƒ } | | k } | rUt j d f | f d f | | f ƒ i t j | ƒ d 6t j | ƒ d 6d t j ƒ  k p´t j t ƒ rÆt j t ƒ n d d 6d t j ƒ  k pët j | ƒ rýt j | ƒ n d d 6t j | ƒ d  6t j | ƒ d! 6} d d" i | d# 6} t t j	 | ƒ ƒ ‚ n  t
 } } } } } t | | d$ ƒ ƒ ƒ } d% } | | k } | r;t j d& f | f d' f | | f ƒ i t j | ƒ d 6d( t j ƒ  k pñt j | ƒ rt j | ƒ n d( d 6} d d i | d 6} t t j	 | ƒ ƒ ‚ n  t
 } } d } | | k } | rýt j d f | f d f | | f ƒ i t j | ƒ d 6d( t j ƒ  k p³t j | ƒ rÅt j | ƒ n d( d 6} d d i | d 6} t t j	 | ƒ ƒ ‚ n  t
 } } d  S()   Nt
   BrokenReprc           B   s   e  Z d  „  Z d „  Z RS(   c         S   s   | |  _  d } d  S(   Ni    (   t   ex(   R   RE   t   foo(    (    s?   /home/ronny/Projects/pytest-dev/py/testing/io_/test_saferepr.pyt   __init__   s    	c         S   s   |  j  ‚ d  S(   N(   RE   (   R   (    (    s?   /home/ronny/Projects/pytest-dev/py/testing/io_/test_saferepr.pyR/   "   s    (   R0   R1   RG   R/   (    (    (    s?   /home/ronny/Projects/pytest-dev/py/testing/io_/test_saferepr.pyRD      s   	t   BrokenReprExceptionc           B   s   e  Z d  Z d  Z RS(   N(   R0   R1   R
   t   __str__R/   (    (    (    s?   /home/ronny/Projects/pytest-dev/py/testing/io_/test_saferepr.pyRH   $   s   t	   Exceptiont   brokent   insp   %(py1)s in %(py13)s
{%(py13)s = %(py3)s(%(py11)s
{%(py11)s = %(py4)s(%(py9)s
{%(py9)s = %(py5)s(%(py7)s)
})
})
}R	   t   py13R   R   R   R   t   py5R   R6   R   s   assert %(py15)st   py15s   really brokent	   TypeErrors   %(py1)s in %(py3)sR&   s   assert %(py5)si   i   t   unknownt   stringsP   %(py1)s in %(py10)s
{%(py10)s = %(py3)s(%(py8)s
{%(py8)s = %(py4)s(%(py6)s)
})
}R   t   py10R   s   assert %(py12)st   py12s   omg even worset	   NameErrors   not ins   %(py1)s not in %(py3)st   s2(   RJ   R   R   R   R   R   R   R   R   R   R
   t   pyt   stdt   syst   version_info(   R   RD   RH   R;   R   t   @py_assert8R<   R>   R   t   @py_format14t   @py_format16R&   t   @py_format4t   @py_format6R   t   @py_assert7t   @py_assert9t   @py_format11t   @py_format13RV   (    (    s?   /home/ronny/Projects/pytest-dev/py/testing/io_/test_saferepr.pyt   test_exceptions   st           ÿ !      r   
      Ù         Ù      r   
   r   c         C   sä  d d l  m } d } t | ƒ } t | ƒ } t | ƒ } d } | ƒ  } | j } d }	 | |	 }
 | |
 } d } | | } t | ƒ } | | k } | r¦t j d f | f d f | | f ƒ i t j | ƒ d	 6d
 t	 j
 ƒ  k pð t j t ƒ rt j t ƒ n d
 d 6t j | ƒ d 6d
 t	 j
 ƒ  k p7t j t ƒ rIt j t ƒ n d
 d 6d t	 j
 ƒ  k pnt j t ƒ r€t j t ƒ n d d 6d t	 j
 ƒ  k p¥t j t ƒ r·t j t ƒ n d d 6d t	 j
 ƒ  k pÜt j | ƒ rît j | ƒ n d d 6t j | ƒ d 6t j | ƒ d 6t j | ƒ d 6t j | ƒ d 6t j |	 ƒ d 6t j | ƒ d 6t j | ƒ d 6t j | ƒ d 6} d d i | d 6} t t j | ƒ ƒ ‚ n  t } } } } } } } } }	 }
 } } } } d  S(   Niÿÿÿÿ(   t   SafeRepriè  t   [t   1000t   ]s   <=sï   %(py10)s
{%(py10)s = %(py0)s(%(py8)s
{%(py8)s = %(py1)s(%(py6)s
{%(py6)s = %(py2)s(%(py4)s)
})
})
} <= %(py28)s
{%(py28)s = %(py12)s(((%(py14)s + (%(py19)s
{%(py19)s = %(py17)s
{%(py17)s = %(py15)s()
}.maxlist
} * %(py21)s)) + %(py25)s))
}R   R%   RT   R8   R   R   R   t   rangeR   Re   RO   R   R   t   py25RS   t   py21t   py17R5   t   py28R   s   assert %(py30)st   py30(   t   py._io.safereprRe   Ri   R   R%   t   maxlistR   R   R   R   R   R   R   R   R
   (   R   Re   R   R   R`   Ra   R=   t   @py_assert16t   @py_assert18t   @py_assert20t   @py_assert22t   @py_assert23t   @py_assert24t   @py_assert26t   @py_assert27t   @py_assert11t   @py_format29t   @py_format31(    (    s?   /home/ronny/Projects/pytest-dev/py/testing/io_/test_saferepr.pyt   test_big_repr3   s*         	 	  
 
  
    ÿ ß   c         C   sQ   d t  f d „  ƒ  Y} y t | ƒ  ƒ } Wn! t k
 rL t j j d ƒ n Xd  S(   Nt   Functionc           B   s   e  Z d  „  Z RS(   c         S   s   d |  j  S(   Ns   <%s>(   t   name(   R   (    (    s?   /home/ronny/Projects/pytest-dev/py/testing/io_/test_saferepr.pyR/   :   s    (   R0   R1   R/   (    (    (    s?   /home/ronny/Projects/pytest-dev/py/testing/io_/test_saferepr.pyR}   9   s   s"   saferepr failed for newstyle class(   t   objectR   RJ   RW   t   testt   fail(   R   R}   R&   (    (    s?   /home/ronny/Projects/pytest-dev/py/testing/io_/test_saferepr.pyt   test_repr_on_newstyle8   s
    c         C   sY  t  j j d d ƒ } t  j j d d ƒ } t | ƒ } | | k } | sKt j d | f d | | f ƒ i d t j ƒ  k sŠ t j t ƒ r™ t j	 t ƒ n d d 6d t j ƒ  k sÁ t j | ƒ rÐ t j	 | ƒ n d d	 6t j	 | ƒ d
 6d t j ƒ  k st j | ƒ rt j	 | ƒ n d d 6} d i | d 6} t
 t j | ƒ ƒ ‚ n  d  } } d  S(   Ns   Â£â‚¬s   utf-8s   'Â£â‚¬'s   ==s0   %(py3)s
{%(py3)s = %(py0)s(%(py1)s)
} == %(py5)sR   R   t   valR   R   t   reprvalRN   R   s   assert %(py7)sR   (   s   ==(   s0   %(py3)s
{%(py3)s = %(py0)s(%(py1)s)
} == %(py5)ss   assert %(py7)s(   RW   t   builtint   _totextR   R   R   R   R   R   R   R   R   R
   (   R   Rƒ   R„   R   R   R_   R   (    (    s?   /home/ronny/Projects/pytest-dev/py/testing/io_/test_saferepr.pyt   test_unicodeA   s       Ú   (	   R0   R1   R"   R,   RC   Rd   R|   R‚   R‡   (    (    (    s?   /home/ronny/Projects/pytest-dev/py/testing/io_/test_saferepr.pyR   	   s   								c             st   t  j j d d ƒ j d ƒ ‰  ‡  f d †  }  t  j j t |  ƒ } t | ƒ } t j	 d d k  rp t
 | ƒ } n  d  S(   Ns   Ä…Ä‡
s   utf-8t   utf8c              s   t  ˆ  ƒ ‚ d  S(   N(   RJ   (    (   t   value(    s?   /home/ronny/Projects/pytest-dev/py/testing/io_/test_saferepr.pyt   fH   s    i    i   (   RW   R…   R†   t   encodeR€   t   raisesRJ   t   strRY   RZ   t   unicode(   RŠ   t   excinfoR&   t   u(    (   R‰   s?   /home/ronny/Projects/pytest-dev/py/testing/io_/test_saferepr.pyt   test_unicode_handlingF   s    (    (   t
   __future__R    t   __builtin__R   t   _pytest.assertion.rewritet	   assertiont   rewriteR   RW   RY   t   ioR   R   R‘   (    (    (    s?   /home/ronny/Projects/pytest-dev/py/testing/io_/test_saferepr.pyt   <module>   s     =