[Zope-Checkins] CVS: Zope3/lib/python/Zope/ContextWrapper/tests - test_proxy.py:1.1.2.3

Fred L. Drake, Jr. fdrake@acm.org
Fri, 26 Apr 2002 15:33:26 -0400


Update of /cvs-repository/Zope3/lib/python/Zope/ContextWrapper/tests
In directory cvs.zope.org:/tmp/cvs-serv13812/tests

Modified Files:
      Tag: SecurityProxy-branch
	test_proxy.py 
Log Message:
Make the coercion tests not fail for Python < 2.3, similar to Guido's fix
for the Sceurity.Proxy.


=== Zope3/lib/python/Zope/ContextWrapper/tests/test_proxy.py 1.1.2.2 => 1.1.2.3 ===
         P = self.new_proxy
 
+        # Before 2.3, coerce() of two proxies returns them unchanged
+        import sys
+        fixed_coerce = sys.version_info >= (2, 3, 0)
+
         x = P(1)
         y = P(2)
         a, b = coerce(x, y)
@@ -190,16 +194,18 @@
         x = P(1)
         y = P(2.1)
         a, b = coerce(x, y)
-        # XXX This fails unless your Python is the latest from CVS!!!
-        # XXX (PyNumber_Coerce[Ex] needs a change)
-        self.failUnless(a.__class__ is float, a.__class__)
+        self.failUnless(a == 1.0)
         self.failUnless(b is y)
+        if fixed_coerce:
+            self.failUnless(a.__class__ is float, a.__class__)
 
         x = P(1.1)
         y = P(2)
         a, b = coerce(x, y)
         self.failUnless(a is x)
-        self.failUnless(b.__class__ is float, b.__class__)
+        self.failUnless(b == 2.0)
+        if fixed_coerce:
+            self.failUnless(b.__class__ is float, b.__class__)
 
         x = P(1)
         y = 2