From 0d84491eed428843d152ef0fcf43f7d616dcc439 Mon Sep 17 00:00:00 2001 From: Vitor Baptista Date: Mon, 23 Jun 2014 18:44:23 -0300 Subject: [PATCH] [#1665] Fix bug in helpers.change_config 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. --- ckan/new_tests/helpers.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/ckan/new_tests/helpers.py b/ckan/new_tests/helpers.py index 3b5d72cb935..810d9a065d6 100644 --- a/ckan/new_tests/helpers.py +++ b/ckan/new_tests/helpers.py @@ -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)