~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_decorators.py

  • Committer: Andrew Bennetts
  • Date: 2010-10-08 08:15:14 UTC
  • mto: This revision was merged to the branch mainline in revision 5498.
  • Revision ID: andrew.bennetts@canonical.com-20101008081514-dviqzrdfwyzsqbz2
Split NEWS into per-release doc/en/release-notes/bzr-*.txt

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
    pass
28
28
 
29
29
 
30
 
def create_decorator_sample(style, unlock_error=None, meth=None):
 
30
def create_decorator_sample(style, unlock_error=None):
31
31
    """Create a DecoratorSample object, using specific lock operators.
32
32
 
33
33
    :param style: The type of lock decorators to use (fast/pretty/None)
34
34
    :param unlock_error: If specified, an error to raise from unlock.
35
 
    :param meth: a function to be decorated and added as a 'meth_read' and
36
 
        'meth_write' to the object.
37
35
    :return: An instantiated DecoratorSample object.
38
36
    """
39
37
 
94
92
            self.actions.append('fail_during_write')
95
93
            raise TypeError('during write')
96
94
 
97
 
        if meth is not None:
98
 
            meth_read = needs_read_lock(meth)
99
 
            meth_write = needs_write_lock(meth)
100
 
 
101
95
    return DecoratorSample()
102
96
 
103
97
 
155
149
        self.assertEqual(['lock_write', ('bank', 'bar', 'bing'),
156
150
                          'unlock_fail'], sam.actions)
157
151
 
158
 
    def test_read_lock_preserves_default_str_kwarg_identity(self):
159
 
        a_constant = 'A str used as a constant'
160
 
        def meth(self, param=a_constant):
161
 
            return param
162
 
        sam = create_decorator_sample(self._decorator_style, meth=meth)
163
 
        self.assertIs(a_constant, sam.meth_read())
164
 
 
165
 
    def test_write_lock_preserves_default_str_kwarg_identity(self):
166
 
        a_constant = 'A str used as a constant'
167
 
        def meth(self, param=a_constant):
168
 
            return param
169
 
        sam = create_decorator_sample(self._decorator_style, meth=meth)
170
 
        self.assertIs(a_constant, sam.meth_write())
171
 
 
172
152
 
173
153
class TestFastDecoratorActions(TestDecoratorActions):
174
154