additional test case
authorStefan Behnel <scoder@users.berlios.de>
Thu, 2 Dec 2010 07:03:14 +0000 (08:03 +0100)
committerStefan Behnel <scoder@users.berlios.de>
Thu, 2 Dec 2010 07:03:14 +0000 (08:03 +0100)
tests/run/set.pyx

index 074345207e58af3cbd066ee8a695b2df735cc8c2..41b50d8cd51d9f8fe4c3c8cad6b1c5babd055082 100644 (file)
@@ -105,6 +105,24 @@ def test_set_discard():
     s1.discard(3)
     return s1
 
+def test_set_sideeffect_unhashable_failure():
+    """
+    >>> test_set_sideeffect_unhashable_failure()
+    [2, 4, 5]
+    """
+    L = []
+    def sideeffect(x):
+        L.append(x)
+        return x
+    def unhashable_value(x):
+        L.append(x)
+        return set()
+    try:
+        s = set([1,sideeffect(2),3,unhashable_value(4),sideeffect(5)])
+    except TypeError: pass
+    else: assert False, "expected exception not raised"
+    return L
+
 def sorted(it):
     # Py3 can't compare strings to ints
     chars = []