summaryrefslogtreecommitdiff
path: root/nova/tests/fixtures.py
diff options
context:
space:
mode:
authorDan Smith <dansmith@redhat.com>2017-09-21 10:05:17 -0700
committerDan Smith <dansmith@redhat.com>2017-09-29 20:39:12 -0700
commitaf05d6208b4f95f1d9b882ed376552b75bb87506 (patch)
treef1a0b269e3024e9695202a0e2258eedc905d12bc /nova/tests/fixtures.py
parentd5244f2fae1e0b0c6e80c1e3b2f1b48fd2c8d1d9 (diff)
downloadnova-af05d6208b4f95f1d9b882ed376552b75bb87506.tar.gz
Fix CellDatabases fixture swallowing exceptions
The _wrap_target_cell() helper in the CellDatabases fixture was accidentally changing the behavior of the target_cell() functionality that it wraps by swallowing any exceptions raised and always returning None. That was not intentional, and introduced by copying the exception handler below a special case and returning None in a finally: context. This just removes that exception handler to allow it to propagate to the caller (as it would in production code), but returns (the intended special case) if nothing is raised. This also fixes a bit of the instance_list module that was working around this quirk so that the code is more natural. Change-Id: Id611678f53a2ad023dd336e30e62d5c3ae9ffd6e
Diffstat (limited to 'nova/tests/fixtures.py')
-rw-r--r--nova/tests/fixtures.py8
1 files changed, 3 insertions, 5 deletions
diff --git a/nova/tests/fixtures.py b/nova/tests/fixtures.py
index a63c20287e..1be06f1ac4 100644
--- a/nova/tests/fixtures.py
+++ b/nova/tests/fixtures.py
@@ -419,11 +419,9 @@ class CellDatabases(fixtures.Fixture):
# cell_mapping of None. Since we're controlling our
# own targeting in this fixture, we need to call this out
# specifically and avoid switching global database state
- try:
- with self._real_target_cell(context, cell_mapping) as c:
- yield c
- finally:
- return
+ with self._real_target_cell(context, cell_mapping) as c:
+ yield c
+ return
ctxt_mgr = self._ctxt_mgrs[cell_mapping.database_connection]
# This assumes the next local DB access is the same cell that
# was targeted last time.