From a099b21671d4f0d27c7466b1168681ff97f5cca2 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Tue, 23 Aug 2022 21:21:28 +0200 Subject: [PATCH] lib: reset settings when error is raised in patch Signed-off-by: Jens Langhammer --- authentik/lib/config.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/authentik/lib/config.py b/authentik/lib/config.py index 02e64de13..943d1e147 100644 --- a/authentik/lib/config.py +++ b/authentik/lib/config.py @@ -152,8 +152,10 @@ class ConfigLoader: """Context manager for unittests to patch a value""" original_value = self.y(path) self.y_set(path, value) - yield - self.y_set(path, original_value) + try: + yield + finally: + self.y_set(path, original_value) @property def raw(self) -> dict: