summaryrefslogtreecommitdiffstats
path: root/nova/tests
diff options
context:
space:
mode:
authorSoren Hansen <soren@linux2go.dk>2011-03-01 20:49:46 +0100
committerSoren Hansen <soren@linux2go.dk>2011-03-01 20:49:46 +0100
commitbe9004ffa4c70358c8edda1f33ffe7ba7e1ae1ee (patch)
tree4833b57a2735900bc0fcdcd607365a273e631ca7 /nova/tests
parentd5736e925f288462f6325130be0af49f0ace5884 (diff)
Use functools.wraps to make sure wrapped method's metadata (docstring and name) doesn't get mangled.
Diffstat (limited to 'nova/tests')
-rw-r--r--nova/tests/test_misc.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/nova/tests/test_misc.py b/nova/tests/test_misc.py
index 154b6fae6..9f572b58e 100644
--- a/nova/tests/test_misc.py
+++ b/nova/tests/test_misc.py
@@ -14,11 +14,9 @@
# License for the specific language governing permissions and limitations
# under the License.
-from datetime import datetime
import errno
import os
import select
-import time
from nova import test
from nova.utils import parse_mailmap, str_dict_replace, synchronized
@@ -62,6 +60,16 @@ class ProjectTestCase(test.TestCase):
class LockTestCase(test.TestCase):
+ def test_synchronized_wrapped_function_metadata(self):
+ @synchronized('whatever')
+ def foo():
+ """Bar"""
+ pass
+ self.assertEquals(foo.__doc__, 'Bar', "Wrapped function's docstring "
+ "got lost")
+ self.assertEquals(foo.__name__, 'foo', "Wrapped function's name "
+ "got mangled")
+
def test_synchronized(self):
rpipe, wpipe = os.pipe()
pid = os.fork()