[openstack-qa] Why not to use with context ?

Attila Fazekas afazekas at redhat.com
Tue Jun 11 17:46:09 UTC 2013


Just for the users it is not a big issue.

Probably we will not need more than 4 users in a test case.

I saw with context attempts for another resources in the past.

You will need to impersonate the same user multiple times.



----- Original Message -----
> From: "Jay Pipes" <jaypipes at gmail.com>
> To: openstack-qa at lists.openstack.org
> Sent: Tuesday, June 11, 2013 6:22:29 PM
> Subject: Re: [openstack-qa] Why not to use with context ?
> 
> On 06/11/2013 12:09 PM, Attila Fazekas wrote:
> > The with context are very powerful element of the python, this
> > should be used wisely. I like it.
> >
> > One my main concern against massive with context usage is python 2.6.
> > I need to use tempest with python 2.6 nowadays.
> >
> > In complex test case you would need to have more than 10 with.
> >          with ..
> >              with ..
> >                  with ..
> >                      with ..
> >                          with ..
> >                              with ..
> >                                  with ..
> >                                      with ..
> >                                          with ..
> >                                              with ..
> 
> Show me a real example of a test case that would have that many levels
> of nesting. I presume you are talking about the PoC code I put together
> that uses context managers to switch between users? If so, it's
> *switching* between users, not nested user actions. Therefore you would
> never have more than one level of nesting.
> 
> So, even if you had three different user contexts active in a single
> test case, you would still only see a single level of context manager:
> 
> def test_some_interaction(self):
>    with self.do_as('net_admin') as client:
>      self.assertSomething...
>    with self.do_as('system_admin') as client:
>      self.assertSomething...
>    with self.do_as('keystone_admin') as client:
>      self.assertSomething...
> 
> Best,
> -jay
> 
> > http://docs.python.org/2/whatsnew/2.7.html#python-3-1-features
> >
> > The syntactical sugar what usable in python 2.6 is similar to the one
> > used by testresources.
> 
> 
> 
> 
> _______________________________________________
> openstack-qa mailing list
> openstack-qa at lists.openstack.org
> http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-qa
> 



More information about the openstack-qa mailing list