~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_decorators.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2010-02-11 04:02:41 UTC
  • mfrom: (5017.2.2 tariff)
  • Revision ID: pqm@pqm.ubuntu.com-20100211040241-w6n021dz0uus341n
(mbp) add import-tariff tests

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006-2010 Canonical Ltd
 
1
# Copyright (C) 2006 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
167
167
        """@needs_read_lock exposes underlying name and doc."""
168
168
        sam = create_decorator_sample(None)
169
169
        self.assertEqual('frob', sam.frob.__name__)
170
 
        self.assertDocstring('Frob the sample object', sam.frob)
 
170
        self.assertEqual('Frob the sample object', sam.frob.__doc__)
171
171
 
172
172
    def test_write_lock_passthrough(self):
173
173
        """@needs_write_lock exposes underlying name and doc."""
174
174
        sam = create_decorator_sample(None)
175
175
        self.assertEqual('bank', sam.bank.__name__)
176
 
        self.assertDocstring('Bank the sample, but using bar and biz.',
177
 
                             sam.bank)
 
176
        self.assertEqual('Bank the sample, but using bar and biz.',
 
177
                         sam.bank.__doc__)
178
178
 
179
179
    def test_argument_passthrough(self):
180
180
        """Test that arguments get passed around properly."""
208
208
                         my_function.func_code.co_name)
209
209
        self.assertEqual('(foo, bar, baz=None, biz=1)',
210
210
                         self.get_formatted_args(my_function))
211
 
        self.assertDocstring(
212
 
            'Just a function that supplies several arguments.', my_function)
 
211
        self.assertEqual('Just a function that supplies several arguments.',
 
212
                         inspect.getdoc(my_function))
213
213
 
214
214
    def test__fast_needs_read_lock(self):
215
215
        """Test the output of _fast_needs_read_lock."""
222
222
        self.assertEqual('read_locked', my_function.func_code.co_name)
223
223
        self.assertEqual('(self, *args, **kwargs)',
224
224
                         self.get_formatted_args(my_function))
225
 
        self.assertDocstring(
226
 
            'Just a function that supplies several arguments.', my_function)
 
225
        self.assertEqual('Just a function that supplies several arguments.',
 
226
                         inspect.getdoc(my_function))
227
227
 
228
228
    def test__pretty_needs_write_lock(self):
229
229
        """Test that _pretty_needs_write_lock generates a nice wrapper."""
237
237
                         my_function.func_code.co_name)
238
238
        self.assertEqual('(foo, bar, baz=None, biz=1)',
239
239
                         self.get_formatted_args(my_function))
240
 
        self.assertDocstring(
241
 
            'Just a function that supplies several arguments.', my_function)
 
240
        self.assertEqual('Just a function that supplies several arguments.',
 
241
                         inspect.getdoc(my_function))
242
242
 
243
243
    def test__fast_needs_write_lock(self):
244
244
        """Test the output of _fast_needs_write_lock."""
251
251
        self.assertEqual('write_locked', my_function.func_code.co_name)
252
252
        self.assertEqual('(self, *args, **kwargs)',
253
253
                         self.get_formatted_args(my_function))
254
 
        self.assertDocstring(
255
 
            'Just a function that supplies several arguments.', my_function)
 
254
        self.assertEqual('Just a function that supplies several arguments.',
 
255
                         inspect.getdoc(my_function))
256
256
 
257
257
    def test_use_decorators(self):
258
258
        """Test that you can switch the type of the decorators."""