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

Method test_keyencoding

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 3

assertInMethod · 0.95
assertRaisesMethod · 0.95
encodeMethod · 0.45

Tested by

no test coverage detected