1 # Check every path through every method of UserList
3 from UserList
import UserList
4 from test
import test_support
, list_tests
6 class UserListTest(list_tests
.CommonTest
):
9 def test_getslice(self
):
10 super(UserListTest
, self
).test_getslice()
13 for i
in range(-3, 6):
14 self
.assertEqual(u
[:i
], l
[:i
])
15 self
.assertEqual(u
[i
:], l
[i
:])
16 for j
in xrange(-3, 6):
17 self
.assertEqual(u
[i
:j
], l
[i
:j
])
19 def test_add_specials(self
):
22 self
.assertEqual(u2
, list("spameggs"))
24 def test_radd_specials(self
):
27 self
.assertEqual(u2
, list("spameggs"))
28 u2
= u
.__radd
__(UserList("spam"))
29 self
.assertEqual(u2
, list("spameggs"))
32 super(UserListTest
, self
).test_iadd()
35 self
.assertEqual(u
, [0, 1, 0, 1])
37 def test_mixedcmp(self
):
38 u
= self
.type2test([0, 1])
39 self
.assertEqual(u
, [0, 1])
40 self
.assertNotEqual(u
, [0])
41 self
.assertNotEqual(u
, [0, 2])
43 def test_mixedadd(self
):
44 u
= self
.type2test([0, 1])
45 self
.assertEqual(u
+ [], u
)
46 self
.assertEqual(u
+ [2], [0, 1, 2])
48 def test_getitemoverwriteiter(self
):
49 # Verify that __getitem__ overrides *are* recognized by __iter__
50 class T(self
.type2test
):
51 def __getitem__(self
, key
):
52 return str(key
) + '!!!'
53 self
.assertEqual(iter(T((1,2))).next(), "0!!!")
56 with test_support
.check_py3k_warnings(
57 (".+__(get|set|del)slice__ has been removed", DeprecationWarning)):
58 test_support
.run_unittest(UserListTest
)
60 if __name__
== "__main__":