code: def test_keyencoding(self):
      d = {}
      key = "PÃ¶p"
      # the default keyencoding is utf-8
      shelve.Shelf(d)[key] = [1]
      self.assertIn(key.encode("utf-8"), d)
      # but a different one can be given
      shelve.Shelf(d, keyencoding="latin-1")[key] = [1]
      self.assertIn(key.encode("latin-1"), d)
      # with all consequences
      s = shelve.Shelf(d, keyencoding="ascii")
      self.assertRaises(UnicodeEncodeError, s.__setitem__, key, [1])
  
imports: import unittest
  import dbm
  import shelve
  import pickle
  import os
  from test.support import os_helper
  from collections.abc import MutableMapping
  from test.test_dbm import dbm_iterator
  from test import mapping_tests
label_desc: Use image node_id 11 for calling the TestCase obj's underlying member method code with example usage: obj.test_keyencoding() without return types