summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2010-06-06 14:10:57 +1200
committerLars Wirzenius <liw@liw.fi>2010-06-06 14:10:57 +1200
commit22b38e86eca00f96b1396240639ce85f27c92f76 (patch)
tree873d96ecf87c7c7475704f9009dc51dc07b416cc
parent164affe3ad8dafbe70e7f614ef875f35a36a87c7 (diff)
downloadpython-ttystatus-22b38e86eca00f96b1396240639ce85f27c92f76.tar.gz
Implement TerminalStatus.clear.
-rw-r--r--ttystatus/status.py6
-rw-r--r--ttystatus/status_tests.py5
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, [])