mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
bpo-27639: Correct return type for UserList slicing operation (#13169)
* BPO-27639: Correct return type for UserList slicing operation Added logic to __getitem__ magic method for UserList to ensure that the return type matches that of self.
This commit is contained in:
parent
ca87eebb22
commit
b1c3167c23
3 changed files with 13 additions and 1 deletions
|
@ -17,6 +17,12 @@ class UserListTest(list_tests.CommonTest):
|
|||
for j in range(-3, 6):
|
||||
self.assertEqual(u[i:j], l[i:j])
|
||||
|
||||
def test_slice_type(self):
|
||||
l = [0, 1, 2, 3, 4]
|
||||
u = UserList(l)
|
||||
self.assertIsInstance(u[:], u.__class__)
|
||||
self.assertEqual(u[:],u)
|
||||
|
||||
def test_add_specials(self):
|
||||
u = UserList("spam")
|
||||
u2 = u + "eggs"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue