diff --git a/mylib/config.py b/mylib/config.py index ec50ba1..387ad96 100644 --- a/mylib/config.py +++ b/mylib/config.py @@ -222,6 +222,14 @@ class BaseOption: # pylint: disable=too-many-instance-attributes lines.append('') return '\n'.join(lines) + @staticmethod + def _get_user_input(prompt): + """ + Get user console input + Note: do not use directly input() to allow to mock it in tests + """ + return input(prompt) + def _ask_value(self, prompt=None, **kwargs): """ Ask to user to enter value of this option and return it """ if self.comment: @@ -236,7 +244,7 @@ class BaseOption: # pylint: disable=too-many-instance-attributes ) else: prompt += f'[{self.to_config(default_value)}] ' - value = input(prompt) + value = self._get_user_input(prompt) return default_value if value == '' else value def ask_value(self, set_it=True):