ó
L]c           @   s   d  d l  Z  d  d l m Z d  d l Z d  d l Z d  d l m Z d  d l m Z	 d  d l
 m Z e e j  Z d e f d     YZ d S(   iĸĸĸĸN(   t   TestCase(   t   constant_names(   t	   constantst   TestConstantsc           B   s~   e  Z d    Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z	 e
 j j e j d d	 d
    Z d   Z RS(   c         C   sx   i  } x< t  |  D]. } | j |  } | d k r | | | <q q W| rt |  j d | t j | d d f  n  d S(   s(   test that a given list has no duplicatesi   s2   The following names occur more than once in %s: %st   indenti   N(   t   sett   countt   failt   jsont   dumps(   t   selft   namelistt   listnamet   dupest   namet   cnt(    (    s7   lib/python2.7/site-packages/zmq/tests/test_constants.pyt   _duplicate_test   s    c         C   s   |  j  t j d  S(   Nt	   all_names(   R   R   R   (   R
   (    (    s7   lib/python2.7/site-packages/zmq/tests/test_constants.pyt   test_duplicate_all   s    c         C   s   d t  | g t |   S(   s   return changed-in keys   %s-in %d.%d.%d(   t   tuplet   list(   R
   t   changet   version(    (    s7   lib/python2.7/site-packages/zmq/tests/test_constants.pyt   _change_key    s    c         C   s   g  } xg d D]_ } t  t | d  } xC | j   D]5 \ } } | j |  |  j | |  j | |   q3 Wq W|  j | d  d  S(   Nt   newt   removedt   _ins   all-changed(   R   R   (   t   getattrR   t   itemst   extendR   R   (   R
   t   all_changedR   t   dR   R   (    (    s7   lib/python2.7/site-packages/zmq/tests/test_constants.pyt   test_duplicate_changed$   s    $c         C   sÐ   i  } x d D] } t  t | d  } xv | j   D]h \ } } |  j | |  } xG | D]? } | t k rX | | k r g  | | <n  | | j |  qX qX Wq3 Wq W| rĖ |  j d t j | d d  n  d  S(   NR   R   R   s2   The following names are missing in `all_names`: %sR   i   (   R   R   (	   R   R   R   R   t   all_sett   appendR   R   R	   (   R
   t   missingR   R   R   R   t   keyR   (    (    s7   lib/python2.7/site-packages/zmq/tests/test_constants.pyt   test_changed_in_all.   s     c         C   s4   x- t  j D]" } |  j t t |  t  j  q
 Wd  S(   N(   t   sugar_constantst   __all__t   assertNotEqualR   t   zmqt
   _UNDEFINED(   R
   R   (    (    s7   lib/python2.7/site-packages/zmq/tests/test_constants.pyt   test_no_negative_constants?   s    c         C   s   g  } x t  j D] } | j |  q Wxg t j |  D]V } t t |  } | t  j k rt |  j t	 t t
 |  q7 |  j t t
 |  |  q7 Wd  S(   N(   R&   t   aliasesR   R!   t
   differenceR   t   backend_constantsR*   t   assertRaisest   AttributeErrorR)   t   assertEqual(   R
   t   all_aliasest   alias_groupR   t   raw(    (    s7   lib/python2.7/site-packages/zmq/tests/test_constants.pyt   test_undefined_constantsC   s    c         C   sŪ   t  j   } x t j j   D] \ } } | | k } xo | D]g } y t t  |  } Wn+ t k
 r | rĒ |  j d |  qĒ q; X| s; |  j d | | f  q; q; Wq Wd  S(   Ns   AttributeError: zmq.%ss   Shouldn't have: zmq.%s=%s(   R)   t   zmq_version_infoR   t   new_inR   R   R0   R   (   R
   t   zmq_versionR   t	   new_namest   should_haveR   t   value(    (    s7   lib/python2.7/site-packages/zmq/tests/test_constants.pyt   test_newO   s    t   reasons+   Only test draft API if built with draft APIc         C   sŪ   t  j   } x t j j   D] \ } } | | k } xo | D]g } y t t  |  } Wn+ t k
 r | rĒ |  j d |  qĒ q; X| s; |  j d | | f  q; q; Wq Wd  S(   Ns   AttributeError: zmq.%ss   Shouldn't have: zmq.%s=%s(   R)   R6   R   t   draft_inR   R   R0   R   (   R
   R8   R   R9   R:   R   R;   (    (    s7   lib/python2.7/site-packages/zmq/tests/test_constants.pyt
   test_draft]   s    c         C   sŪ   t  j   } x t j j   D] \ } } | | k  } xo | D]g } y t t  |  } Wn+ t k
 r | rĒ |  j d |  qĒ q; X| s; |  j d | | f  q; q; Wq Wd  S(   Ns   AttributeError: zmq.%ss   Shouldn't have: zmq.%s=%s(   R)   R6   R   t
   removed_inR   R   R0   R   (   R
   R8   R   R9   R:   R   R;   (    (    s7   lib/python2.7/site-packages/zmq/tests/test_constants.pyt   test_removedl   s    (   t   __name__t
   __module__R   R   R   R    R%   R+   R5   R<   t   pytestt   markt   skipifR)   t	   DRAFT_APIR?   RA   (    (    (    s7   lib/python2.7/site-packages/zmq/tests/test_constants.pyR      s   	
			
				%(   R   t   unittestR    RD   R)   t	   zmq.utilsR   t	   zmq.sugarR   R&   t   zmq.backendR.   R   R   R!   R   (    (    (    s7   lib/python2.7/site-packages/zmq/tests/test_constants.pyt   <module>   s   