Skip to content

Commit 77403d5

Browse files
authored
tab output: disable number parse (#88)
1 parent 7cbee25 commit 77403d5

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

knack/output.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,8 @@ def _auto_table(self, result):
187187
def dump(self, data):
188188
from tabulate import tabulate
189189
table_data = self._auto_table(data)
190-
table_str = tabulate(table_data, headers="keys", tablefmt="simple") if table_data else ''
190+
table_str = tabulate(table_data, headers="keys", tablefmt="simple",
191+
disable_numparse=True) if table_data else ''
191192
if table_str == '\n':
192193
raise ValueError('Unable to extract fields for table.')
193194
return table_str + '\n'

tests/test_output.py

+13-2
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,9 @@ def test_out_table(self):
8686
obj['lun'] = 0
8787
output_producer.out(CommandResultItem(obj), formatter=format_table, out_file=self.io)
8888
self.assertEqual(normalize_newlines(self.io.getvalue()), normalize_newlines(
89-
"""Active Lun Val
89+
"""Active Lun Val
9090
-------- ----- --------
91-
True 0 0b1f6472
91+
True 0 0b1f6472
9292
"""))
9393

9494
def test_out_table_list_of_lists(self):
@@ -158,6 +158,17 @@ def test_out_table_no_query_yes_jmespath_table_transformer(self):
158158
"""Name Val Active
159159
------ -------------- --------
160160
qwerty 0b1f6472qwerty True
161+
"""))
162+
163+
def test_out_table_with_number(self):
164+
output_producer = OutputProducer(cli_ctx=self.mock_ctx)
165+
obj = OrderedDict()
166+
obj['Sku'] = '6.10'
167+
output_producer.out(CommandResultItem(obj), formatter=format_table, out_file=self.io)
168+
self.assertEqual(normalize_newlines(self.io.getvalue()), normalize_newlines(
169+
"""Sku
170+
-----
171+
6.10
161172
"""))
162173

163174
# TSV output tests

0 commit comments

Comments
 (0)