From 3e49cb31bb5c1c3b172872fb4cd88a31cb116bd9 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Mon, 14 Jun 2010 16:03:07 +1200 Subject: Fix bug in ttystatus.Pathname widget: if value is not set in master, but update is called, do not crash. --- debian/changelog | 7 +++++++ ttystatus/pathname.py | 2 +- ttystatus/pathname_tests.py | 4 ++++ 3 files changed, 12 insertions(+), 1 deletion(-) 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 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) -- cgit v1.2.1