Permalink
Browse files

Add a test for tuple subclass + PySequence_Length

  • Loading branch information...
1 parent d37ea37 commit dd556c8cdbd4568a14a6dc0b8b9dda2b3a2bc508 @snaury snaury committed Jun 13, 2012
Showing with 14 additions and 0 deletions.
  1. +14 −0 tests/test_greenlet.py
View
@@ -431,3 +431,17 @@ def initiator():
value = initiator.switch()
self.assertTrue(seen)
self.assertEqual(value, 42)
+
+ if sys.version_info[0] == 2:
+ # There's no apply in Python 3.x
+ def test_tuple_subclass(self):
+ class mytuple(tuple):
+ def __len__(self):
+ greenlet.getcurrent().switch()
+ return tuple.__len__(self)
+ args = mytuple()
+ kwargs = dict(a=42)
+ def switchapply():
+ apply(greenlet.getcurrent().parent.switch, args, kwargs)
+ g = greenlet(switchapply)
+ self.assertEqual(g.switch(), kwargs)

0 comments on commit dd556c8

Please sign in to comment.