view test/test_rlog.py @ 2649:1df7d4a41da4

Buncha stuff (sorry about the large checkin): - Permissions may now be defined on a per-property basis - added "Create" Permission. Replaces the "Web"- and "Email Registration" Permissions. - added option to turn off registration confirmation via email ("instant_registration" in config) Migrated the user edit/view permission to use check code. Fixed a buncha stuff in the default templates. Needs a thorough review though.
author Richard Jones <richard@users.sourceforge.net>
date Wed, 28 Jul 2004 02:29:46 +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/