yahoo-eng-team team mailing list archive
-
yahoo-eng-team team
-
Mailing list archive
-
Message #47659
[Bug 1554617] Re: Tests for aggregates use getattr() improperly
Reviewed: https://review.openstack.org/268712
Committed: https://git.openstack.org/cgit/openstack/nova/commit/?id=5c51e3c21d2d7820a0a96403d5fdd8dd16d8ed30
Submitter: Jenkins
Branch: master
commit 5c51e3c21d2d7820a0a96403d5fdd8dd16d8ed30
Author: Ryan Rossiter <rlrossit@xxxxxxxxxx>
Date: Sun Jan 17 00:50:41 2016 +0000
Aggregate object fixups
In the original removal of DictCompat from the Aggregate object, the
aggregate.get(foo, default) calls were changed to getattr(aggregate,
foo, default). This is an incorrect change, because the default of
getattr() is only used if AttributeError is raised. The original get()
call would return the default if the variable was not set, but in order
to get the default with getattr() 'in' has to be used. So now, the
getattr() calls are changed to:
foo = aggregate.foo if 'foo' in aggregate else default
Also, a comment was added for using getattr() on all aggregate fields,
explaining we can do the getattr() and not worry about metadata being
unset, because the compute API always sets it. nova.objects.base also
has a helper method to compare the primitives of two objects to check if
they're equal, so a helper method in the tests were changed over to use
that helper method.
Change-Id: Iee651704c90fcdda0938f907924a4565399601d7
Closes-Bug: #1554617
** Changed in: nova
Status: In Progress => Fix Released
--
You received this bug notification because you are a member of Yahoo!
Engineering Team, which is subscribed to OpenStack Compute (nova).
https://bugs.launchpad.net/bugs/1554617
Title:
Tests for aggregates use getattr() improperly
Status in OpenStack Compute (nova):
Fix Released
Bug description:
Because objects do not raise AttributeError if an attribute is not
set, the default functionality of getattr() cannot be used with
objects. Instead, an 'in' check needs to be used on the object, and if
that passes, I can use getattr(). If that fails, I need to give the
default.
To manage notifications about this bug go to:
https://bugs.launchpad.net/nova/+bug/1554617/+subscriptions
References