~openerp-dev/openobject-server/trunk-missing-default-values-pza

« back to all changes in this revision

Viewing changes to openerp/tests/test_func.py

  • Committer: Antony Lesuisse
  • Date: 2014-01-31 00:52:07 UTC
  • mfrom: (4854.4.369 trunk-website-al)
  • mto: This revision was merged to the branch mainline in revision 5025.
  • Revision ID: al@openerp.com-20140131005207-mn7t6tar8cywe9hz
[MERGE] trunk-website-al

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- coding: utf-8 -*-
 
2
import functools
 
3
import unittest2
 
4
 
 
5
from ..tools.func import compose
 
6
 
 
7
class TestCompose(unittest2.TestCase):
 
8
    def test_basic(self):
 
9
        str_add = compose(str, lambda a, b: a + b)
 
10
        self.assertEqual(
 
11
            str_add(1, 2),
 
12
            "3")
 
13
 
 
14
    def test_decorator(self):
 
15
        """ ensure compose() can be partially applied as a decorator
 
16
        """
 
17
        @functools.partial(compose, unicode)
 
18
        def mul(a, b):
 
19
            return a * b
 
20
 
 
21
        self.assertEqual(mul(5, 42), u"210")
 
22