← Back to team overview

testtools-dev team mailing list archive

[Merge] lp:~gz/testtools/update_wrapped_function_manually_666306 into lp:testtools

 

Martin [gz] has proposed merging lp:~gz/testtools/update_wrapped_function_manually_666306 into lp:testtools.

Requested reviews:
  testtools developers (testtools-dev)
Related bugs:
  #666306 Test suite shouldn't depend on twisted
  https://bugs.launchpad.net/bugs/666306


Attempt three at making this test do the right thing. Rather than using functools.wraps or twisted.python.util.mergeFunctionMetadata this just updates the relevant metadata in the wrapped function itself. As all the code is right there in the test method, it's pretty clear the fancier stuff the library functions take account of is not needed.
-- 
https://code.launchpad.net/~gz/testtools/update_wrapped_function_manually_666306/+merge/39293
Your team testtools developers is requested to review the proposed merge of lp:~gz/testtools/update_wrapped_function_manually_666306 into lp:testtools.
=== modified file 'testtools/tests/test_runtest.py'
--- testtools/tests/test_runtest.py	2010-10-24 08:27:24 +0000
+++ testtools/tests/test_runtest.py	2010-10-25 16:47:45 +0000
@@ -2,8 +2,6 @@
 
 """Tests for the RunTest single test execution logic."""
 
-from twisted.python.util import mergeFunctionMetadata
-
 from testtools import (
     ExtendedToOriginalDecorator,
     run_test_with,
@@ -263,7 +261,9 @@
             """Silly, trivial decorator."""
             def decorated(*args, **kwargs):
                 return function(*args, **kwargs)
-            return mergeFunctionMetadata(function, decorated)
+            decorated.__name__ = function.__name__
+            decorated.__dict__.update(function.__dict__)
+            return decorated
         class SomeCase(TestCase):
             @wrapped
             @run_test_with(CustomRunTest)


Follow ups