[openstack-dev] [nova] contextlib.nested and Python3 failing

John Garbutt john at johngarbutt.com
Thu Aug 20 10:37:21 UTC 2015


On 20 August 2015 at 01:42, melanie witt <melwittt at gmail.com> wrote:
> On Aug 19, 2015, at 16:51, Sylvain Bauza <sbauza at redhat.com> wrote:
>
>> Ideas appreciated.
>
> Instead of using the nested context managers, a way I like is to decorate a nested function in the test and call it, for example:
>
>
> def test_thing(self):
>
>     @mock.patch(...)
>     @mock.patch(...)
>     @mock.patch(...)
>     def do_test(..., ..., ...):
>         ...
>
>     do_test()

+1

I have always found that more readable that the context manager thing,
can't really explain why.

johnthetubaguy



More information about the OpenStack-dev mailing list