diff options
author | Lars Wirzenius <liw@liw.fi> | 2012-04-15 19:25:31 +0100 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2012-04-15 19:25:31 +0100 |
commit | 194fa11664ce1aff4c14097fe1e733c19873d8b2 (patch) | |
tree | a7571b39066717ae046b3b99799ebdde62303c8a | |
parent | 88d494d0045df84f89a01be8c7df2c195635a057 (diff) | |
download | python-ttystatus-194fa11664ce1aff4c14097fe1e733c19873d8b2.tar.gz |
Fix Pathname to render from end instead of beginning
-rw-r--r-- | ttystatus/pathname.py | 4 | ||||
-rw-r--r-- | ttystatus/pathname_tests.py | 11 |
2 files changed, 10 insertions, 5 deletions
diff --git a/ttystatus/pathname.py b/ttystatus/pathname.py index bf5fe5a..0fbdbd7 100644 --- a/ttystatus/pathname.py +++ b/ttystatus/pathname.py @@ -31,8 +31,8 @@ class Pathname(ttystatus.Widget): self._key = key self.pathname = '' - def render(self, render): - return self.pathname + def render(self, width): + return self.pathname[-width:] def update(self, master): self.pathname = master.get(self._key, '') diff --git a/ttystatus/pathname_tests.py b/ttystatus/pathname_tests.py index 1191f43..70d6c1e 100644 --- a/ttystatus/pathname_tests.py +++ b/ttystatus/pathname_tests.py @@ -28,12 +28,17 @@ class PathnameTests(unittest.TestCase): self.assertFalse(self.w.static_width) def test_is_empty_initially(self): - self.assertEqual(self.w.render(0), '') + self.assertEqual(self.w.render(10), '') def test_updates(self): self.w.update({'foo': 'bar'}) - self.assertEqual(self.w.render(0), 'bar') + self.assertEqual(self.w.render(10), 'bar') def test_handles_update_to_other_value(self): self.w.update({'other': 1}) - self.assertEqual(self.w.render(0), '') + self.assertEqual(self.w.render(10), '') + + def test_truncates_from_beginning(self): + self.w.update({'foo': '/this/is/a/path'}) + self.assertEqual(self.w.render(6), 'a/path') + |