diff options
author | Lars Wirzenius <liw@liw.fi> | 2010-06-14 16:03:07 +1200 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2010-06-14 16:03:07 +1200 |
commit | 3e49cb31bb5c1c3b172872fb4cd88a31cb116bd9 (patch) | |
tree | 6444a1c77b2d0c500de60eab06080d81d31ebb99 | |
parent | 912c17b55037c245eeec85c7df6d17745b68ad5f (diff) | |
download | python-ttystatus-3e49cb31bb5c1c3b172872fb4cd88a31cb116bd9.tar.gz |
Fix bug in ttystatus.Pathname widget: if value is not set in master,
but update is called, do not crash.
-rw-r--r-- | debian/changelog | 7 | ||||
-rw-r--r-- | ttystatus/pathname.py | 2 | ||||
-rw-r--r-- | ttystatus/pathname_tests.py | 4 |
3 files changed, 12 insertions, 1 deletions
diff --git a/debian/changelog b/debian/changelog index ed436d0..c6388a7 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +python-ttystatus (0.3) squeeze; urgency=low + + * Fix bug in ttystatus.Pathname widget: if value is not set in master, + but update is called, do not crash. + + -- Lars Wirzenius <liw@liw.fi> Mon, 14 Jun 2010 15:29:53 +1200 + python-ttystatus (0.2) squeeze; urgency=low * New release. diff --git a/ttystatus/pathname.py b/ttystatus/pathname.py index fe8b043..ac51a31 100644 --- a/ttystatus/pathname.py +++ b/ttystatus/pathname.py @@ -29,7 +29,7 @@ class Pathname(ttystatus.Widget): self._key = key def update(self, master, width): - v = master[self._key] + v = master.get(self._key, '') if len(v) > width: ellipsis = '...' if len(ellipsis) < width: diff --git a/ttystatus/pathname_tests.py b/ttystatus/pathname_tests.py index a4fe411..f0c54d5 100644 --- a/ttystatus/pathname_tests.py +++ b/ttystatus/pathname_tests.py @@ -30,6 +30,10 @@ class PathnameTests(unittest.TestCase): def test_updates(self): self.w.update({'foo': 'bar'}, 999) self.assertEqual(str(self.w), 'bar') + + def test_handles_update_to_other_value(self): + self.w.update({'other': 1}, 999) + self.assertEqual(str(self.w), '') def test_truncates_from_beginning(self): self.w.update({'foo': 'foobar'}, 5) |