On Wed, Aug 19, 2015 at 6:51 PM, Sylvain Bauza <sba...@redhat.com> wrote:

> Hi,
>
> I was writing some tests so I added a contextlib.nested to a checked
> TestCase [1]. Unfortunately, contextlib.nested is no longer available in
> Python3 and there is no clear solution on how to provide a compatible
> import for both python2 and python3:
>  - either providing a python3 compatible behaviour by using
> contextlib.ExitStack but that class is not available in Python 2
>  - or provide contextlib2 for python2 (and thus adding it to the
> requirements)
>
> That sounds really disruptive and blocking as we are close to the
> FeatureFreeze. Many other users of contextlib.nested are not impacted by
> the job because it excludes all of them but since the test I'm changing is
> part of the existing validated tests, that leaves Jenkins -1'ing my change.
>
> Of course, a 3rd solution would consist of excluding my updated test from
> the python3 check but I can hear others yelling at that :-)
>
> Ideas appreciated.
>
> -Sylvain
>
> [1]
> https://review.openstack.org/#/c/199205/18/nova/tests/unit/scheduler/test_rpcapi.py,cm
>
>
>
Mock provides a context that patches multiple things so that no nesting is
needed: http://www.voidspace.org.uk/python/mock/patch.html#patch-multiple

oslotest provides fixtures for mock, so you don't need a context:
http://docs.openstack.org/developer/oslotest/api.html#module-oslotest.mockpatch

  __ Brant
__________________________________________________________________________
OpenStack Development Mailing List (not for usage questions)
Unsubscribe: openstack-dev-requ...@lists.openstack.org?subject:unsubscribe
http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev

Reply via email to