[Zope-Checkins] CVS: Zope3/lib/python/Zope/ContextWrapper/tests - testSimpleMethodWrapper.py:1.1.2.4

Fred L. Drake, Jr. fdrake@acm.org
Fri, 7 Jun 2002 12:04:22 -0400


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

Modified Files:
      Tag: Zope-3x-branch
	testSimpleMethodWrapper.py 
Log Message:
Replace assert statements with explicit raise statements so this test
will work with "python -O".


=== Zope3/lib/python/Zope/ContextWrapper/tests/testSimpleMethodWrapper.py 1.1.2.3 => 1.1.2.4 ===
 class NewStyleClass(object):
     def thisIsAContextMethod(wrapped_self):
-        assert type(wrapped_self) in wrapperTypes
+        if type(wrapped_self) not in wrapperTypes:
+            raise AssertionError
     thisIsAContextMethod = ContextMethod(thisIsAContextMethod)
 
     def __call__(wrapped_self):
-        assert type(wrapped_self) in wrapperTypes
+        if type(wrapped_self) not in wrapperTypes:
+            raise AssertionError
     __call__ = ContextMethod(__call__)
 
     def thisIsNotAContextMethod(self):
-        assert type(self) not in wrapperTypes
-    
+        if type(self) in wrapperTypes:
+            raise AssertionError
+
        
 class ClassicClass:
     def thisIsAContextMethod(wrapped_self):
-        assert type(wrapped_self) in wrapperTypes
+        if type(wrapped_self) not in wrapperTypes:
+            raise AssertionError
     thisIsAContextMethod = ContextMethod(thisIsAContextMethod)
 
     def __call__(wrapped_self, a, b=None):
-        assert type(wrapped_self) in wrapperTypes
-        assert a==1
-        assert b==2
-        
+        if type(wrapped_self) not in wrapperTypes:
+            raise AssertionError
+        if a != 1:
+            raise AssertionError
+        if b != 2:
+            raise AssertionError
     __call__ = ContextMethod(__call__)
-    
 
     def thisIsNotAContextMethod(self):
-        assert type(self) not in wrapperTypes
+        if type(self) in wrapperTypes:
+            raise AssertionError
 
 
 class SimpleMethodWrapperTestCase(unittest.TestCase):
@@ -72,12 +78,10 @@
         wrapped(1,2)
         wrapped(a=1, b=2)
         wrapped(1, b=2)
-       
+
 
 def test_suite():
-    suite = unittest.TestSuite()
-    suite.addTest(unittest.makeSuite(SimpleMethodWrapperTestCase))
-    return suite
+    return unittest.makeSuite(SimpleMethodWrapperTestCase)
 
 
 if __name__ == "__main__":