Skip to content

Commit

Permalink
Fix some errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
serhiy-storchaka committed Jul 25, 2023
1 parent d553110 commit 5c0ce18
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Lib/test/test_bytes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1354,7 +1354,7 @@ def do_tests(setitem):
except ValueError:
pass
try:
setitem(b, 0, None)
setitem(b, 0, object())
self.fail("Didn't raise TypeError")
except TypeError:
pass
Expand Down
16 changes: 8 additions & 8 deletions Lib/test/test_capi/test_abstract.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,13 +236,13 @@ def test_object_getitem(self):
self.assertEqual(getitem(dct, '\U0001f40d'), 2)

dct2 = ProxyGetItem(dct)
self.assertEqual(getitem(dct, 'a'), 1)
self.assertRaises(KeyError, getitem, dct, 'b')
self.assertEqual(getitem(dct2, 'a'), 1)
self.assertRaises(KeyError, getitem, dct2, 'b')

self.assertEqual(getitem(['a', 'b', 'c'], 1), 'b')

self.assertRaises(TypeError, getitem, 42, 'a')
self.assertRaises(TypeError, getitem, {}, [])
self.assertRaises(TypeError, getitem, {}, []) # unhashable
self.assertRaises(SystemError, getitem, {}, NULL)
self.assertRaises(IndexError, getitem, [], 1)
self.assertRaises(TypeError, getitem, [], 'a')
Expand Down Expand Up @@ -279,7 +279,7 @@ def test_mapping_haskey(self):
self.assertTrue(haskey(['a', 'b', 'c'], 1))

self.assertFalse(haskey(42, 'a'))
self.assertFalse(haskey({}, []))
self.assertFalse(haskey({}, [])) # unhashable
self.assertFalse(haskey({}, NULL))
self.assertFalse(haskey([], 1))
self.assertFalse(haskey([], 'a'))
Expand Down Expand Up @@ -320,7 +320,7 @@ def test_object_setitem(self):
self.assertEqual(lst, ['a', 'x', 'c'])

self.assertRaises(TypeError, setitem, 42, 'a', 5)
self.assertRaises(TypeError, setitem, {}, [], 5)
self.assertRaises(TypeError, setitem, {}, [], 5) # unhashable
self.assertRaises(SystemError, setitem, {}, NULL, 5)
self.assertRaises(SystemError, setitem, {}, 'a', NULL)
self.assertRaises(IndexError, setitem, [], 1, 5)
Expand Down Expand Up @@ -361,14 +361,14 @@ def test_object_delitem(self):
dct2 = ProxyDelItem(dct)
delitem(dct2, 'a')
self.assertEqual(dct, {'c': 2})
self.assertRaises(KeyError, delitem, dct, 'b')
self.assertRaises(KeyError, delitem, dct2, 'b')

lst = ['a', 'b', 'c']
delitem(lst, 1)
self.assertEqual(lst, ['a', 'c'])

self.assertRaises(TypeError, delitem, 42, 'a')
self.assertRaises(TypeError, delitem, {}, [])
self.assertRaises(TypeError, delitem, {}, []) # unhashable
self.assertRaises(SystemError, delitem, {}, NULL)
self.assertRaises(IndexError, delitem, [], 1)
self.assertRaises(TypeError, delitem, [], 'a')
Expand All @@ -387,7 +387,7 @@ def test_mapping_delitemstring(self):
dct2 = ProxyDelItem(dct)
delitemstring(dct2, b'a')
self.assertEqual(dct, {'c': 2})
self.assertRaises(KeyError, delitemstring, dct, b'b')
self.assertRaises(KeyError, delitemstring, dct2, b'b')

self.assertRaises(TypeError, delitemstring, 42, b'a')
self.assertRaises(UnicodeDecodeError, delitemstring, {}, b'\xff')
Expand Down

0 comments on commit 5c0ce18

Please sign in to comment.