From 1f77fd468aa9cd6d9ea6251c56a07886a9ba7433 Mon Sep 17 00:00:00 2001 From: Shreya Malviya Date: Tue, 30 Aug 2022 14:23:57 +0530 Subject: [PATCH] UT: Add function `convert_lists_to_tuples` to utils --- monkey/tests/utils.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/monkey/tests/utils.py b/monkey/tests/utils.py index b2268e572..d2a9113ae 100644 --- a/monkey/tests/utils.py +++ b/monkey/tests/utils.py @@ -1,7 +1,7 @@ import ctypes import os from pathlib import Path -from typing import Iterable +from typing import Iterable, Mapping def is_user_admin(): @@ -31,3 +31,15 @@ def add_files_to_dir(parent_dir: Path, file_names: Iterable[str]) -> Iterable[Pa f.touch() return files + + +# This is only needed since values are compared in configuration objects in the tests. +# In practice, the list/tuple differences shouldn't make any difference since both are iterable. +def convert_lists_to_tuples(configuration: Mapping): + for key in configuration: + value = configuration[key] + if isinstance(value, list): + configuration[key] = tuple(value) + if isinstance(value, Mapping): + convert_lists_to_tuples(value) + return configuration