[Zope3-checkins] CVS: Zope3/lib/python/Zope/ContextWrapper/tests - testSimpleMethodWrapper.py:1.6
Steve Alexander
steve@cat-box.net
Tue, 12 Nov 2002 05:57:34 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/ContextWrapper/tests
In directory cvs.zope.org:/tmp/cvs-serv23886/tests
Modified Files:
testSimpleMethodWrapper.py
Log Message:
Removed extraneous import.
Added link to wiki documentation.
Refactored unit tests to avoid the need for noop tests for classic classes.
=== Zope3/lib/python/Zope/ContextWrapper/tests/testSimpleMethodWrapper.py 1.5 => 1.6 ===
--- Zope3/lib/python/Zope/ContextWrapper/tests/testSimpleMethodWrapper.py:1.5 Mon Nov 11 14:40:43 2002
+++ Zope3/lib/python/Zope/ContextWrapper/tests/testSimpleMethodWrapper.py Tue Nov 12 05:57:34 2002
@@ -11,7 +11,6 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
-import pickle
import sys
import unittest
@@ -115,11 +114,11 @@
thisIsAContextGetProperty = ContextGetProperty(_getter)
-class TestNewStyleClass(unittest.TestCase):
+class TestClassicClass(unittest.TestCase):
def createObject(self):
# to be overridden in tests that subclass this one
- return NewStyleClass()
+ return ClassicClass()
def setUp(self):
unittest.TestCase.setUp(self)
@@ -174,6 +173,29 @@
self.assertEqual(self.wrapped.thisIsAContextProperty, True)
self.assert_(self.obj.result is self.wrapped)
+ def testGetContextGetProperty(self):
+ self.assertEqual(self.wrapped.thisIsAContextGetProperty, True)
+ self.assert_(self.obj.result is self.wrapped)
+
+ def testGetContextProperty_w_name_in_dict(self):
+ self.obj.thisIsAContextProperty = False
+ self.assertEqual(self.wrapped.thisIsAContextProperty, True)
+ self.assert_(self.obj.result is self.wrapped)
+
+ def testNotFound(self):
+ self.assertRaises(AttributeError,
+ getattr, self.wrapped, 'noSuchAttribute')
+
+
+class TestNewStyleClass(TestClassicClass):
+
+ def createObject(self):
+ return NewStyleClass()
+
+ # Setting properties doesn't work with classic classes,
+ # so this class has extra tests for setting properties in
+ # new-style classes.
+
def testSetContextProperty(self):
value = 23
self.wrapped.thisIsAContextProperty = value
@@ -181,10 +203,6 @@
self.assert_(result_obj is self.wrapped)
self.assert_(result_value is value)
- def testGetContextGetProperty(self):
- self.assertEqual(self.wrapped.thisIsAContextGetProperty, True)
- self.assert_(self.obj.result is self.wrapped)
-
def testSetContextGetProperty(self):
value = 23
self.wrapped.thisIsAContextGetProperty = value
@@ -203,33 +221,11 @@
self.assert_(result_obj is self.wrapped)
self.assert_(result_value is value)
- def testGetContextProperty_w_name_in_dict(self):
- self.obj.thisIsAContextProperty = False
- self.assertEqual(self.wrapped.thisIsAContextProperty, True)
- self.assert_(self.obj.result is self.wrapped)
-
- def testNotFound(self):
- self.assertRaises(AttributeError,
- getattr, self.wrapped, 'noSuchAttribute')
-
-
class TestNewStyleClassWithSlots(TestNewStyleClass):
def createObject(self):
return NewStyleClassWithSlots()
-class TestClassicClass(TestNewStyleClass):
-
- def createObject(self):
- return ClassicClass()
-
- # setting properties doesn't work with classic classes
- # so, disable those tests
- def testSetContextProperty(self):
- pass
- testSetContextGetProperty = testSetContextProperty
- testGetContextSetProperty = testSetContextProperty
- testSetContextSetProperty = testSetContextProperty
def test_suite():
return unittest.TestSuite((