Skip to content

Commit

Permalink
[#1665] Fix bug in helpers.change_config
Browse files Browse the repository at this point in the history
The problem was that if the method being decorated raised an Exception, we
didn't reset the config to their original values. This patch guarantees that
we'll reset it.
  • Loading branch information
vitorbaptista committed Jun 23, 2014
1 parent e5d8c05 commit 0d84491
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions ckan/new_tests/helpers.py
Expand Up @@ -148,11 +148,13 @@ def decorator(func):
def wrapper(*args, **kwargs):
_original_config = config.copy()
config[key] = value
return_value = None

return_value = func(*args, **kwargs)

config.clear()
config.update(_original_config)
try:
return_value = func(*args, **kwargs)
finally:
config.clear()
config.update(_original_config)

return return_value
return nose.tools.make_decorator(func)(wrapper)
Expand Down

0 comments on commit 0d84491

Please sign in to comment.