File tree Expand file tree Collapse file tree 2 files changed +16
-1
lines changed
Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -72,7 +72,12 @@ def format_prettytable(table, fmt='table'):
7272 """Converts SoftLayer.CLI.formatting.Table instance to a prettytable."""
7373 for i , row in enumerate (table .rows ):
7474 for j , item in enumerate (row ):
75- table .rows [i ][j ] = format_output (item )
75+ # Issue when adding items that evaulate to None (like empty lists) for Rich Tables
76+ # so we just cast those to a str
77+ if item :
78+ table .rows [i ][j ] = format_output (item )
79+ else :
80+ table .rows [i ][j ] = str (item )
7681 ptable = table .prettytable (fmt )
7782 return ptable
7883
Original file line number Diff line number Diff line change @@ -484,3 +484,13 @@ def test_format_api_list_with_none_value(self):
484484
485485 self .assertIsInstance (result , formatting .Table )
486486 self .assertEqual (result .columns , ['key' ])
487+
488+ def test_format_api_list_with_empty_array (self ):
489+ result = formatting .iter_to_table ([{'id' : 130224450 , 'activeTickets' : []}])
490+ self .assertIsInstance (result , formatting .Table )
491+ self .assertIn ('id' , result .columns )
492+ self .assertIn ('activeTickets' , result .columns )
493+ formatted = formatting .format_output (result , "table" )
494+ # No good ways to test whats actually in a Rich.Table without going through the hassel of
495+ # printing it out. As long as this didn't throw and exception it should be fine.
496+ self .assertEqual (formatted .row_count , 1 )
You can’t perform that action at this time.
0 commit comments