(self)
| 308 | @support.impl_detail("the module 'xxsubtype' is internal") |
| 309 | @unittest.skipIf(xxsubtype is None, "requires xxsubtype module") |
| 310 | def test_spam_lists(self): |
| 311 | # Testing spamlist operations... |
| 312 | import copy, xxsubtype as spam |
| 313 | |
| 314 | def spamlist(l, memo=None): |
| 315 | import xxsubtype as spam |
| 316 | return spam.spamlist(l) |
| 317 | |
| 318 | # This is an ugly hack: |
| 319 | copy._deepcopy_dispatch[spam.spamlist] = spamlist |
| 320 | |
| 321 | self.binop_test(spamlist([1]), spamlist([2]), spamlist([1,2]), "a+b", |
| 322 | "__add__") |
| 323 | self.binop_test(spamlist([1,2,3]), 2, 1, "b in a", "__contains__") |
| 324 | self.binop_test(spamlist([1,2,3]), 4, 0, "b in a", "__contains__") |
| 325 | self.binop_test(spamlist([1,2,3]), 1, 2, "a[b]", "__getitem__") |
| 326 | self.sliceop_test(spamlist([1,2,3]), 0, 2, spamlist([1,2]), "a[b:c]", |
| 327 | "__getitem__") |
| 328 | self.setop_test(spamlist([1]), spamlist([2]), spamlist([1,2]), "a+=b", |
| 329 | "__iadd__") |
| 330 | self.setop_test(spamlist([1,2]), 3, spamlist([1,2,1,2,1,2]), "a*=b", |
| 331 | "__imul__") |
| 332 | self.unop_test(spamlist([1,2,3]), 3, "len(a)", "__len__") |
| 333 | self.binop_test(spamlist([1,2]), 3, spamlist([1,2,1,2,1,2]), "a*b", |
| 334 | "__mul__") |
| 335 | self.binop_test(spamlist([1,2]), 3, spamlist([1,2,1,2,1,2]), "b*a", |
| 336 | "__rmul__") |
| 337 | self.set2op_test(spamlist([1,2]), 1, 3, spamlist([1,3]), "a[b]=c", |
| 338 | "__setitem__") |
| 339 | self.setsliceop_test(spamlist([1,2,3,4]), 1, 3, spamlist([5,6]), |
| 340 | spamlist([1,5,6,4]), "a[b:c]=d", "__setitem__") |
| 341 | # Test subclassing |
| 342 | class C(spam.spamlist): |
| 343 | def foo(self): return 1 |
| 344 | a = C() |
| 345 | self.assertEqual(a, []) |
| 346 | self.assertEqual(a.foo(), 1) |
| 347 | a.append(100) |
| 348 | self.assertEqual(a, [100]) |
| 349 | self.assertEqual(a.getstate(), 0) |
| 350 | a.setstate(42) |
| 351 | self.assertEqual(a.getstate(), 42) |
| 352 | |
| 353 | @support.impl_detail("the module 'xxsubtype' is internal") |
| 354 | @unittest.skipIf(xxsubtype is None, "requires xxsubtype module") |
nothing calls this directly
no test coverage detected