Skip to content

Commit

Permalink
Handle special case of having an empty table.
Browse files Browse the repository at this point in the history
Fixes #1
  • Loading branch information
mailund committed Sep 30, 2016
1 parent 34e6890 commit b3b57b8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
4 changes: 4 additions & 0 deletions statusbar/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,10 @@ def format_table(self, width=None,
aligned across lines and then returns formatted lines as a list of
strings.
"""
# handle the special case of an empty table.
if len(self._lines) == 0:
return []

if width is None: # pragma: no cover
width = shutil.get_terminal_size()[0]

Expand Down
1 change: 1 addition & 0 deletions tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ def test_field_width_calculations(self):

def test_table_formatting(self):
st = statusbar.StatusTable()
self.assertEqual(st.format_table(), [])

label1 = "Test"
sb = st.add_status_line(label1)
Expand Down

0 comments on commit b3b57b8

Please sign in to comment.