29th December 2021
New: Test programs that use
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() == "/"
New: Change the logging level of a library.
sh_logger = logging.getLogger("sh") sh_logger.setLevel(logging.WARN)
New: Get all subdirectories of a directory.
[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)
New: Conditionally skip questions.
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()
New: Don't highlight the selected option by default.
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()
New: Get the columns of a database.
Last update: 2022-08-31