mς
­fIc        
   @   s>  d  k  Td k Z d k Z d k l Z l Z d Z d d e f d d e f d d	 e	 f d
 d d d d g e
 f d d e d  d e f d d d d d e f d d d d e f g Z e o e e d  e d  e f d e d	  e	 f d e d  e d  e d  e d  g e
 f d e d  e d   d d g e
 f g 7Z n d!   Z d"   Z d#   Z d$   Z e e  d% GHy! e i e i i d&  d Z Wn e e f j
 o d Z n Xe d j	 oa y e e e  Z Wn' e j
 o Z d' Ge i GHd Z n Xe d j	 o e e  d( GHq:n
 d) Gd* GHd S(+   (   t   *N(   s   verifys   have_unicodes-   SOFTWARE\Python Registry Test Key - Delete Mes	   Int Valuei-   s
   String Vals   A string valuet   StringExpands   The path is %path%s   Multi-stringt   Lotst   oft   stringt   valuess   Raw Datat   binaryi    t   datas
   Big Stringt   xi   i   i   s
   Big Binarys   Unicode Vals   A Unicode valuet   UnicodeExpands   Multi-unicodet   unicodes   Multi-mixedt   Unicodet   andc         C   sg  t  |  t t d  t |  t  } t | d  } x- t D]% \ } } } t | | d | |  q8 Wt |  \ } } }	 t | d j d  t | d j d  t |  \ } } }	 t | d j d  t | t t  j d  t |  } t |  y t |  t d  Wn t j
 o n Xt |  }
 | i   y t |
  t d  Wn t j
 o n Xd  S(	   Ns   Default valuet   sub_keyi    i   s"   Not the correct number of sub keyss    Not the correct number of valuessA   It appears the CloseKey() function does not close the actual key!sB   It appears the key.Close() function does not close the actual key!(   t   SetValuet   root_keyt   test_key_namet   REG_SZt	   CreateKeyt   keyR   t	   test_datat
   value_namet
   value_datat
   value_typet
   SetValueExt   QueryInfoKeyt   nkeyst   nvaluest	   since_modt   verifyt   lent   intt   int_sub_keyt   CloseKeyt   RuntimeErrort   EnvironmentErrort   int_keyt   Close(   R   R   R   R   R   R   R    R   R   R   R$   (    (    t-   /mit/python/lib/python2.4/test/test_winreg.pyt   WriteTestData   s4     



c         C   sk  t  |  t  } t | d j d  t |  t  } t | d  }
 d } xL y t	 |
 |  } Wn t j
 o Pn Xt | t j d  | d } qI Wt | t t  j d  xL t D]D \ } } } t |
 |  \ }	 } t |	 | j o
 | | j d  q΅ W|
 i   t | d  }	 t |	 d j d	  y t | d  t d d
  Wn t j
 o n X| i   d  S(   Ns   Default values+   Registry didn't give back the correct valueR   i    i   s&   Didn't read back the correct test datas'   Didn't read the correct number of itemss!   Could not directly read the values   Read subkey value wrongs2   Was able to get a second key when I only have one!(   t
   QueryValueR   R   t   valR   t   OpenKeyR   R   t   indext	   EnumValueR   R#   R   R   R   R   R   t   QueryValueExt   read_valt   read_typR%   t   EnumKey(   R   R+   R   R)   R   R/   R   R   R   R.   R   (    (    R&   t   ReadTestDataA   s8       
c   	      C   s"  t  |  t d t  } t  | d d t  } x$ t D] \ } } } t
 | |  q1 Wt |  \ } } } t | d j o
 | d j d  | i   t | d  y t | d  t d d  Wn t j
 o n X| i   t |  t  y  t  |  t  } t d d  Wn t j
 o n Xd  S(   Ni    R   s   subkey not empty before deletes    Deleting the key twice succeededs   Could open the non-existent key(   R*   R   R   t   KEY_ALL_ACCESSR   R   R   R   R   R   t   DeleteValueR   R   R   R   R   R%   t	   DeleteKeyR#   t   WindowsError(	   R   R   R   R   R   R   R   R   R   (    (    R&   t   DeleteTestDatad   s*      

c         C   s"   t  |   t |   t |   d  S(   N(   R'   R   R1   R6   (   R   (    (    R&   t   TestAll   s    

s   Local registry tests workeds   --remotes)   Could not connect to the remote machine -s   Remote registry tests workeds)   Remote registry calls can be tested usings(   'test_winreg.py --remote \\machine_name'(   t   _winregt   ost   syst   test.test_supportR   t   have_unicodeR   t	   REG_DWORDR   t   REG_EXPAND_SZt   REG_MULTI_SZt   chrt
   REG_BINARYR   R
   R'   R1   R6   R7   t   HKEY_CURRENT_USERt   argvR+   t   remote_namet
   IndexErrort
   ValueErrort   Nonet   ConnectRegistryt
   remote_keyR#   t   exct   strerror(   R'   R7   R<   R   R   R:   R6   R1   RD   RI   R   RJ   R9   (    (    R&   t   ?   s6   		%	#		
!
