view test/test_rlog.py @ 2633:a9e1fff1e793

I thought I committed this last night. Ho hum. - This implements most of the rest of the new tracker config layout: - dbinit.py split between schema.py and initial_data.py - interfaces.py gone - tracker and detectors __init__.py gone - Added some missing functionality to backends: db_exists test and db_nuke. - Implemented configuration file options in postgresql backend. - Cleaned up tracker initialisation a lot.
author Richard Jones <richard@users.sourceforge.net>
date Tue, 27 Jul 2004 00:57:19 +0000
parents fa50e1347397
children 6fe75dcb0b34
line wrap: on
line source

import unittest, StringIO

from roundup import rlog

class LoggingTestCase(unittest.TestCase):
    def setUp(self):
        self.logging = rlog.BasicLogging()
        self.file = StringIO.StringIO()
        self.logging.setFile(self.file)
    def testLevels(self):
        logger = self.logging.getLogger('test')
        v1 = self.file.getvalue()
        logger.debug('test')
        v2 = self.file.getvalue()
        self.assertEqual(v1, v2, 'Logged when should not have')

        v1 = self.file.getvalue()
        logger.info('test')
        v2 = self.file.getvalue()
        self.assertNotEqual(v1, v2, 'Nothing logged')

        v1 = self.file.getvalue()
        logger.warning('test')
        v2 = self.file.getvalue()
        self.assertNotEqual(v1, v2, 'Nothing logged')

        v1 = self.file.getvalue()
        logger.error('test')
        v2 = self.file.getvalue()
        self.assertNotEqual(v1, v2, 'Nothing logged')

        v1 = self.file.getvalue()
        try:
            1/0
        except:
            logger.exception('test')
        v2 = self.file.getvalue()
        self.assertNotEqual(v1, v2, 'Nothing logged')

def test_suite():
    suite = unittest.TestSuite()
    suite.addTest(unittest.makeSuite(LoggingTestCase))
    return suite

if __name__ == '__main__':
    runner = unittest.TextTestRunner()
    unittest.main(testRunner=runner)


Roundup Issue Tracker: http://roundup-tracker.org/