mirror of
https://github.com/python/cpython.git
synced 2026-01-06 15:32:22 +00:00
Userlist.copy() wasn't returning a UserList.
This commit is contained in:
parent
7b48432a77
commit
1c7b7f7fbe
2 changed files with 7 additions and 1 deletions
|
|
@ -887,7 +887,7 @@ def insert(self, i, item): self.data.insert(i, item)
|
|||
def pop(self, i=-1): return self.data.pop(i)
|
||||
def remove(self, item): self.data.remove(item)
|
||||
def clear(self): self.data.clear()
|
||||
def copy(self): return self.data.copy()
|
||||
def copy(self): return self.__class__(self)
|
||||
def count(self, item): return self.data.count(item)
|
||||
def index(self, item, *args): return self.data.index(item, *args)
|
||||
def reverse(self): self.data.reverse()
|
||||
|
|
|
|||
|
|
@ -52,6 +52,12 @@ def __getitem__(self, key):
|
|||
return str(key) + '!!!'
|
||||
self.assertEqual(next(iter(T((1,2)))), "0!!!")
|
||||
|
||||
def test_userlist_copy(self):
|
||||
u = self.type2test([6, 8, 1, 9, 1])
|
||||
v = u.copy()
|
||||
self.assertEqual(u, v)
|
||||
self.assertEqual(type(u), type(v))
|
||||
|
||||
def test_main():
|
||||
support.run_unittest(UserListTest)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue