UT: Add function `convert_lists_to_tuples` to utils

This commit is contained in:
Shreya Malviya 2022-08-30 14:23:57 +05:30
parent 9b924c55b6
commit 1f77fd468a
1 changed files with 13 additions and 1 deletions

View File

@ -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