diff options
-rw-r--r-- | ttystatus/status.py | 6 | ||||
-rw-r--r-- | ttystatus/status_tests.py | 5 |
2 files changed, 10 insertions, 1 deletions
diff --git a/ttystatus/status.py b/ttystatus/status.py index 8f17159..b51c5c5 100644 --- a/ttystatus/status.py +++ b/ttystatus/status.py @@ -19,8 +19,12 @@ class TerminalStatus(object): '''Show status and progress information on a terminal.''' def __init__(self): - self._widgets = [] + self.clear() def add(self, widget): '''Add a new widget to the status display.''' self._widgets.append(widget) + + def clear(self): + '''Remove all widgets.''' + self._widgets = [] diff --git a/ttystatus/status_tests.py b/ttystatus/status_tests.py index 9aa6367..15a95c1 100644 --- a/ttystatus/status_tests.py +++ b/ttystatus/status_tests.py @@ -31,3 +31,8 @@ class TerminalStatusTests(unittest.TestCase): w = ttystatus.Literal('foo') self.ts.add(w) self.assertEqual(self.ts._widgets, [w]) + + def test_removes_all_widgets(self): + self.ts.add(ttystatus.Literal('foo')) + self.ts.clear() + self.assertEqual(self.ts._widgets, []) |