Merge "Use maybe_get more"
This commit is contained in:
commit
c16e459a52
@ -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()
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user