author David Douard <david.douard@logilab.fr>
Fri, 21 Nov 2014 20:07:15 +0100
changeset 1782 69394bafe4bd
parent 1765 3c579657557f
permissions -rw-r--r--
[narval] the lgp_suffix option of lgp.build checker is now used as is it is now the responsibility of the caller to build the desired suffix instead of a hardcoded ~rev<csid>.

"""unit tests for the apycotlib.writer module"""

from logilab.common.testlib import TestCase, unittest_main
import cubes.apycot.testutils # required for sys.path black magic
from apycotlib.writer import BaseDataWriter

class BaseDataWriterTC(TestCase):

    def setUp(self):
        self.writer = BaseDataWriter(None, 1)

    def test__msg_info_01(self):
        path, line, msg = self.writer._msg_info('bonjour %s', 'vous')
        self.assertEqual(path, None)
        self.assertEqual(line, None)
        self.assertEqual(msg, 'bonjour vous')

    def test__msg_info_02(self):
        path, line, msg = self.writer._msg_info('bonjour %s', 'vous', path='/tmp', line=1)
        self.assertEqual(path, '/tmp')
        self.assertEqual(line, 1)
        self.assertEqual(msg, 'bonjour vous')

    def test__msg_info_03(self):
            path, line, msg = self.writer._msg_info('oops %s', 'badaboum', tb=True)
        self.assertEqual(path, None)
        self.assertEqual(line, None)
        self.assertTrue(msg.startswith('oops badaboum'))
        self.assertTrue('Traceback' in msg)

if __name__ == '__main__':