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

Method test_keyencoding

Lib/test/test_shelve.py:126–137  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

124 self.assertEqual(len(d2), 1)
125
126 def test_keyencoding(self):
127 d = {}
128 key = 'Pöp'
129 # the default keyencoding is utf-8
130 shelve.Shelf(d)[key] = [1]
131 self.assertIn(key.encode('utf-8'), d)
132 # but a different one can be given
133 shelve.Shelf(d, keyencoding='latin-1')[key] = [1]
134 self.assertIn(key.encode('latin-1'), d)
135 # with all consequences
136 s = shelve.Shelf(d, keyencoding='ascii')
137 self.assertRaises(UnicodeEncodeError, s.__setitem__, key, [1])
138
139 def test_writeback_also_writes_immediately(self):
140 # Issue 5754

Callers

nothing calls this directly

Calls 3

assertInMethod · 0.95
assertRaisesMethod · 0.95
encodeMethod · 0.45

Tested by

no test coverage detected