MCPcopy Index your code
hub / github.com/python/cpython / test_mixed_add

Method test_mixed_add

Lib/test/test_userlist.py:51–80  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

49 self.assertEqual(u[:],u)
50
51 def test_mixed_add(self):
52 for t in UserList, list, str, tuple, iter:
53 with self.subTest(t.__name__):
54 u = UserList("spam") + t("eggs")
55 self.assertEqual(u, list("spameggs"))
56 self.assertIs(type(u), UserList)
57
58 u = t("spam") + UserList("eggs")
59 self.assertEqual(u, list("spameggs"))
60 self.assertIs(type(u), UserList)
61
62 u = UserList("spam") + UserListSubclass("eggs")
63 self.assertEqual(u, list("spameggs"))
64 self.assertIs(type(u), UserList)
65
66 u = UserListSubclass("spam") + UserList("eggs")
67 self.assertEqual(u, list("spameggs"))
68 self.assertIs(type(u), UserListSubclass)
69
70 u = UserListSubclass("spam") + UserListSubclass2("eggs")
71 self.assertEqual(u, list("spameggs"))
72 self.assertIs(type(u), UserListSubclass)
73
74 u2 = UserList("eggs").__radd__(UserList("spam"))
75 self.assertEqual(u2, list("spameggs"))
76 self.assertIs(type(u), UserListSubclass)
77
78 u2 = UserListSubclass("eggs").__radd__(UserListSubclass2("spam"))
79 self.assertEqual(u2, list("spameggs"))
80 self.assertIs(type(u), UserListSubclass)
81
82 def test_mixed_iadd(self):
83 for t in UserList, list, str, tuple, iter:

Callers

nothing calls this directly

Calls 9

UserListClass · 0.90
tFunction · 0.85
listClass · 0.85
UserListSubclassClass · 0.85
UserListSubclass2Class · 0.85
subTestMethod · 0.45
assertEqualMethod · 0.45
assertIsMethod · 0.45
__radd__Method · 0.45

Tested by

no test coverage detected