author Julien Cristau <julien.cristau@logilab.fr>
Wed, 09 Jul 2014 11:36:06 +0200
changeset 1547 9012705e9076
parent 1501 a45f5a997ab2
child 1549 46be4dfc1070
permissions -rw-r--r--
[narval/debcheck] use a glob instead of a recursive os.walk to find *.changes We know where those files are, there's no need to do a recursive search. This also avoids issues with os.walk with non-ascii file names. ***

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

import os
from logilab.common.testlib import TestCase, unittest_main

import cubicweb.devtools
import cubes.apycot.testutils

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__':