]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
adding passing test. testing for g(*Nothing()) where Nothing is a user-defined iterator.
authorSamuele Pedroni <pedronis@openend.se>
Sat, 21 Feb 2004 20:58:04 +0000 (20:58 +0000)
committerSamuele Pedroni <pedronis@openend.se>
Sat, 21 Feb 2004 20:58:04 +0000 (20:58 +0000)
Lib/test/output/test_extcall
Lib/test/test_extcall.py

index ddb2be50fe81d289206f503eaed26adf63bc2ff9..c9d70ccad09b0a41a56f5e618da5cef08baa3756 100644 (file)
@@ -17,6 +17,7 @@ TypeError: g() takes at least 1 argument (0 given)
 1 (2, 3) {}
 1 (2, 3, 4, 5) {}
 0 (1, 2) {}
+0 (1, 2, 3) {}
 1 () {'a': 1, 'b': 2, 'c': 3, 'd': 4}
 {'a': 1, 'b': 2, 'c': 3}
 {'a': 1, 'b': 2, 'c': 3}
index 1e80387cf4acb0ae0882802fa2d3cfaafac1650f..21fa281c96dba7d73e324056bf50ad5478b7efbd 100644 (file)
@@ -75,6 +75,31 @@ class Nothing:
             raise IndexError, i
 g(*Nothing())
 
+class Nothing:
+    def __init__(self):
+        self.c = 0
+    def __iter__(self):
+        return self
+try:
+    g(*Nothing())
+except TypeError, attr:
+    pass
+else:
+    print "should raise TypeError"
+
+class Nothing:
+    def __init__(self):
+        self.c = 0
+    def __iter__(self):
+        return self
+    def next(self):
+        if self.c == 4:
+            raise StopIteration
+        c = self.c
+        self.c += 1
+        return c
+g(*Nothing())
+
 # make sure the function call doesn't stomp on the dictionary?
 d = {'a': 1, 'b': 2, 'c': 3}
 d2 = d.copy()