mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
Add a bunch of tests for a list subclass that would have caught the
previous embarrassment (typeobject.c checking crashing minidom).
This commit is contained in:
parent
fd38f8e638
commit
12b22ff6d7
1 changed files with 22 additions and 0 deletions
|
@ -1766,6 +1766,28 @@ def inherits():
|
|||
verify(u[0:0].__class__ is unicode)
|
||||
vereq(u[0:0], u"")
|
||||
|
||||
class sublist(list):
|
||||
pass
|
||||
a = sublist(range(5))
|
||||
vereq(a, range(5))
|
||||
a.append("hello")
|
||||
vereq(a, range(5) + ["hello"])
|
||||
a[5] = 5
|
||||
vereq(a, range(6))
|
||||
a.extend(range(6, 20))
|
||||
vereq(a, range(20))
|
||||
a[-5:] = []
|
||||
vereq(a, range(15))
|
||||
del a[10:15]
|
||||
vereq(len(a), 10)
|
||||
vereq(a, range(10))
|
||||
vereq(list(a), range(10))
|
||||
vereq(a[0], 0)
|
||||
vereq(a[9], 9)
|
||||
vereq(a[-10], 0)
|
||||
vereq(a[-1], 9)
|
||||
vereq(a[:5], range(5))
|
||||
|
||||
class CountedInput(file):
|
||||
"""Counts lines read by self.readline().
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue