Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
f82d9b52
Kaydet (Commit)
f82d9b52
authored
Eyl 03, 2007
tarafından
Martin v. Löwis
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Patch #1076: Use wide API for registry functions.
üst
5d12abe0
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
13 deletions
+17
-13
test_winreg.py
Lib/test/test_winreg.py
+17
-13
_winreg.c
PC/_winreg.c
+0
-0
No files found.
Lib/test/test_winreg.py
Dosyayı görüntüle @
f82d9b52
# -*- coding: utf-8 -*-
# Test the windows specific win32reg module.
# Only win32reg functions not hit here: FlushKey, LoadKey and SaveKey
...
...
@@ -17,17 +18,19 @@ test_data = [
(
"Raw Data"
,
b
"binary
\x00
data"
,
REG_BINARY
),
(
"Big String"
,
"x"
*
(
2
**
14
-
1
),
REG_SZ
),
(
"Big Binary"
,
b
"x"
*
(
2
**
14
),
REG_BINARY
),
# Two and three kanjis, meaning: "Japan" and "Japanese")
(
"Japanese 日本"
,
"日本語"
,
REG_SZ
),
]
class
WinregTests
(
unittest
.
TestCase
):
remote_name
=
None
def
WriteTestData
(
self
,
root_key
):
def
WriteTestData
(
self
,
root_key
,
subkeystr
=
"sub_key"
):
# Set the default value for this key.
SetValue
(
root_key
,
test_key_name
,
REG_SZ
,
"Default value"
)
key
=
CreateKey
(
root_key
,
test_key_name
)
# Create a sub-key
sub_key
=
CreateKey
(
key
,
"sub_key"
)
sub_key
=
CreateKey
(
key
,
subkeystr
)
# Give the sub-key some named values
for
value_name
,
value_data
,
value_type
in
test_data
:
...
...
@@ -62,7 +65,7 @@ class WinregTests(unittest.TestCase):
except
EnvironmentError
:
pass
def
ReadTestData
(
self
,
root_key
):
def
ReadTestData
(
self
,
root_key
,
subkeystr
=
"sub_key"
):
# Check we can get default value for this key.
val
=
QueryValue
(
root_key
,
test_key_name
)
self
.
assertEquals
(
val
,
"Default value"
,
...
...
@@ -70,7 +73,7 @@ class WinregTests(unittest.TestCase):
key
=
OpenKey
(
root_key
,
test_key_name
)
# Read the sub-keys
sub_key
=
OpenKey
(
key
,
"sub_key"
)
sub_key
=
OpenKey
(
key
,
subkeystr
)
# Check I can enumerate over the values.
index
=
0
while
1
:
...
...
@@ -93,7 +96,7 @@ class WinregTests(unittest.TestCase):
sub_key
.
Close
()
# Enumerate our main key.
read_val
=
EnumKey
(
key
,
0
)
self
.
assertEquals
(
read_val
,
"sub_key"
,
"Read subkey value wrong"
)
self
.
assertEquals
(
read_val
,
subkeystr
,
"Read subkey value wrong"
)
try
:
EnumKey
(
key
,
1
)
self
.
fail
(
"Was able to get a second key when I only have one!"
)
...
...
@@ -102,9 +105,9 @@ class WinregTests(unittest.TestCase):
key
.
Close
()
def
DeleteTestData
(
self
,
root_key
):
def
DeleteTestData
(
self
,
root_key
,
subkeystr
=
"sub_key"
):
key
=
OpenKey
(
root_key
,
test_key_name
,
0
,
KEY_ALL_ACCESS
)
sub_key
=
OpenKey
(
key
,
"sub_key"
,
0
,
KEY_ALL_ACCESS
)
sub_key
=
OpenKey
(
key
,
subkeystr
,
0
,
KEY_ALL_ACCESS
)
# It is not necessary to delete the values before deleting
# the key (although subkeys must not exist). We delete them
# manually just to prove we can :-)
...
...
@@ -115,11 +118,11 @@ class WinregTests(unittest.TestCase):
self
.
assertEquals
(
nkeys
,
0
,
"subkey not empty before delete"
)
self
.
assertEquals
(
nvalues
,
0
,
"subkey not empty before delete"
)
sub_key
.
Close
()
DeleteKey
(
key
,
"sub_key"
)
DeleteKey
(
key
,
subkeystr
)
try
:
# Shouldnt be able to delete it twice!
DeleteKey
(
key
,
"sub_key"
)
DeleteKey
(
key
,
subkeystr
)
self
.
fail
(
"Deleting the key twice succeeded"
)
except
EnvironmentError
:
pass
...
...
@@ -132,13 +135,14 @@ class WinregTests(unittest.TestCase):
except
WindowsError
:
# Use this error name this time
pass
def
TestAll
(
self
,
root_key
):
self
.
WriteTestData
(
root_key
)
self
.
ReadTestData
(
root_key
)
self
.
DeleteTestData
(
root_key
)
def
TestAll
(
self
,
root_key
,
subkeystr
=
"sub_key"
):
self
.
WriteTestData
(
root_key
,
subkeystr
)
self
.
ReadTestData
(
root_key
,
subkeystr
)
self
.
DeleteTestData
(
root_key
,
subkeystr
)
def
testLocalMachineRegistryWorks
(
self
):
self
.
TestAll
(
HKEY_CURRENT_USER
)
self
.
TestAll
(
HKEY_CURRENT_USER
,
"日本-subkey"
)
def
testConnectRegistryToLocalMachineWorks
(
self
):
# perform minimal ConnectRegistry test which just invokes it
...
...
PC/_winreg.c
Dosyayı görüntüle @
f82d9b52
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment