def METHOD_NAME(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])