Uname: Linux web3.us.cloudlogin.co 5.10.226-xeon-hst #2 SMP Fri Sep 13 12:28:44 UTC 2024 x86_64
Software: Apache
PHP version: 8.1.31 [ PHP INFO ] PHP os: Linux
Server Ip: 162.210.96.117
Your Ip: 18.219.10.176
User: edustar (269686) | Group: tty (888)
Safe Mode: OFF
Disable Function:
NONE

name : test_winreg.cpython-310.pyc
o

ab%U�@s�ddlZddlZddlZddlZddlmZddlZddlmZm	Z	ej
ddgd�ddlTz
ejej�
d�d	ZWn
eefyHdZYnwe��dd
�Ze�dkrXdnd
Zedkr`dnd
Zde��fZdeZdeZddefddefddefddefdgd�efdgd�efddefd d!d"efd#d$d%efd&d'efg
ZGd(d)�d)ej �Z!Gd*d+�d+e!�Z"e�#ed,�Gd-d.�d.e!��Z$e�#ed/�Gd0d1�d1e!��Z%e&d2kr�es�e'd3d4�e�(�dSdS)5�N)�
import_helper)�machine�
win32_edition�winreg�win)Zrequired_on)�*z--remote��ZAMD64TF)�rz Python Test Key [%d] - Delete Mez	SOFTWARE\zSOFTWARE\Classes\z	Int Value�-zQword Valuel�w�*M	z
String ValzA string valueZStringExpandzThe path is %path%zMulti-string)ZLotsZof�string�valuesz	Multi-nul)�rrrzRaw Datasbinarydataz
Big String�xi�?z
Big Binary�xi@uJapanese 日本u	日本語c@sTeZdZdd�Zdd�Zdefdd�Zdefdd	�Zdd
d�Z	ddd
�Z
dd�ZdS)�BaseWinregTestscCs|�tt�dS�N)�delete_tree�HKEY_CURRENT_USER�
test_key_name��self�r�9/usr/local/python-3.10/lib/python3.10/test/test_winreg.py�setUp6szBaseWinregTests.setUpcCspz	t||dt�}Wn
tyYdSw	zt|d�}Wn	ty%Yq-w|�||�qt|�t||�dS�Nr)�OpenKey�KEY_ALL_ACCESS�OSError�EnumKeyr�CloseKey�	DeleteKey)r�rootZsubkey�hkeyZ	subsubkeyrrrr;s���zBaseWinregTests.delete_tree�sub_keycCs"t|ttd�||t�}|�|jdk�|||�}tD]
\}}}t||d||�qt|�\}	}
}|�|	dd�|�|
dd�t|�\}	}
}|�|	dd�|�|
t	t�d�t
|�}t|�zt|�|�d�Wn	t
yqYnwt
|�}
|��zt|
�|�d�WdSt
y�YdSw)N�
Default valuerrz"Not the correct number of sub keysz Not the correct number of valueszAIt appears the CloseKey() function does not close the actual key!zBIt appears the key.Close() function does not close the actual key!)�SetValuer�REG_SZ�
assertTrue�handle�	test_data�
SetValueEx�QueryInfoKey�assertEqual�len�intr �failr�Close)r�root_key�	subkeystr�	CreateKey�keyr$�
value_name�
value_data�
value_type�nkeys�nvalues�	since_modZint_sub_keyZint_keyrrr�_write_test_dataKs<

���z BaseWinregTests._write_test_datac	Cs4t|t�}|�|dd�||t�}|||��P}d}	zt||�}Wn	ty*Yq9w|�|tvdd�|d}q|�|tt�d�tD]\}	}
}t||	�\}}
|�||
d�|�|
|d�qDWd�n1siwY|��t	|d�}|�||d	�zt	|d�|�
d
�Wn	ty�Ynw|��dS)Nr%z+Registry didn't give back the correct valuerrTz&Didn't read back the correct test dataz'Didn't read the correct number of itemsz!Could not directly read the valuezRead subkey value wrongz2Was able to get a second key when I only have one!)�
QueryValuerr-�	EnumValuerr*r.�QueryValueExr1rr0)rr2r3r�valr5r$�index�datar6r7r8Zread_valZread_typrrr�_read_test_datausR
�
��������

�zBaseWinregTests._read_test_datacCs�t|tdt�}t||dt�}tD]
\}}}t||�qt|�\}}	}
|�|dd�|�|	dd�|��t||�zt||�|�	d�Wn	t
yNYnw|��t|t�z
t|t�}|�	d�WdSt
yoYdSw)Nrzsubkey not empty before deletez Deleting the key twice succeededzCould open the non-existent key)rrrr*ZDeleteValuer,r-r1r!r0r)rr2r3r5r$r6r7r8r9r:r;rrr�_delete_test_data�s.

�

�z!BaseWinregTests._delete_test_datacCs(|�||�|�||�|�||�dSr)r<rCrD)rr2r3rrr�	_test_all�szBaseWinregTests._test_allcCs�t||dtd��}|�|jdk�Wd�n1swYt||dtd��}|�|jdk�Wd�dS1s<wYdS)Nr)r5r$�reserved�access)�CreateKeyExrr(r)�	OpenKeyEx)rr5r$ZckeyZokeyrrr�_test_named_args�s���"�z BaseWinregTests._test_named_argsN)r$)�__name__�
__module__�__qualname__rrr4r<rrCrDrErJrrrrr4s
�*
(
rc@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Ze
�edkd�dd��Zdd�Zdd�Zdd�Zdd �Zd!S)"�LocalWinregTestscCs|�t�|�td�dS)Nu
日本-subkey)rErrrrr�test_registry_works�s
z$LocalWinregTests.test_registry_workscCs:dd�}|jt|d�dd�}|jt|d�|�t�dS)NcS�t||dt�Sr)rHr�r5r$rrr�<lambda>��zILocalWinregTests.test_registry_works_extended_functions.<locals>.<lambda>)r4cSrPr)rI�KEY_READrQrrrrR�rS)r)r<rrCrD)rZckeZokerrr�&test_registry_works_extended_functions�s
z7LocalWinregTests.test_registry_works_extended_functionscCs|�tt�ttt�dSr)rJrrr!rrrr�test_named_arguments�sz%LocalWinregTests.test_named_argumentscCs2tdt�}|�|jd�|��|�|jd�dSr)�ConnectRegistry�HKEY_LOCAL_MACHINE�assertNotEqualr)r1r-�r�hrrr�,test_connect_registry_to_local_machine_works�s
z=LocalWinregTests.test_connect_registry_to_local_machine_workscCsdd�}|�t|�dS)NcSs
tdt�S)NZabcdefghijkl)rWrrrrrrR�s
zCLocalWinregTests.test_nonexistent_remote_registry.<locals>.<lambda>)�assertRaisesr)r�connectrrr� test_nonexistent_remote_registry�sz1LocalWinregTests.test_nonexistent_remote_registrycCs2td�}|�t|�t�|�|tjdd�dS)Nz
%windir%\testZwindirz\test)ZExpandEnvironmentStringsr-�type�str�os�environ)r�rrrr�testExpandEnvironmentStrings�sz-LocalWinregTests.testExpandEnvironmentStringscCsXztdt��
}|�|jd�t�1swYWdSty+|�|jd�YdSwr)rWrXrYr)rr-rZrrr�test_context_manager�s��z%LocalWinregTests.test_context_managerc

sd�G�fdd�dtj�}|�}|��zbtttd��)}td�D]}t|�\}}}t|�D]}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xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxrZchanging_value)r4rrr&r')rr5Z	use_shortZlong_string�s��donerr�runs��"�zBLocalWinregTests.test_changing_value.<locals>.VeryActiveThread.runN)rKrLrMrjrrhrr�VeryActiveThreadsrkz\changing_valuei�rT)�	threading�Thread�startr4rr�ranger,r>r=�joinr!)
rrk�threadr5�_�num_subkeys�
num_values�t�i�namerrhr�test_changing_value�s<
�
�����z$LocalWinregTests.test_changing_valuecCs�d}zLttt��}t||td�t|�\}}}t|d�Wd�n1s&wYWttd�t|f��ttt�dSWttd�t|f��ttt�dSttd�t|f��ttt�w)NAxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxrr�\)	r4rrr&r'r,rr!rp)rrwr5rsrtrurrr�
test_long_keys���zLocalWinregTests.test_long_keyc
CsTzttd�Wnty"}z|jtjtjfvr|�d��d}~wwttd�dS)NrzMaccess denied to registry key (are you running in a non-interactive session?)r)r>ZHKEY_PERFORMANCE_DATAr�errno�EPERMZEACCESZskipTestr?)r�errr�test_dynamic_key)s
��z!LocalWinregTests.test_dynamic_key)�r	zRequires Windows XPc	CsHz�ttt��}|�|jd�Wd�n1swYttt�}|�|jd�|�t��t|�Wd�n1s=wY|�t��t	|�Wd�n1sVwY|�t��t
|�Wd�n1sowY|�t��
ttt�Wd�n1s�wYWttt�dSWttt�dSttt�wr)
r4rrrYr)rr]�NotImplementedError�DisableReflectionKey�EnableReflectionKey�QueryReflectionKey�DeleteKeyExr!)r�ckr5rrr�test_reflection_unsupported7s*�

�
�
���z,LocalWinregTests.test_reflection_unsupportedc	Csvz4ttt��}|�|jd�t|ddtd�Wd�n1s wYWttt�dSWttt�dSttt�w)Nr�	test_name�)r4rrrYr)r+�	REG_DWORDr!)rr�rrr�test_setvalueex_value_rangeKs��z,LocalWinregTests.test_setvalueex_value_rangec	Cs�zIttt��,}|�|jd�d}t|ddt|�t|d�\}}|�|t�|�||�Wd�n1s5wYWt	tt�dSWt	tt�dSt	tt�w)Nrr�r�)
r4rrrYr)r+r�r?r-r!�rr�Ztest_valZret_valZret_typerrr�test_queryvalueex_return_valueWs��z/LocalWinregTests.test_queryvalueex_return_valuec	Cs�zIttt��,}|�|jd�d}t|ddt|�t|d�\}}|�|t�|�||�Wd�n1s5wYWt	tt�dSWt	tt�dSt	tt�w)Nrr�)
r4rrrYr)r+�
REG_BINARYr?r-r!r�rrr�#test_setvalueex_crash_with_none_argg���z4LocalWinregTests.test_setvalueex_crash_with_none_argc	Cs�zIttt��,}|�|jd�d}t|ddt|�t|d�\}}|�|t�|�|d�Wd�n1s5wYWt	tt�dSWt	tt�dSt	tt�w)NrzA string with a nullr�zA string)
r4rrrYr)r+r'r?r-r!r�rrr� test_read_string_containing_nulltr�z1LocalWinregTests.test_read_string_containing_nullN)rKrLrMrOrUrVr\r_rerfrxrzr~�unittest�
skipUnless�WIN_VERr�r�r�r�r�rrrrrN�s"	 

rNzSkipping remote registry testsc@seZdZdd�ZdS)�RemoteWinregTestscCsttt�}|�|�dSr)rW�REMOTE_NAMErrE)rZ
remote_keyrrr�test_remote_registry_works�s
z,RemoteWinregTests.test_remote_registry_worksN)rKrLrMr�rrrrr��sr�zx64 specific registry testsc@s^eZdZdd�Ze�e�dvd�dd��Ze�e	d�dd	��Z
e�e	d�d
d��Zdd
�ZdS)�Win64WinregTestscCs |�tt�ttttdd�dS)Nr)r5r$rGrF)rJrrr�rrrrrrV�s
�z%Win64WinregTests.test_named_arguments)ZWindowsCoreHeadlessZ	IoTEdgeOSz)APIs not available on WindowsCoreHeadlesscCshttd��%}|�t|��|�t|��|�t|��|�t|��Wd�dS1s-wYdS)NZSoftware)rrXr(r�ZassertIsNoner�r�)rr5rrr�test_reflection_functions�s"�z*Win64WinregTests.test_reflection_functionszOS doesn't support reflectioncCs�z�tttdttB��A}|�|jd�tttdttB��}|�|jd�Wd�n1s-wYt|ddt	d�dd�}|�
t|�Wd�n1sNwYtttdttB�� }|�|jd�|�
dt|d��t|ddt	d�Wd�n1swYtttdttB��}|�
dt|d��Wd�n1s�wYWttttd�dSWttttd�dSttttd�w)NrrZ32KEYcS�tttdttB�Sr)rr�test_reflect_key_namerT�KEY_WOW64_64KEYrrrrrR���z2Win64WinregTests.test_reflection.<locals>.<lambda>Z64KEY)rHrr�r�KEY_WOW64_32KEYrYr)rr+r'r]rr�r-r=rTr�)r�created_keyr5�	open_failrrr�test_reflection�sN������
������z Win64WinregTests.test_reflectioncCs�zstttdttB��$}t|�}|�t|�t�|�	|�t
|�|�t|��Wd�n1s1wYdd�}|�t
|�tttdttB��}|�|jd�Wd�n1s[wYWttttd�dSWttttd�dSttttd�w)NrcSr�r)rIrr�rTr�rrrrrR�r�z:Win64WinregTests.test_disable_reflection.<locals>.<lambda>)rHrr�rr�r�r-r`�boolZassertFalser�r(r]rrIrTrYr)r�)rr��disabledr�r5rrr�test_disable_reflection�s8�
�
������z(Win64WinregTests.test_disable_reflectioncCs:|�t��}ttd�Wd�dS1swYdS)NZsome_value_that_does_not_exist)r]�FileNotFoundErrorr=ZHKEY_CLASSES_ROOT)r�ctxrrr�test_exception_numbers�s"�z'Win64WinregTests.test_exception_numbersN)
rKrLrMrVr�ZskipIfrr�r��HAS_REFLECTIONr�r�r�rrrrr��s




+
r��__main__z)Remote registry calls can be tested usingz('test_winreg.py --remote \\machine_name'))rb�sysr{r�Ztest.supportrrl�platformrr�
import_moduler�argvrAr��
IndexError�
ValueErrorZgetwindowsversionr�Z
WIN64_MACHINEr��getpidZ
test_key_baserr�r�Z	REG_QWORDr'Z
REG_EXPAND_SZZREG_MULTI_SZr�r*ZTestCaserrNr�r�r�rK�print�mainrrrr�<module>sX��
9
b��
© 2025 GrazzMean