[pypy-commit] pypy default: failing test
hakanardo
noreply at buildbot.pypy.org
Thu Aug 15 16:58:57 CEST 2013
Author: Hakan Ardo <hakan at debian.org>
Branch:
Changeset: r66162:6e2656749ce4
Date: 2013-08-15 16:56 +0200
http://bitbucket.org/pypy/pypy/changeset/6e2656749ce4/
Log: failing test
diff --git a/pypy/module/array/test/test_array.py b/pypy/module/array/test/test_array.py
--- a/pypy/module/array/test/test_array.py
+++ b/pypy/module/array/test/test_array.py
@@ -874,6 +874,70 @@
assert l
assert l[0] is None or len(l[0]) == 0
+ def test_assign_object_with_special_methods(self):
+ from array import array
+
+ class Num(object):
+ def __float__(self):
+ return 5.25
+
+ def __int__(self):
+ return 7
+
+ class NotNum(object):
+ pass
+
+ class Silly(object):
+ def __float__(self):
+ return None
+
+ def __int__(self):
+ return None
+
+ class OldNum:
+ def __float__(self):
+ return 6.25
+
+ def __int__(self):
+ return 8
+
+ class OldNotNum:
+ pass
+
+ class OldSilly:
+ def __float__(self):
+ return None
+
+ def __int__(self):
+ return None
+
+ for tc in 'bBhHiIlL':
+ a = array(tc, [0])
+ raises(TypeError, a.__setitem__, 0, 1.0)
+ a[0] = 1
+ a[0] = Num()
+ assert a[0] == 7
+ raises(TypeError, a.__setitem__, NotNum())
+ a[0] = OldNum()
+ assert a[0] == 8
+ raises(TypeError, a.__setitem__, OldNotNum())
+ raises(TypeError, a.__setitem__, Silly())
+ raises(TypeError, a.__setitem__, OldSilly())
+
+ for tc in 'fd':
+ a = array(tc, [0])
+ a[0] = 1.0
+ a[0] = 1
+ a[0] = Num()
+ assert a[0] == 5.25
+ raises(TypeError, a.__setitem__, NotNum())
+ a[0] = OldNum()
+ assert a[0] == 6.25
+ raises(TypeError, a.__setitem__, OldNotNum())
+ raises(TypeError, a.__setitem__, Silly())
+ raises(TypeError, a.__setitem__, OldSilly())
+
+
class TestCPythonsOwnArray(BaseArrayTests):
More information about the pypy-commit
mailing list