[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/Traversing/tests - testZopeWrapper.py:1.1.2.3

Steve Alexander steve@cat-box.net
Wed, 20 Mar 2002 17:32:00 -0500


Update of /cvs-repository/Zope3/lib/python/Zope/App/Traversing/tests
In directory cvs.zope.org:/tmp/cvs-serv3161/tests

Added Files:
      Tag: Zope-3x-branch
	testZopeWrapper.py 
Log Message:
Added ZopeWrapper function to Traversing/__init__.py, which avoids
wrapping primitives.
Added test for this.



=== Zope3/lib/python/Zope/App/Traversing/tests/testZopeWrapper.py 1.1.2.2 => 1.1.2.3 ===
+#
+# Copyright (c) 2001 Zope Corporation and Contributors.  All Rights Reserved.
+# 
+# This software is subject to the provisions of the Zope Public License,
+# Version 1.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS 
+# FOR A PARTICULAR PURPOSE.
+##############################################################################
+"""
+
+$Id$
+"""
+
+import unittest
+from Zope.Testing.CleanUp import CleanUp # Base class w registry cleanup
+from Zope.ContextWrapper import Wrapper, getobject
+import Zope.App.Traversing 
+from Zope.App.Traversing import ZopeWrapper
+
+class ZopeWrapperTests(CleanUp, unittest.TestCase):
+    def setUp(self):
+        pass
+        
+    def testPrimitives(self):
+        for obj in None, 1,1l, 1.0, 1+2j, u'', '':
+            self.assertEquals(ZopeWrapper(obj) is obj, 1)
+
+    def testComplexTypes(self):
+        obj = object()
+        w = Wrapper(obj)
+        zw = ZopeWrapper(obj)
+        self.assertEquals(type(zw) is type(w), 1)
+        self.assertEquals(getobject(zw) is getobject(w), 1)
+
+def test_suite():
+    loader = unittest.TestLoader()
+    suite = loader.loadTestsFromTestCase(ZopeWrapperTests)
+    return suite
+
+if __name__=='__main__':
+    unittest.TextTestRunner().run(test_suite())