[pypy-commit] pypy default: Add more tests. Skip this one test, because I found out that it's a problem
arigo
noreply at buildbot.pypy.org
Fri Aug 26 14:07:01 CEST 2011
Author: Armin Rigo <arigo at tunes.org>
Branch:
Changeset: r46788:e076c90b99d1
Date: 2011-08-26 14:12 +0200
http://bitbucket.org/pypy/pypy/changeset/e076c90b99d1/
Log: Add more tests. Skip this one test, because I found out that it's a
problem only with old-style classes, which behave differently than
new-style classes on CPython in this deep corner case.
diff --git a/pypy/module/__builtin__/test/test_classobj.py b/pypy/module/__builtin__/test/test_classobj.py
--- a/pypy/module/__builtin__/test/test_classobj.py
+++ b/pypy/module/__builtin__/test/test_classobj.py
@@ -982,6 +982,11 @@
raises(TypeError, descr.__delete__, a)
def test_eq_order(self):
+ # this gives the ordering of equality-related functions on top of
+ # CPython **for old-style classes**. This test passes on CPython2.7
+ # but fails on PyPy. If you run the same test with new-style classes,
+ # it fails on CPython too.
+ py.test.skip("far too obscure")
class A:
def __eq__(self, other): return True
def __ne__(self, other): return True
@@ -996,18 +1001,42 @@
def __le__(self, other): return False
def __gt__(self, other): return False
def __ge__(self, other): return False
+ #
assert A() == B()
assert A() != B()
assert A() < B()
assert A() <= B()
assert A() > B()
assert A() >= B()
+ #
assert not (B() == A())
assert not (B() != A())
assert not (B() < A())
assert not (B() <= A())
assert not (B() > A())
assert not (B() >= A())
+ #
+ class C(A):
+ def __eq__(self, other): return False
+ def __ne__(self, other): return False
+ def __lt__(self, other): return False
+ def __le__(self, other): return False
+ def __gt__(self, other): return False
+ def __ge__(self, other): return False
+ #
+ assert A() == C()
+ assert A() != C()
+ assert A() < C()
+ assert A() <= C()
+ assert A() > C()
+ assert A() >= C()
+ #
+ assert not (C() == A())
+ assert not (C() != A())
+ assert not (C() < A())
+ assert not (C() <= A())
+ assert not (C() > A())
+ assert not (C() >= A())
class AppTestOldStyleClassStrDict(object):
diff --git a/pypy/objspace/test/test_descroperation.py b/pypy/objspace/test/test_descroperation.py
--- a/pypy/objspace/test/test_descroperation.py
+++ b/pypy/objspace/test/test_descroperation.py
@@ -473,6 +473,58 @@
assert not(C(1) == D(2))
assert not(D(1) == C(2))
+ def test_eq_order(self):
+ class A(object):
+ def __eq__(self, other): return True
+ def __ne__(self, other): return True
+ def __lt__(self, other): return True
+ def __le__(self, other): return True
+ def __gt__(self, other): return True
+ def __ge__(self, other): return True
+ class B(object):
+ def __eq__(self, other): return False
+ def __ne__(self, other): return False
+ def __lt__(self, other): return False
+ def __le__(self, other): return False
+ def __gt__(self, other): return False
+ def __ge__(self, other): return False
+ #
+ assert A() == B()
+ assert A() != B()
+ assert A() < B()
+ assert A() <= B()
+ assert A() > B()
+ assert A() >= B()
+ #
+ assert not (B() == A())
+ assert not (B() != A())
+ assert not (B() < A())
+ assert not (B() <= A())
+ assert not (B() > A())
+ assert not (B() >= A())
+ #
+ class C(A):
+ def __eq__(self, other): return False
+ def __ne__(self, other): return False
+ def __lt__(self, other): return False
+ def __le__(self, other): return False
+ def __gt__(self, other): return False
+ def __ge__(self, other): return False
+ #
+ assert not (A() == C())
+ assert not (A() != C())
+ assert not (A() < C())
+ assert not (A() <= C())
+ assert not (A() > C())
+ assert not (A() >= C())
+ #
+ assert not (C() == A())
+ assert not (C() != A())
+ assert not (C() < A())
+ assert not (C() <= A())
+ assert not (C() > A())
+ assert not (C() >= A())
+
def test_addition(self):
# Old-style
class A:
More information about the pypy-commit
mailing list