From 154d6f417cea336cbbefbc8478377670e96dd546 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Thu, 15 Sep 2011 14:23:38 +0100 Subject: Fix String to handle non-string values. --- NEWS | 5 +++++ ttystatus/string.py | 2 +- ttystatus/string_tests.py | 4 ++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 58e8280..821c26f 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,11 @@ NEWS file for ttystatus ======================= +Version 0.15, released UNRELEASED +--------------------------------- + +* Bugfix: the String widget now handles non-string values. + Version 0.14, released 2011-08-31 --------------------------------- diff --git a/ttystatus/string.py b/ttystatus/string.py index 1dc3023..32a76ea 100644 --- a/ttystatus/string.py +++ b/ttystatus/string.py @@ -27,7 +27,7 @@ class String(ttystatus.Widget): self.value = '' def format(self): - return self.value + return str(self.value) def update(self, master, width): self.value = master[self._key] diff --git a/ttystatus/string_tests.py b/ttystatus/string_tests.py index b0e17dd..39f480a 100644 --- a/ttystatus/string_tests.py +++ b/ttystatus/string_tests.py @@ -30,3 +30,7 @@ class StringTests(unittest.TestCase): def test_updates(self): self.s.update({'foo': 'bar'}, 999) self.assertEqual(str(self.s), 'bar') + + def test_handles_non_string_value(self): + self.s.update({'foo': 123}, 999) + self.assertEqual(str(self.s), '123') -- cgit v1.2.1