Merge "Use maybe_get more"

This commit is contained in:
Zuul 2018-05-23 12:28:27 +00:00 committed by Gerrit Code Review
commit c16e459a52
2 changed files with 2 additions and 5 deletions

View File

@ -888,11 +888,8 @@ class ContainerBroker(DatabaseBroker):
def _populate_instance_cache(self, conn=None):
# load cached instance attributes from the database if necessary
if self.container is None:
if conn:
with self.maybe_get(conn) as conn:
self._do_get_info_query(conn)
else:
with self.get() as conn:
self._do_get_info_query(conn)
def _get_alternate_object_stats(self):
state = self.get_db_state()

View File

@ -618,7 +618,7 @@ class TestExampleBroker(unittest.TestCase):
with broker.get() as other_conn:
self.assertEqual(broker.conn, None)
with broker.maybe_get(other_conn) as identity_conn:
self.assertEqual(other_conn, identity_conn)
self.assertIs(other_conn, identity_conn)
self.assertEqual(broker.conn, None)
self.assertEqual(broker.conn, None)
self.assertEqual(broker.conn, conn)