Userlist.copy() wasn't returning a UserList.

This commit is contained in:
Raymond Hettinger 2011-05-05 14:34:35 -07:00
parent 7b48432a77
commit 1c7b7f7fbe
2 changed files with 7 additions and 1 deletions

View file

@ -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()

View file

@ -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)