[Zope3-checkins] CVS: Zope3/src/zope/proxy/context/tests - test_decorator.py:1.8 test_wrapper.py:1.12

Marius Gedminas mgedmin@codeworks.lt
Mon, 12 May 2003 11:44:42 -0400


Update of /cvs-repository/Zope3/src/zope/proxy/context/tests
In directory cvs.zope.org:/tmp/cvs-serv21280/src/zope/proxy/context/tests

Modified Files:
	test_decorator.py test_wrapper.py 
Log Message:
Applied the recent descriptor.c fixes to wrapper.c:
- Access to descriptor->ob_type->tp_descr_get and tp_descr_set is now only done
  when PyType_HasFeature(descriptor->ob_type, Py_TPFLAGS_HAVE_CLASS) is true.
- The name argument of getattro/setattro wrappers is converted from Unicode
  when necessary and it's reference count is incremented temporarily to prevent
  it from being GCed at the wrong time.


=== Zope3/src/zope/proxy/context/tests/test_decorator.py 1.7 => 1.8 ===
--- Zope3/src/zope/proxy/context/tests/test_decorator.py:1.7	Mon May 12 10:59:37 2003
+++ Zope3/src/zope/proxy/context/tests/test_decorator.py	Mon May 12 11:44:41 2003
@@ -192,11 +192,6 @@
         f = MixinFactory
         n = ('foo', 'spoo', u's\u2323g', 'someinstanceattr')
         self.assertRaises(TypeError, self.proxy_class, obj, c, f, n)
-        n = ('foo', 'spoo', 'someinstanceattr')
-        w = self.proxy_class(obj, c, f, n)
-        self.assertRaises(UnicodeError, getattr, w, u's\u2323g')
-        self.assertRaises(UnicodeError, setattr, w, u's\u2323g', 23)
-
 
     def test_typeerror_if_no_factory(self):
         w = self.proxy_class(object(), None, None, ('foo',))


=== Zope3/src/zope/proxy/context/tests/test_wrapper.py 1.11 => 1.12 ===
--- Zope3/src/zope/proxy/context/tests/test_wrapper.py:1.11	Thu May  8 05:40:11 2003
+++ Zope3/src/zope/proxy/context/tests/test_wrapper.py	Mon May 12 11:44:41 2003
@@ -252,6 +252,18 @@
         self.assertEqual(x.value_called, (p, 'foo', 'bar'))
         self.assert_(x.value_called[0] is x)
 
+    def test_UnicodeAttrNames(self):
+        class SomeObject(object):
+            foo = 42
+        obj = SomeObject()
+        p = self.new_proxy(obj)
+        self.assertEquals(getattr(p, u'foo'), 42)
+        self.assertRaises(AttributeError, getattr, p, u'bar')
+        self.assertRaises(UnicodeError, getattr, p, u'baz\u1234')
+        setattr(p, u'bar', 23)
+        self.assertEquals(p.bar, 23)
+        self.assertRaises(UnicodeError, setattr, p, u'baz\u1234', 23)
+
     def test_getitem(self):
         p1, p2, p3, context = self.make_proxies('__getitem__')
         self.assertEquals(p1[42], (None, (42, )))