MCPcopy Index your code
hub / github.com/python/cpython / _read_test_data

Method _read_test_data

Lib/test/test_winreg.py:129–167  ·  view source on GitHub ↗
(self, root_key, subkeystr="sub_key", OpenKey=OpenKey)

Source from the content-addressed store, hash-verified

127 except OSError:
128 pass
129 def _read_test_data(self, root_key, subkeystr="sub_key", OpenKey=OpenKey):
130 # Check we can get default value for this key.
131 val = QueryValue(root_key, test_key_name)
132 self.assertEqual(val, "Default value",
133 "Registry didn't give back the correct value")
134
135 key = OpenKey(root_key, test_key_name)
136 # Read the sub-keys
137 with OpenKey(key, subkeystr) as sub_key:
138 # Check I can enumerate over the values.
139 index = 0
140 while 1:
141 try:
142 data = EnumValue(sub_key, index)
143 except OSError:
144 break
145 self.assertEqual(data in test_data, True,
146 "Didn't read back the correct test data")
147 index = index + 1
148 self.assertEqual(index, len(test_data),
149 "Didn't read the correct number of items")
150 # Check I can directly access each item
151 for value_name, value_data, value_type in test_data:
152 read_val, read_typ = QueryValueEx(sub_key, value_name)
153 self.assertEqual(read_val, value_data,
154 "Could not directly read the value")
155 self.assertEqual(read_typ, value_type,
156 "Could not directly read the value")
157 sub_key.Close()
158 # Enumerate our main key.
159 read_val = EnumKey(key, 0)
160 self.assertEqual(read_val, subkeystr, "Read subkey value wrong")
161 try:
162 EnumKey(key, 1)
163 self.fail("Was able to get a second key when I only have one!")
164 except OSError:
165 pass
166
167 key.Close()
168
169 def _delete_test_data(self, root_key, subkeystr="sub_key"):
170 key = OpenKey(root_key, test_key_name, 0, KEY_ALL_ACCESS)

Callers 2

_test_allMethod · 0.95

Calls 3

CloseMethod · 0.80
assertEqualMethod · 0.45
failMethod · 0.45

Tested by

no test coverage detected