[Zope-Checkins] CVS: Zope3/lib/python/Zope/Publisher/tests - testMapply.py:1.1.2.1 testPublisher.py:1.1.2.2

Martijn Pieters mj@zope.com
Tue, 27 Nov 2001 15:36:19 -0500


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

Modified Files:
      Tag: Zope-3x-branch
	testPublisher.py 
Added Files:
      Tag: Zope-3x-branch
	testMapply.py 
Log Message:
Moved mapply tests to separate file; split mapply tests out a bit.


=== Added File Zope3/lib/python/Zope/Publisher/tests/testMapply.py ===
# 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.

import unittest

from Zope.Publisher.mapply import mapply

class MapplyTests(unittest.TestCase):
    def testMethod(self):
        def compute(a,b,c=4):
            return '%d%d%d' % (a, b, c)
        values = {'a':2, 'b':3, 'c':5}
        v = mapply(compute, (), values)
        self.failUnlessEqual(v, '235')

        v = mapply(compute, (7,), values)
        self.failUnlessEqual(v, '735')

    def testClass(self):
        values = {'a':2, 'b':3, 'c':5}
        class c:
            a = 3
            def __call__(self, b, c=4):
                return '%d%d%d' % (self.a, b, c)
            compute = __call__
        cc = c()
        v = mapply(cc, (), values)
        self.failUnlessEqual(v, '335')

        del values['c']
        v = mapply(cc.compute, (), values)
        self.failUnlessEqual(v, '334')

        class c2: pass
        c2inst = c2()
        c2inst.__call__ = cc
        v = mapply(c2inst, (), values)
        self.failUnlessEqual(v, '334')

def test_suite():
    loader = unittest.TestLoader()
    return loader.loadTestsFromTestCase(MapplyTests)

if __name__=='__main__':
    unittest.TextTestRunner().run(test_suite())


=== Zope3/lib/python/Zope/Publisher/tests/testPublisher.py 1.1.2.1 => 1.1.2.2 ===
 from Zope.Publisher.DefaultPublication import DefaultPublication
 from Zope.Publisher.Exceptions import Retry
-from Zope.Publisher.mapply import mapply
 
 from StringIO import StringIO
 
@@ -62,36 +61,6 @@
         self.failUnlessEqual(res, 'item')
         res = self._publisherResults('folder/item')
         self.failUnlessEqual(res, 'item')
-
-    def testMapply(self):
-        def compute(a,b,c=4):
-            return '%d%d%d' % (a, b, c)
-        values = {'a':2, 'b':3, 'c':5}
-        v = mapply(compute, (), values)
-        self.failUnlessEqual(v, '235')
-
-        v = mapply(compute, (7,), values)
-        self.failUnlessEqual(v, '735')
-
-        class c:
-            a = 3
-            def __call__(self, b, c=4):
-                return '%d%d%d' % (self.a, b, c)
-            compute = __call__
-        cc = c()
-        v = mapply(cc, (), values)
-        self.failUnlessEqual(v, '335')
-
-        del values['c']
-        v = mapply(cc.compute, (), values)
-        self.failUnlessEqual(v, '334')
-
-        class c2: pass
-        c2inst = c2()
-        c2inst.__call__ = cc
-        v = mapply(c2inst, (), values)
-        self.failUnlessEqual(v, '334')
-
 
 def test_suite():
     loader = unittest.TestLoader()