view test/test_rlog.py @ 2983:9614a101b68f

Stuff from the train ride this morning: - Extend the property concept in Permissions to allow a list of properties - Fix the cgi templating code to check the correct permission when rendering edit fields - A swag of changes (just the start) fixing up the customisation doc for the new tracker layout and permissions setup
author Richard Jones <richard@users.sourceforge.net>
date Tue, 30 Nov 2004 08:32:57 +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/