[Checkins] SVN: zope.app.pagetemplate/tags/3.7.0/src/zope/app/pagetemplate/tests/test_simpleviewclass.py Revert inadvertent checkin to release tag.

Tres Seaver tseaver at palladion.com
Mon May 25 21:39:48 EDT 2009


Log message for revision 100385:
  Revert inadvertent checkin to release tag.

Changed:
  U   zope.app.pagetemplate/tags/3.7.0/src/zope/app/pagetemplate/tests/test_simpleviewclass.py

-=-
Modified: zope.app.pagetemplate/tags/3.7.0/src/zope/app/pagetemplate/tests/test_simpleviewclass.py
===================================================================
--- zope.app.pagetemplate/tags/3.7.0/src/zope/app/pagetemplate/tests/test_simpleviewclass.py	2009-05-26 01:36:57 UTC (rev 100384)
+++ zope.app.pagetemplate/tags/3.7.0/src/zope/app/pagetemplate/tests/test_simpleviewclass.py	2009-05-26 01:39:48 UTC (rev 100385)
@@ -1,6 +1,6 @@
 ##############################################################################
 #
-# Copyright (c) 2001-2009 Zope Corporation and Contributors.
+# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
 # All Rights Reserved.
 #
 # This software is subject to the provisions of the Zope Public License,
@@ -17,20 +17,18 @@
 """
 import unittest
 
-class Test_SimpleTestView(unittest.TestCase):
+from zope.app.pagetemplate.simpleviewclass import SimpleViewClass
+from zope.app.pagetemplate.tests.simpletestview import SimpleTestView
+from zope.publisher.browser import TestRequest
 
-    def _getTargetClass(self):
-        from zope.app.pagetemplate.tests.simpletestview import SimpleTestView
-        return SimpleTestView
+class data(object): pass
 
-    def _makeOne(self, context, request):
-        return self._getTargetClass()(context, request)
+class SimpleViewTestCase(unittest.TestCase):
 
     def test_simple(self):
-        from zope.publisher.browser import TestRequest
-        context = DummyContext()
+        ob = data()
         request = TestRequest()
-        view = self._makeOne(context, request)
+        view = SimpleTestView(ob, request)
         macro = view['test']
         out = view()
         self.assertEqual(out,
@@ -39,38 +37,27 @@
                          '    <p>hello world</p>\n'
                          '  </body>\n</html>\n')
 
-class Test_SimpleViewClass(unittest.TestCase):
-
-    def _getTargetClass(self):
-        from zope.app.pagetemplate.simpleviewclass import SimpleViewClass
-        return SimpleViewClass
-
-    def _makeKlass(self, *args, **kw):
-        return self._getTargetClass()(*args, **kw)
-
-    def test___name__(self):
-        klass = self._makeKlass('testsimpleviewclass.pt', name='test.html')
-        view = klass(None, None)
+    def test_name(self):
+        View = SimpleViewClass('testsimpleviewclass.pt', name='test.html')
+        view = View(None, None)
         self.assertEqual(view.__name__, 'test.html')
 
-    def test___getitem___(self):
-        klass = self._makeKlass('testsimpleviewclass.pt', name='test.html')
-        view = klass(None, None)
+    def test_getitem(self):
+        View = SimpleViewClass('testsimpleviewclass.pt', name='test.html')
+        view = View(None, None)
         self.assert_(view['test'] is not None)
         self.assertRaises(KeyError, view.__getitem__, 'foo')
 
-    def test_w_base_classes(self):
-        from zope.publisher.browser import TestRequest
-        class BaseClass(object):
-            pass
+    def test_WBases(self):
+        class C(object): pass
 
-        klass = self._makeKlass('testsimpleviewclass.pt', bases=(BaseClass, ))
+        SimpleTestView = SimpleViewClass('testsimpleviewclass.pt', bases=(C, ))
 
-        self.failUnless(issubclass(klass, BaseClass))
+        self.failUnless(issubclass(SimpleTestView, C))
 
-        ob = DummyContext()
+        ob = data()
         request = TestRequest()
-        view = klass(ob, request)
+        view = SimpleTestView(ob, request)
         macro = view['test']
         out = view()
         self.assertEqual(out,
@@ -79,95 +66,8 @@
                          '    <p>hello world</p>\n'
                          '  </body>\n</html>\n')
 
-class Test_simple(unittest.TestCase):
-
-    def _getTargetClass(self):
-        from zope.app.pagetemplate.simpleviewclass import simple
-        return simple
-
-    def _makeOne(self, context=None, request=None):
-        if context is None:
-            context = DummyContext()
-        if request is None:
-            request = DummyRequest()
-        return self._getTargetClass()(context, request)
-
-    def test_class_conforms_to_IBrowserPublisher(self):
-        from zope.interface.verify import verifyClass
-        from zope.publisher.interfaces.browser import IBrowserPublisher
-        verifyClass(IBrowserPublisher, self._getTargetClass())
-
-    def test_browserDefault(self):
-        request = DummyRequest()
-        view = self._makeOne(request=request)
-        self.assertEqual(view.browserDefault(request), (view, ()))
-
-    def test_publishTraverse_not_index_raises_NotFound(self):
-        from zope.publisher.interfaces import NotFound
-        request = DummyRequest()
-        view = self._makeOne(request=request)
-        self.assertRaises(NotFound, view.publishTraverse, request, 'nonesuch')
-
-    def test_publishTraverse_w_index_returns_index(self):
-        request = DummyRequest()
-        view = self._makeOne(request=request)
-        index = view.index = DummyTemplate()
-        self.failUnless(view.publishTraverse(request, 'index.html') is index)
-
-    def test___getitem___uses_index_macros(self):
-        view = self._makeOne()
-        view.index = index = DummyTemplate()
-        index.macros = {}
-        index.macros['aaa'] = aaa = object()
-        self.failUnless(view['aaa'] is aaa)
-
-    def test___call___no_args_no_kw(self):
-        view = self._makeOne()
-        view.index = index = DummyTemplate()
-        result = view()
-        self.failUnless(result is index)
-        self.assertEqual(index._called_with, ((), {}))
-
-    def test___call___w_args_no_kw(self):
-        view = self._makeOne()
-        view.index = index = DummyTemplate()
-        result = view('abc')
-        self.failUnless(result is index)
-        self.assertEqual(index._called_with, (('abc',), {}))
-
-    def test___call___no_args_w_kw(self):
-        view = self._makeOne()
-        view.index = index = DummyTemplate()
-        result = view(foo='bar')
-        self.failUnless(result is index)
-        self.assertEqual(index._called_with, ((), {'foo': 'bar'}))
-
-    def test___call___no_args_no_kw(self):
-        view = self._makeOne()
-        view.index = index = DummyTemplate()
-        result = view('abc', foo='bar')
-        self.failUnless(result is index)
-        self.assertEqual(index._called_with, (('abc',), {'foo': 'bar'}))
-
-
-class DummyContext:
-    pass
-
-class DummyResponse:
-    pass
-
-class DummyRequest:
-    debug = False
-    response = DummyResponse()
-
-class DummyTemplate:
-    def __call__(self, *args, **kw):
-        self._called_with = (args, kw)
-        return self
-
 def test_suite():
-    return unittest.TestSuite((
-        unittest.makeSuite(Test_SimpleTestView),
-        unittest.makeSuite(Test_SimpleViewClass),
-        unittest.makeSuite(Test_simple),
-    ))
+    return unittest.makeSuite(SimpleViewTestCase)
+
+if __name__=='__main__':
+    unittest.TextTestRunner().run(test_suite())



More information about the Checkins mailing list