ó
ŒwÛjc        
   @   så  d  d l  Z  d  d l Z d  d l Z d  d l Z d  d l m Z e j d ƒ Z d  d l m	 Z	 e j d ƒ d  d l
 Ty! e j e j j d ƒ d Z Wn e e f k
 r¶ d Z n Xe j ƒ  d	  Z e	 ƒ  d
 k rÜ e n e Z e d8 k  rô e n e Z d e  j ƒ  f Z d e Z d e 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: e f d! d d; e  f g Z! e j" r1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* e j$ f d+ „  ƒ  YZ% d, e% f d- „  ƒ  YZ& e j' e d. ƒ d/ e% f d0 „  ƒ  Yƒ Z( e j' e d1 ƒ d2 e% f d3 „  ƒ  Yƒ Z) d4 „  Z* e+ d5 k ráe s×d6 Gd7 GHn  e* ƒ  n  d S(<   iÿÿÿÿN(   t   test_supportt	   threading(   t   machinet   _winreg(   t   *s   --remotei   i   t   AMD64i   s    Python Test Key [%d] - Delete Mes	   SOFTWARE\s   SOFTWARE\Classes\s	   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   s
   Big Binarys   Unicode Vals   A Unicode valuet   UnicodeExpands   Multi-unicodet   unicodes   Multi-mixedt   Unicodet   andt   BaseWinregTestsc           B   sD   e  Z d  „  Z d „  Z e d „ Z e d „ Z d „  Z d „  Z	 RS(   c         C   s   |  j  t t ƒ d  S(   N(   t   delete_treet   HKEY_CURRENT_USERt   test_key_name(   t   self(    (    s†   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_winreg.pyt   setUp<   s    c         C   s‹   y t  | | t ƒ } Wn t k
 r* d  SXxB t ro y t | d ƒ } Wn t k
 r[ Pn X|  j | | ƒ q. Wt | ƒ t | | ƒ d  S(   Ni    (   t   OpenKeyt   KEY_ALL_ACCESSt   WindowsErrort   Truet   EnumKeyR   t   CloseKeyt	   DeleteKey(   R   t   roott   subkeyt   hkeyt	   subsubkey(    (    s†   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_winreg.pyR   A   s    	
c         C   sk  t  | t t d ƒ | | t ƒ } | | d ƒ } x- t D]% \ } } } t | | d | | ƒ q8 Wt | ƒ \ } }	 }
 |  j | d d ƒ |  j |	 d d ƒ t | ƒ \ } }	 }
 |  j | d d ƒ |  j |	 t t ƒ d ƒ t | ƒ } t	 | ƒ y t | ƒ |  j
 d ƒ Wn t k
 r!n Xt | ƒ } | j ƒ  y t | ƒ |  j
 d ƒ Wn t k
 rf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   SetValueR   t   REG_SZt	   test_datat
   SetValueExt   QueryInfoKeyt   assertEqualt   lent   intR   t   failt   EnvironmentErrort   Close(   R   t   root_keyt	   CreateKeyt   keyR#   t
   value_namet
   value_datat
   value_typet   nkeyst   nvaluest	   since_modt   int_sub_keyt   int_key(    (    s†   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_winreg.pyt   _write_test_dataQ   s4    



c      	   C   su  t  | t ƒ } |  j | d d ƒ | | t ƒ } | | d ƒ �Ç } d } xI y t | | ƒ } Wn t k
 rs Pn X|  j | t d ƒ | d } qL W|  j | t t ƒ d ƒ xR t D]J \ } }	 }
 t | | ƒ \ } } |  j | |	 d ƒ |  j | |
 d ƒ qµ WWd  QX| j	 ƒ  t
 | d ƒ } |  j | d d	 ƒ y t
 | d ƒ |  j d
 ƒ Wn t k
 rfn X| j	 ƒ  d  S(   Ns   Default values+   Registry didn't give back the correct valueR#   i    s&   Didn't read back the correct test datai   s'   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	   EnumValueR-   t   assertInR&   R*   t   QueryValueExR.   R   R,   (   R   R/   R   t   valR1   R#   t   indexR   R2   R3   R4   t   read_valt   read_typ(    (    s†   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_winreg.pyt   _read_test_datay   s>    
c   
      C   s$  t  | t d t ƒ } t  | d d t ƒ } x$ t D] \ } } } t | | ƒ q1 Wt | ƒ \ } } }	 |  j | d d ƒ |  j | d d ƒ | j ƒ  t | d ƒ y t | d ƒ |  j	 d ƒ Wn t
 k
 rÔ n X| j ƒ  t | t ƒ y  t  | t ƒ } |  j	 d ƒ Wn t k
 r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   R&   t   DeleteValueR(   R)   R.   R   R,   R-   R   (
   R   R/   R1   R#   R2   R3   R4   R5   R6   R7   (    (    s†   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_winreg.pyt   _delete_test_data¡   s*    

c         C   s+   |  j  | ƒ |  j | ƒ |  j | ƒ d  S(   N(   R:   RC   RE   (   R   R/   (    (    s†   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_winreg.pyt	   _test_all¿   s    (
   t   __name__t
   __module__R   R   R0   R:   R   RC   RE   RF   (    (    (    s†   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_winreg.pyR   :   s   		((	t   LocalWinregTestsc           B   sž   e  Z d  „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 e j e d k  d ƒ d „  ƒ Z d „  Z d „  Z d „  Z d „  Z RS(   c         C   s   |  j  t ƒ d  S(   N(   RF   R   (   R   (    (    s†   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_winreg.pyt   test_registry_worksÆ   s    c         C   sC   d „  } |  j  t | ƒ d „  } |  j t | ƒ |  j t ƒ d  S(   Nc         S   s   t  |  | d t ƒ S(   Ni    (   t   CreateKeyExR   (   R1   R#   (    (    s†   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_winreg.pyt   <lambda>Í   t    c         S   s   t  |  | d t ƒ S(   Ni    (   t	   OpenKeyExt   KEY_READ(   R1   R#   (    (    s†   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_winreg.pyRL   Ð   RM   (   R:   R   RC   RE   (   R   t   cket   oke(    (    s†   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_winreg.pyt&   test_registry_works_extended_functionsÉ   s
    		c         C   sC   t  d  t ƒ } |  j | j d ƒ | j ƒ  |  j | j d ƒ d  S(   Ni    (   t   ConnectRegistryt   Nonet   HKEY_LOCAL_MACHINEt   assertNotEqualt   handleR.   R)   (   R   t   h(    (    s†   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_winreg.pyt,   test_connect_registry_to_local_machine_worksÕ   s    
c         C   s   d „  } |  j  t | ƒ d  S(   Nc           S   s   t  d t ƒ S(   Nt   abcdefghijkl(   RS   R   (    (    (    s†   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_winreg.pyRL   Ý   RM   (   t   assertRaisesR   (   R   t   connect(    (    s†   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_winreg.pyt   test_inexistant_remote_registryÜ   s    	c         C   sA   t  d ƒ } |  j t | ƒ t ƒ |  j | t j d d ƒ d  S(   Nu   %windir%\testt   windirs   \test(   t   ExpandEnvironmentStringsR)   t   typeR   t   ost   environ(   R   t   r(    (    s†   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_winreg.pyt   test_expand_environment_stringsà   s    c         C   s`   y5 t  d  t ƒ �  } |  j | j d ƒ t ‚ Wd  QXWn$ t k
 r[ |  j | j d ƒ n Xd  S(   Ni    (   RS   RT   RU   RV   RW   R   R)   (   R   RX   (    (    s†   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_winreg.pyt   test_context_managerå   s    c   
   
      s  t  ‰  d t j f ‡  f d †  ƒ  Y} | ƒ  } | j ƒ  zƒ t t t d ƒ �j } x` t d ƒ D]R } t | ƒ \ } } } x4 t | ƒ D]& } t	 | | ƒ }	 t
 | |	 d ƒ q† Wq^ WWd  QXWd  t ‰  | j ƒ  t t t d t ƒ � } t | d ƒ Wd  QXt t t ƒ Xd  S(   Nt   VeryActiveThreadc              s   e  Z ‡  f d  †  Z RS(   c      	      se   t  t t ƒ �P } t } d d } x6 ˆ  sZ | r7 d n | } | } t | d t | ƒ q% WWd  QXd  S(   NR   iÐ  t   changing_value(   R0   R   R   R   R$   R%   (   R   R1   t	   use_shortt   long_stringt   s(   t   done(    s†   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_winreg.pyt   runõ   s    
	(   RG   RH   Rl   (    (   Rk   (    s†   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_winreg.pyRf   ô   s   s   \changing_valueiè  i    Rg   (   t   FalseR   t   Threadt   startR0   R   R   t   rangeR(   R<   R;   R   t   joinR   R   R   (
   R   Rf   t   threadR1   t   _t   num_subkeyst
   num_valuest   tt   it   name(    (   Rk   s†   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_winreg.pyt   test_changing_valueî   s"    
	
#
c      
   C   s›   d d } zQ t  t t ƒ �< } t | | t d ƒ t | ƒ \ } } } t | d ƒ Wd  QXWd  t t t d t ƒ � } t	 | | ƒ Wd  QXt	 t t ƒ Xd  S(   NR   i   i    (
   R0   R   R   R$   R%   R(   R   R   R   R   (   R   Rx   R1   Rt   Ru   Rv   (    (    s†   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_winreg.pyt   test_long_key  s    
c         C   sf   y t  t d ƒ WnA t k
 rT } | j t j t j f k rN |  j d ƒ n  ‚  n Xt t d  ƒ d  S(   Ni    sM   access denied to registry key (are you running in a non-interactive session?)(	   R<   t   HKEY_PERFORMANCE_DATAt   OSErrort   errnot   EPERMt   EACCESt   skipTestR>   RT   (   R   t   e(    (    s†   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_winreg.pyt   test_dynamic_key  s    i   i   s   Requires Windows XPc         C   sé   zÔ t  t t ƒ � } |  j | j d ƒ Wd  QXt t t ƒ } |  j | j d ƒ |  j t ƒ � t | ƒ Wd  QX|  j t ƒ � t	 | ƒ Wd  QX|  j t ƒ � t
 | ƒ Wd  QX|  j t ƒ � t t t ƒ Wd  QXWd  t t t ƒ Xd  S(   Ni    (   R0   R   R   RV   RW   R   R[   t   NotImplementedErrort   DisableReflectionKeyt   EnableReflectionKeyt   QueryReflectionKeyt   DeleteKeyExR   (   R   t   ckR1   (    (    s†   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_winreg.pyt   test_reflection_unsupported,  s    c      
   C   sZ   zE t  t t ƒ �0 } |  j | j d ƒ t | d d  t d ƒ Wd  QXWd  t t t ƒ Xd  S(   Ni    t	   test_nameI   €    (	   R0   R   R   RV   RW   R'   RT   t	   REG_DWORDR   (   R   Rˆ   (    (    s†   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_winreg.pyt   test_setvalueex_value_range@  s
     c         C   sv   za t  t t ƒ �L } |  j | j d ƒ |  j t ƒ �! t | d d  t	 t
 d ƒ ƒ Wd  QXWd  QXWd  t t t ƒ Xd  S(   Ni    RŠ   R?   (   R0   R   R   RV   RW   R[   t	   TypeErrorR'   RT   t
   REG_BINARYt
   memoryviewR   (   R   Rˆ   (    (    s†   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_winreg.pyt   test_setvalueex_with_memoryviewL  s    ,c      
   C   s•   z€ t  t t ƒ �k } |  j | j d ƒ d } t | d d  t | ƒ t | d ƒ \ } } |  j	 | t ƒ |  j	 | | ƒ Wd  QXWd  t
 t t ƒ Xd  S(   Ni    I   €    RŠ   (   R0   R   R   RV   RW   R'   RT   R‹   R>   R)   R   (   R   Rˆ   t   test_valt   ret_valt   ret_type(    (    s†   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_winreg.pyt   test_queryvalueex_return_valueU  s    c      
   C   s•   z€ t  t t ƒ �k } |  j | j d ƒ d  } t | d d t | ƒ t | d ƒ \ } } |  j	 | t ƒ |  j	 | | ƒ Wd  QXWd  t
 t t ƒ Xd  S(   Ni    RŠ   (   R0   R   R   RV   RW   RT   R'   RŽ   R>   R)   R   (   R   Rˆ   R‘   R’   R“   (    (    s†   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_winreg.pyt#   test_setvalueex_crash_with_none_arge  s    (   i   i   (   RG   RH   RJ   RR   RY   R]   Rd   Re   Ry   Rz   R‚   t   unittestt
   skipUnlesst   WIN_VERR‰   RŒ   R�   R”   R•   (    (    (    s†   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_winreg.pyRI   Ä   s   								!		!				s   Skipping remote registry testst   RemoteWinregTestsc           B   s   e  Z d  „  Z RS(   c         C   s    t  t t ƒ } |  j | ƒ d  S(   N(   RS   t   REMOTE_NAMER   RF   (   R   t
   remote_key(    (    s†   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_winreg.pyt   test_remote_registry_worksw  s    (   RG   RH   Rœ   (    (    (    s†   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_winreg.pyR™   t  s   s   x64 specific registry testst   Win64WinregTestsc           B   sP   e  Z d  „  Z e j e d ƒ d „  ƒ Z e j e d ƒ d „  ƒ Z d „  Z RS(   c         C   sn   t  t d ƒ �Y } |  j t | ƒ ƒ |  j d  t | ƒ ƒ |  j d  t | ƒ ƒ |  j t | ƒ ƒ Wd  QXd  S(   Nt   Software(   R   RU   t
   assertTrueR†   R)   RT   R…   R„   (   R   R1   (    (    s†   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_winreg.pyt   test_reflection_functions  s
    s   OS doesn't support reflectionc         C   sW  z<t  t t d t t Bƒ �~ } |  j | j d ƒ t t t d t t Bƒ � } |  j | j d ƒ Wd  QXt | d d t	 d ƒ d „  } |  j
 t | ƒ Wd  QXt t t d t t Bƒ �I } |  j | j d ƒ |  j d t | d ƒ ƒ t | d d t	 d ƒ Wd  QXt t t d t t Bƒ �  } |  j d t | d ƒ ƒ Wd  QXWd  t t t t d ƒ Xd  S(   Ni    RM   t   32KEYc           S   s   t  t t d t t Bƒ S(   Ni    (   R   R   t   test_reflect_key_nameRO   t   KEY_WOW64_64KEY(    (    (    s†   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_winreg.pyRL   ž  s   t   64KEY(   RK   R   R¢   R   t   KEY_WOW64_32KEYRV   RW   R   R'   R%   R[   R   R£   R)   R;   RO   R‡   (   R   t   created_keyR1   t	   open_fail(    (    s†   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_winreg.pyt   test_reflection‰  s(    	#	c         C   sÛ   zÀ t  t t d t t Bƒ �S } t | ƒ } |  j t | ƒ t ƒ |  j	 | ƒ t
 | ƒ |  j t | ƒ ƒ Wd  QXd „  } |  j t | ƒ t t t d t t Bƒ � } |  j | j d ƒ Wd  QXWd  t t t t d ƒ Xd  S(   Ni    c           S   s   t  t t d t t Bƒ S(   Ni    (   RN   R   R¢   RO   R£   (    (    (    s†   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_winreg.pyRL   Æ  s   (   RK   R   R¢   R   R¥   R†   R)   R`   t   boolt   assertFalseR„   RŸ   R[   R   RN   RO   RV   RW   R‡   (   R   R¦   t   disabledR§   R1   (    (    s†   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_winreg.pyt   test_disable_reflectionµ  s    
		c         C   s?   |  j  t ƒ � } t t d ƒ Wd  QX|  j | j j d ƒ d  S(   Nt   some_value_that_does_not_existi   (   R[   R   R;   t   HKEY_CLASSES_ROOTR)   t	   exceptionR}   (   R   t   ctx(    (    s†   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_winreg.pyt   test_exception_numbersÓ  s    (	   RG   RH   R    R–   R—   t   HAS_REFLECTIONR¨   R¬   R±   (    (    (    s†   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_winreg.pyR�   |  s   	
,c           C   s   t  j t t t ƒ d  S(   N(   R    t   run_unittestRI   R™   R�   (    (    (    s†   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_winreg.pyt	   test_mainÙ  s    t   __main__s)   Remote registry calls can be tested usings(   'test_winreg.py --remote \\machine_name'(   i   i   i @  iÿ?  i @  (,   Ra   t   sysR}   R–   t   testR    t   import_moduleR   t   platformR   R   t   argvR@   Rš   t
   IndexErrort
   ValueErrorRT   t   getwindowsversionR˜   R   Rm   t   WIN64_MACHINER²   t   getpidt   test_key_baseR   R¢   R‹   R%   t   REG_EXPAND_SZt   REG_MULTI_SZt   chrRŽ   R&   t   have_unicodeR   t   TestCaseR   RI   R—   R™   R�   R´   RG   (    (    (    s†   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_winreg.pyt   <module>   sV   $
!


	Š°\	