Commit 6d09a5b5 by Renzo Lucioni

Merge pull request #10923 from edx/renzo/robust-modified-courseware

Make modifies_courseware robust to exceptions raised during tests
parents b5f190dd 124afe48
......@@ -317,10 +317,20 @@ class SharedModuleStoreTestCase(TestCase):
@functools.wraps(f)
def wrapper(*args, **kwargs):
"""Call the object method, and reset the test case afterwards."""
try:
# Attempt execution of the test.
return_val = f(*args, **kwargs)
except:
# If the test raises an exception, re-raise it.
raise
else:
# Otherwise, return the test's return value.
return return_val
finally:
# In either case, call SharedModuleStoreTestCase.reset() "on the way out."
# For more, see here: https://docs.python.org/2/tutorial/errors.html#defining-clean-up-actions.
obj = args[0]
obj.reset()
return return_val
return wrapper
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment