File tree Expand file tree Collapse file tree 2 files changed +11
-1
lines changed
Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -1834,6 +1834,7 @@ def ppretty(
18341834 max_string : int | None = None ,
18351835 max_depth : int | None = None ,
18361836 expand_all : bool = False ,
1837+ end : str = "\n " ,
18371838 ) -> None :
18381839 """Pretty print an object.
18391840
@@ -1849,7 +1850,9 @@ def ppretty(
18491850 :param max_string: maximum length of strings before truncating, or None to disable. Defaults to None.
18501851 :param max_depth: maximum depth for nested data structures, or None for unlimited depth. Defaults to None.
18511852 :param expand_all: Expand all containers. Defaults to False.
1853+ :param end: string to write at end of printed text. Defaults to a newline.
18521854 """
1855+ # The overflow and soft_wrap settings match the behavior of rich.pretty.pprint().
18531856 pretty_obj = Pretty (
18541857 obj ,
18551858 indent_size = indent_size ,
@@ -1865,6 +1868,7 @@ def ppretty(
18651868 file or self .stdout ,
18661869 pretty_obj ,
18671870 soft_wrap = True ,
1871+ end = end ,
18681872 )
18691873
18701874 def get_bottom_toolbar (self ) -> list [str | tuple [str , str ]] | None :
Original file line number Diff line number Diff line change @@ -3505,6 +3505,7 @@ def test_ppretty(base_app: cmd2.Cmd) -> None:
35053505 indent_size = 2 ,
35063506 max_depth = 5 ,
35073507 expand_all = True ,
3508+ end = "\n \n " ,
35083509 )
35093510
35103511 # Verify Pretty was instantiated with the correct arguments
@@ -3521,7 +3522,12 @@ def test_ppretty(base_app: cmd2.Cmd) -> None:
35213522
35223523 # Verify print_to() was called with the mock pretty object and soft_wrap=True
35233524 # It should default to self.stdout when no file is provided
3524- mock_print_to .assert_called_once_with (base_app .stdout , mock_pretty_obj , soft_wrap = True )
3525+ mock_print_to .assert_called_once_with (
3526+ base_app .stdout ,
3527+ mock_pretty_obj ,
3528+ soft_wrap = True ,
3529+ end = "\n \n " ,
3530+ )
35253531
35263532
35273533# we override cmd.parseline() so we always get consistent
You can’t perform that action at this time.
0 commit comments