MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_changing_value

Method test_changing_value

Lib/test/test_winreg.py:263–293  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

261 self.assertEqual(h.handle, 0)
262
263 def test_changing_value(self):
264 # Issue2810: A race condition in 2.6 and 3.1 may cause
265 # EnumValue or QueryValue to raise "WindowsError: More data is
266 # available"
267 done = False
268
269 class VeryActiveThread(threading.Thread):
270 def run(self):
271 with CreateKey(HKEY_CURRENT_USER, test_key_name) as key:
272 use_short = True
273 long_string = 'x'*2000
274 while not done:
275 s = 'x' if use_short else long_string
276 use_short = not use_short
277 SetValue(key, 'changing_value', REG_SZ, s)
278
279 thread = VeryActiveThread()
280 thread.start()
281 try:
282 with CreateKey(HKEY_CURRENT_USER,
283 test_key_name+'\\changing_value') as key:
284 for _ in range(1000):
285 num_subkeys, num_values, t = QueryInfoKey(key)
286 for i in range(num_values):
287 name = EnumValue(key, i)
288 QueryValue(key, name[0])
289 finally:
290 done = True
291 thread.join()
292 DeleteKey(HKEY_CURRENT_USER, test_key_name+'\\changing_value')
293 DeleteKey(HKEY_CURRENT_USER, test_key_name)
294
295 def test_queryvalueex_race_condition(self):
296 # gh-142282: QueryValueEx could read garbage buffer under race

Callers

nothing calls this directly

Calls 8

VeryActiveThreadClass · 0.85
CreateKeyFunction · 0.85
QueryInfoKeyFunction · 0.85
EnumValueFunction · 0.85
QueryValueFunction · 0.85
DeleteKeyFunction · 0.85
startMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected