diff --git a/tests/texttable_test.py b/tests/texttable_test.py index 342c160..1e31aa7 100755 --- a/tests/texttable_test.py +++ b/tests/texttable_test.py @@ -543,6 +543,16 @@ def testTableWithLabels(self): t.LabelValueTable(['c', 'a'])) self.assertRaises(texttable.TableError, t.LabelValueTable, ['a', 'z']) + def testTableWithLabelsDefaultMultiCharHeader(self): + t = texttable.TextTable() + t.header = ('Interface', 'Status') + t.Append(('ge-0/0/0', 'up')) + t.Append(('ge-0/0/1', 'down')) + self.assertEqual( + '# LABEL Interface\nge-0/0/0.Status up\nge-0/0/1.Status down\n', + t.LabelValueTable()) + self.assertEqual(t.LabelValueTable(['Interface']), t.LabelValueTable()) + def testTextJustify(self): t = texttable.TextTable() self.assertEqual([' a '], t._TextJustify('a', 6)) diff --git a/textfsm/texttable.py b/textfsm/texttable.py index 71450a0..e136814 100755 --- a/textfsm/texttable.py +++ b/textfsm/texttable.py @@ -905,7 +905,7 @@ def LabelValueTable(self, label_list=None): Raises: TableError: If specified label is not a column header of the table. """ - label_list = label_list or self._Header()[0] + label_list = label_list or [self._Header()[0]] # Ensure all labels are valid. for label in label_list: if label not in self._Header():