← Back to team overview

testtools-dev team mailing list archive

Re: [Merge] lp:~jml/testtools/patch-310770 into lp:testtools

 

A few thoughts.

Firstly, I'd expect this to delete an attribute too, if the original
was unset; this doesn't, but the tests don't make it clear whether
that is oversight or intent.

Secondly, this is so useful, I really would rather not see it on TestCase.

How about

def patch(obj, attribute, value):
    """Set obj.attribute to value and return a cleanup to restore it."""


?

Then you can do
self.addCleanup(patch(sys, "stderr", StringIO())
-- 
https://code.launchpad.net/~jml/testtools/patch-310770/+merge/31666
Your team testtools developers is requested to review the proposed merge of lp:~jml/testtools/patch-310770 into lp:testtools.



References