Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion knack/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,8 @@ def _auto_table(self, result):
def dump(self, data):
from tabulate import tabulate
table_data = self._auto_table(data)
table_str = tabulate(table_data, headers="keys", tablefmt="simple") if table_data else ''
table_str = tabulate(table_data, headers="keys", tablefmt="simple",
disable_numparse=True) if table_data else ''
if table_str == '\n':
raise ValueError('Unable to extract fields for table.')
return table_str + '\n'
Expand Down
15 changes: 13 additions & 2 deletions tests/test_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ def test_out_table(self):
obj['lun'] = 0
output_producer.out(CommandResultItem(obj), formatter=format_table, out_file=self.io)
self.assertEqual(normalize_newlines(self.io.getvalue()), normalize_newlines(
"""Active Lun Val
"""Active Lun Val
-------- ----- --------
True 0 0b1f6472
True 0 0b1f6472
"""))

def test_out_table_list_of_lists(self):
Expand Down Expand Up @@ -158,6 +158,17 @@ def test_out_table_no_query_yes_jmespath_table_transformer(self):
"""Name Val Active
------ -------------- --------
qwerty 0b1f6472qwerty True
"""))

def test_out_table_with_number(self):
output_producer = OutputProducer(cli_ctx=self.mock_ctx)
obj = OrderedDict()
obj['Sku'] = '6.10'
output_producer.out(CommandResultItem(obj), formatter=format_table, out_file=self.io)
self.assertEqual(normalize_newlines(self.io.getvalue()), normalize_newlines(
"""Sku
-----
6.10
"""))

# TSV output tests
Expand Down