29th December 2021
shcan be patched in your tests the typical way, with
from unittest.mock import patch import sh def get_something(): return sh.pwd() @patch("sh.pwd", create=True) def test_something(pwd): pwd.return_value = "/" assert get_something() == "/"
sh_logger = logging.getLogger("sh") sh_logger.setLevel(logging.WARN)
[x for x in os.walk(directory)]
New: Move a file.
import os os.rename("path/to/current/file.foo", "path/to/new/destination/for/file.foo")
New: Copy a file.
import shutil shutil.copyfile(src_file, dest_file)
Sometimes it is helpful to be able to skip a question based on a condition. To avoid the need for an if around the question, you can pass the condition when you create the question:
import questionary DISABLED = True response = questionary.confirm("Are you amazed?").skip_if(DISABLED, default=True).ask()
If you don't want to highlight the default choice in the
selectquestion use the next style:
from questionary import Style choice = select( "Question title: ", choices=['a', 'b', 'c'], default='a', style=Style([("selected", "noreverse")]), ).ask()