diff options
author | Sylvain Th?nault <sylvain.thenault@logilab.fr> | 2009-08-07 10:54:45 +0200 |
---|---|---|
committer | Sylvain Th?nault <sylvain.thenault@logilab.fr> | 2009-08-07 10:54:45 +0200 |
commit | 29fbb301a61d85214a0de76b7308ffb7d9c9fd96 (patch) | |
tree | 4016396e39749c537439473b648eb39e5908dbb9 /test | |
parent | a37b556013111e0593f2600acc3dab71bff2968b (diff) | |
download | logilab-common-29fbb301a61d85214a0de76b7308ffb7d9c9fd96.tar.gz |
remove modules deprecated for a while
Diffstat (limited to 'test')
-rw-r--r-- | test/unittest_logger.py | 53 |
1 files changed, 0 insertions, 53 deletions
diff --git a/test/unittest_logger.py b/test/unittest_logger.py deleted file mode 100644 index 071893f..0000000 --- a/test/unittest_logger.py +++ /dev/null @@ -1,53 +0,0 @@ -"""unittests for logilab.common.logger""" - -from tempfile import mktemp -import os -import sys -from cStringIO import StringIO - -from logilab.common.testlib import TestCase, unittest_main -from logilab.common.logger import * - - -def get_logged_messages(output): - """strip timestamps and extract effective logged text - (log lines look like: [timestamp] message) - """ - return [line.split(']')[-1].strip() for line in output.splitlines()] - - -class LoggerTC(TestCase): - - def test_defaultlogging(self): - # redirect stdout so that we can test - stdout_backup = sys.stdout - sys.stdout = StringIO() - # make default logger - logger = make_logger() - logger.log(message='hello') - logger.log(message='world') - output = sys.stdout.getvalue() - msg = get_logged_messages(output) - # restore stdout - sys.stdout = stdout_backup - self.assertEquals(msg, ['hello', 'world']) - - def test_filelogging(self): - filename = mktemp(dir='/tmp') - # make file logger - logger = make_logger(method='file', output=filename) - logger.log(message='hello') - logger.log(message='world') - # make sure everything gets flushed (testing purpose) - logger.output.flush() - output = open(filename).read() #os.read(descr, 300) - # close everything correcly - #os.close(descr) - logger.output.close() - # remove file - os.remove(filename) - self.assertEquals(get_logged_messages(output), ['hello', 'world']) - -if __name__ == '__main__': - unittest_main() - |