Skip to content

Commit 306e43d

Browse files
committed
Fix shelve tests for backend compatibility
1 parent 7636a66 commit 306e43d

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

Lib/test/test_shelve.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,8 @@ def test_custom_serializer_and_deserializer(self):
173173
def serializer(obj, protocol):
174174
if isinstance(obj, (bytes, bytearray, str)):
175175
if protocol == 5:
176+
if isinstance(obj, bytearray):
177+
return bytes(obj)
176178
return obj
177179
return type(obj).__name__
178180
elif isinstance(obj, array.array):
@@ -223,11 +225,10 @@ def deserializer(data):
223225
)
224226

225227
def test_custom_incomplete_serializer_and_deserializer(self):
226-
dbm_sqlite3 = import_helper.import_module("dbm.sqlite3")
227228
os.mkdir(self.dirname)
228229
self.addCleanup(os_helper.rmtree, self.dirname)
229230

230-
with self.assertRaises(dbm_sqlite3.error):
231+
with self.assertRaises((TypeError, dbm.error)):
231232
def serializer(obj, protocol=None):
232233
pass
233234

0 commit comments

Comments
 (0)