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

Method test_remove

Lib/test/test_bytes.py:1872–1894  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1870 a.extend, 1.0)
1871
1872 def test_remove(self):
1873 b = bytearray(b'hello')
1874 b.remove(ord('l'))
1875 self.assertEqual(b, b'helo')
1876 b.remove(ord('l'))
1877 self.assertEqual(b, b'heo')
1878 self.assertRaises(ValueError, lambda: b.remove(ord('l')))
1879 self.assertRaises(ValueError, lambda: b.remove(400))
1880 self.assertRaises(TypeError, lambda: b.remove('e'))
1881 # remove first and last
1882 b.remove(ord('o'))
1883 b.remove(ord('h'))
1884 self.assertEqual(b, b'e')
1885 self.assertRaises(TypeError, lambda: b.remove(b'e'))
1886 b.remove(Indexable(ord('e')))
1887 self.assertEqual(b, b'')
1888
1889 # test values outside of the ascii range: (0, 127)
1890 c = bytearray([126, 127, 128, 129])
1891 c.remove(127)
1892 self.assertEqual(c, bytes([126, 128, 129]))
1893 c.remove(129)
1894 self.assertEqual(c, bytes([126, 128]))
1895
1896 def test_pop(self):
1897 b = bytearray(b'world')

Callers

nothing calls this directly

Calls 4

IndexableClass · 0.70
removeMethod · 0.45
assertEqualMethod · 0.45
assertRaisesMethod · 0.45

Tested by

no test coverage detected