code: def _write_test_data(
      self, root_key, subkeystr="sub_key", CreateKey=CreateKey
  ):
      # Set the default value for this key.
      SetValue(root_key, test_key_name, REG_SZ, "Default value")
      key = CreateKey(root_key, test_key_name)
      self.assertTrue(key.handle != 0)
      # Create a sub-key
      sub_key = CreateKey(key, subkeystr)
      # Give the sub-key some named values
  
      for value_name, value_data, value_type in test_data:
          SetValueEx(sub_key, value_name, 0, value_type, value_data)
  
      # Check we wrote as many items as we thought.
      nkeys, nvalues, since_mod = QueryInfoKey(key)
      self.assertEqual(nkeys, 1, "Not the correct number of sub keys")
      self.assertEqual(nvalues, 1, "Not the correct number of values")
      nkeys, nvalues, since_mod = QueryInfoKey(sub_key)
      self.assertEqual(nkeys, 0, "Not the correct number of sub keys")
      self.assertEqual(
          nvalues, len(test_data), "Not the correct number of values"
      )
      # Close this key this way...
      # (but before we do, copy the key as an integer - this allows
      # us to test that the key really gets closed).
      int_sub_key = int(sub_key)
      CloseKey(sub_key)
      try:
          QueryInfoKey(int_sub_key)
          self.fail(
              "It appears the CloseKey() function does "
              "not close the actual key!"
          )
      except OSError:
          pass
      # ... and close that key that way :-)
      int_key = int(key)
      key.Close()
      try:
          QueryInfoKey(int_key)
          self.fail(
              "It appears the key.Close() function "
              "does not close the actual key!"
          )
      except OSError:
          pass
  
imports: import gc
  import os, sys, errno
  import threading
  import unittest
  from platform import machine, win32_edition
  from test.support import cpython_only, import_helper
  from winreg import *
label_desc: Use image node_id 3 for calling the BaseWinregTests obj's underlying member method code with example usage: obj._write_test_data(root_key, subkeystr, CreateKey) without return types