ó
ûR‹_c           @   s´   d  d l  m Z d  d l Z d  d l m Z m Z m Z m Z m Z	 d  d l
 m Z m Z m Z d  d l m Z e r d Z n d Z e r” d Z n d	 Z d
 e f d „  ƒ  YZ d S(   iÿÿÿÿ(   t   TestCaseN(   t
   ShouldWarnt   comparet   ShouldRaiset   ShouldNotWarnt
   Comparison(   t   PY3t
   PY_36_PLUSt
   PY_37_PLUS(   t   ShouldAssertt   builtinst
   exceptionst    t   ,t   ShouldWarnTestsc           B   s}   e  Z d  „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 d	 „  Z d
 „  Z d „  Z d „  Z RS(   c      
   C   s[   t  j d t ƒ - } t t d ƒ ƒ  t  j d ƒ Wd  QXWd  QXt t | ƒ d d ƒd  S(   Nt   recordt   foot   expectedi    (   t   warningst   catch_warningst   TrueR   t   UserWarningt   warnR   t   len(   t   selft   backstop(    (    s[   /var/www/syncserver/local/lib/python2.7/site-packages/testfixtures/tests/test_shouldwarn.pyt   test_warn_expected   s    c         C   sm   t  d t d ƒ = t j d t ƒ $ } t ƒ   t j d ƒ Wd  QXWd  QXWd  QXt t | ƒ d d ƒd  S(   NsM   sequence not as expected:

same:
[]

expected:
[]

actual:
[UserWarning('foo's   )]R   R   R   i    (	   R	   t   commaR   R   R   R   R   R   R   (   R   R   (    (    s[   /var/www/syncserver/local/lib/python2.7/site-packages/testfixtures/tests/test_shouldwarn.pyt   test_warn_not_expected   s    
c         C   s   t  ƒ   Wd  QXd  S(   N(   R   (   R   (    (    s[   /var/www/syncserver/local/lib/python2.7/site-packages/testfixtures/tests/test_shouldwarn.pyt   test_no_warn_expected+   s    
c      	   C   s8   t  d t d ƒ  t t d ƒ ƒ  Wd  QXWd  QXd  S(   Ns3   sequence not as expected:

same:
[]

expected:
[<C:s,   .UserWarning>args: ('foo',)</C>]

actual:
[]R   (   R	   t   warn_moduleR   R   (   R   (    (    s[   /var/www/syncserver/local/lib/python2.7/site-packages/testfixtures/tests/test_shouldwarn.pyt   test_no_warn_not_expected/   s    c      
   C   sJ   t  j ƒ  8 t  j d ƒ t t d ƒ ƒ  t  j d ƒ Wd  QXWd  QXd  S(   Nt   ignoreR   (   R   R   t   simplefilterR   R   R   (   R   (    (    s[   /var/www/syncserver/local/lib/python2.7/site-packages/testfixtures/tests/test_shouldwarn.pyt   test_filters_removed9   s    c      
   C   s   t  t ƒ : } t t d ƒ ƒ  t j d ƒ t j d ƒ Wd  QXWd  QXt | j ƒ } |  j d | k ƒ |  j d | k ƒ d  S(   NR   t   bar(	   R   t   AssertionErrorR   R   R   R   t   strt   raisedt
   assertTrue(   R   t   st   content(    (    s[   /var/www/syncserver/local/lib/python2.7/site-packages/testfixtures/tests/test_shouldwarn.pyt   test_multiple_warnings?   s    c         C   s$   t  t ƒ  t j d ƒ Wd  QXd  S(   NR   (   R   R   R   R   (   R   (    (    s[   /var/www/syncserver/local/lib/python2.7/site-packages/testfixtures/tests/test_shouldwarn.pyt   test_minimal_okH   s    c      
   C   sG   t  d t d t d ƒ % t t ƒ  t j d ƒ Wd  QXWd  QXd  S(   Ns;   sequence not as expected:

same:
[]

expected:
[<C(failed):s?   .DeprecationWarning>wrong type</C>]

actual:
[UserWarning('foo's   )]R   (   R	   R   R   R   t   DeprecationWarningR   R   (   R   (    (    s[   /var/www/syncserver/local/lib/python2.7/site-packages/testfixtures/tests/test_shouldwarn.pyt   test_minimal_badL   s    c      
   C   s6   t  t d ƒ ƒ  t j d t d d d ƒ Wd  QXd  S(   NR   s   bar.pyi*   t
   bar_module(   R   R,   R   t   warn_explicit(   R   (    (    s[   /var/www/syncserver/local/lib/python2.7/site-packages/testfixtures/tests/test_shouldwarn.pyt   test_maximal_okW   s    c         C   sY   t  d t d t d ƒ 7 t t d ƒ ƒ  t j d t d d d ƒ Wd  QXWd  QXd  S(	   Ns<   sequence not as expected:

same:
[]

expected:
[
<C(failed):sƒ   .DeprecationWarning>
attributes differ:
'args': ('bar',) (Comparison) != ('foo',) (actual)
</C>]

actual:
[DeprecationWarning('foo's   )]R#   R   s   bar.pyi*   R.   (   R	   R   R   R   R,   R   R/   (   R   (    (    s[   /var/www/syncserver/local/lib/python2.7/site-packages/testfixtures/tests/test_shouldwarn.pyt   test_maximal_bad]   s
    c         C   sº   t  ƒ    } t j d t d d d ƒ Wd  QXt t | ƒ d d ƒt d d d	 t d
 d  d d d d  d d d t t d ƒ ƒ ƒ } t	 r“ d  | d <n  t d t t j
 |  d | d ƒ d  S(   NR   s   bar.pyi*   R.   R   i   t   _category_nameR,   t   categoryt   filet   filenamet   linet   linenot   messaget   sourcet   actuali    (   R   R   R/   R,   R   R   t   dictt   Nonet   CR   t   WarningMessage(   R   t   recordedt   expected_attrs(    (    s[   /var/www/syncserver/local/lib/python2.7/site-packages/testfixtures/tests/test_shouldwarn.pyt   test_maximal_explorel   s     c         C   s=   t  t d d ƒ% t j d t ƒ t j d t ƒ Wd  QXd  S(   NR8   s   This function is deprecated.s   This utility is deprecated.(   R   R,   R   R   (   R   (    (    s[   /var/www/syncserver/local/lib/python2.7/site-packages/testfixtures/tests/test_shouldwarn.pyt   test_filter_presentƒ   s    	
c         C   s^   t  r d } n d } t d j | ƒ ƒ . t t d d ƒ t j d t ƒ Wd  QXWd  QXd  S(   Ns   builtins.DeprecationWarnings   exceptions.DeprecationWarningsC   sequence not as expected:

same:
[]

expected:
[<C:{}>]

actual:
[]R8   s   This function is deprecated.s   This utility is deprecated.(   R   R	   t   formatR   R,   R   R   (   R   t	   type_repr(    (    s[   /var/www/syncserver/local/lib/python2.7/site-packages/testfixtures/tests/test_shouldwarn.pyt   test_filter_missing‰   s    		
(   t   __name__t
   __module__R   R   R   R   R"   R*   R+   R-   R0   R1   RA   RB   RE   (    (    (    s[   /var/www/syncserver/local/lib/python2.7/site-packages/testfixtures/tests/test_shouldwarn.pyR      s   				
									(   t   unittestR    R   t   testfixturesR   R   R   R   R   R=   t   testfixtures.compatR   R   R   t   testfixtures.shouldraiseR	   R   R   R   (    (    (    s[   /var/www/syncserver/local/lib/python2.7/site-packages/testfixtures/tests/test_shouldwarn.pyt   <module>   s   (		