Skip to content

Commit ad0e87c

Browse files
committed
PYTHON-2022 Fix potential UnboundLocalError in gridfs test
1 parent 5604156 commit ad0e87c

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

test/test_gridfs_spec.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,13 +146,17 @@ def run_scenario(self):
146146
converted_args = dict((camel_to_snake(c), v)
147147
for c, v in args.items())
148148

149+
expect_error = test['assert'].get("error", False)
150+
result = None
149151
error = None
150152
try:
151153
result = operation(**converted_args)
152154

153155
if 'download' in test['act']['operation']:
154156
result = Binary(result.read())
155157
except Exception as exc:
158+
if not expect_error:
159+
raise
156160
error = exc
157161

158162
self.init_expected_db(test, result)
@@ -164,7 +168,7 @@ def run_scenario(self):
164168
"ChunkIsWrongSize": CorruptGridFile,
165169
"RevisionNotFound": NoFile}
166170

167-
if test['assert'].get("error", False):
171+
if expect_error:
168172
self.assertIsNotNone(error)
169173
self.assertIsInstance(error, errors[test['assert']['error']],
170174
test['description'])

0 commit comments

Comments
 (0)