From 12b22ff6d70cde60c49721f1ba8b88f47a9b4343 Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Tue, 9 Oct 2001 20:36:44 +0000 Subject: [PATCH] Add a bunch of tests for a list subclass that would have caught the previous embarrassment (typeobject.c checking crashing minidom). --- Lib/test/test_descr.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/Lib/test/test_descr.py b/Lib/test/test_descr.py index 5f0bb962962..50e7d9db902 100644 --- a/Lib/test/test_descr.py +++ b/Lib/test/test_descr.py @@ -1766,6 +1766,28 @@ def rev(self): 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().