diff options
author | Lars Wirzenius <liw@liw.fi> | 2011-08-29 18:41:55 +0100 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2011-08-29 18:41:55 +0100 |
commit | 26d564c10f8c62c955f049db03ca26f8cadb943e (patch) | |
tree | f246c095b8b4b014a9730eb4677badbb895a8b26 | |
parent | 07c6c917bfe45409973124e0a8ab208e366c4e08 (diff) | |
download | python-ttystatus-26d564c10f8c62c955f049db03ca26f8cadb943e.tar.gz |
Fix tests so they pass.
-rw-r--r-- | ttystatus/messager.py | 2 | ||||
-rw-r--r-- | ttystatus/messager_tests.py | 13 | ||||
-rw-r--r-- | ttystatus/status_tests.py | 5 |
3 files changed, 16 insertions, 4 deletions
diff --git a/ttystatus/messager.py b/ttystatus/messager.py index 6085132..43a04cf 100644 --- a/ttystatus/messager.py +++ b/ttystatus/messager.py @@ -135,7 +135,7 @@ class Messager(object): try: f.write('%s\n' % string) f.flush() - except IOError: # pragma: no cover + except IOError: # We ignore these. No point in crashing if terminal is bad. pass self._overwrite(old) diff --git a/ttystatus/messager_tests.py b/ttystatus/messager_tests.py index 6f9bc8a..3ce889e 100644 --- a/ttystatus/messager_tests.py +++ b/ttystatus/messager_tests.py @@ -93,9 +93,18 @@ class MessagerTests(unittest.TestCase): self.assertEqual(self.output.getvalue(), 'foo\r \r') def test_notify_removes_message_and_puts_it_back_afterwards(self): + f = StringIO.StringIO() self.messager.write('foo') - self.messager.notify('bar') - self.assertEqual(self.output.getvalue(), 'foo\r \rbar\nfoo') + self.messager.notify('bar', f) + self.assertEqual(self.output.getvalue(), 'foo\r \rfoo') + self.assertEqual(f.getvalue(), 'bar\n') + + def test_notify_does_not_mind_ioerror(self): + f = open('/dev/full', 'w') + self.messager.write('foo') + self.messager.notify('bar', f) + self.assertEqual(self.output.getvalue(), 'foo\r \rfoo') + f.close() def test_finish_flushes_unwritten_message(self): self.messager._now = lambda: 0 diff --git a/ttystatus/status_tests.py b/ttystatus/status_tests.py index 068212a..9e6d0ac 100644 --- a/ttystatus/status_tests.py +++ b/ttystatus/status_tests.py @@ -37,7 +37,7 @@ class DummyMessager(object): def write(self, string): self.written.write(string) - def notify(self, string): + def notify(self, string, f): pass def finish(self): @@ -117,6 +117,9 @@ class TerminalStatusTests(unittest.TestCase): def test_has_notify_method(self): self.assertEqual(self.ts.notify('foo'), None) + def test_has_error_method(self): + self.assertEqual(self.ts.error('foo'), None) + def test_has_finish_method(self): self.assertEqual(self.ts.finish(), None) |