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

Sylvain Bauza sbauza at redhat.com
Mon Aug 24 13:31:51 UTC 2015



Le 20/08/2015 03:37, John Garbutt a écrit :
> 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.

Agreed, it looks like a good approach and leave an alternative 
possibility for not using the test.nested stuff.

-Sylvain

> johnthetubaguy
>
> __________________________________________________________________________
> OpenStack Development Mailing List (not for usage questions)
> Unsubscribe: OpenStack-dev-request at lists.openstack.org?subject:unsubscribe
> http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev




More information about the OpenStack-dev mailing list