示例#1
0
 def test_04_debug(self):
     """
     test debug level
     """
     Messager.debug(u'Hello 世界!')
     json_dic = {}
     Messager.output_json(json_dic)
     self.assertEqual(
         json_dic,
         {'messages': [(u'Hello \u4e16\u754c\uff01', 'debug', 3)]})
示例#2
0
 def test_03_error(self):
     """
     test error level
     """
     Messager.error(u'Hello 世界!')
     json_dic = {}
     Messager.output_json(json_dic)
     self.assertEqual(
         json_dic,
         {'messages': [(u'Hello \u4e16\u754c\uff01', 'error', 3)]})
示例#3
0
 def test_01_warning(self):
     """
     test warning level
     """
     Messager.warning(u'Hello 世界!')
     json_dic = {}
     Messager.output_json(json_dic)
     self.assertEqual(
         json_dic,
         {'messages': [(u'Hello \u4e16\u754c\uff01', 'warning', 3)]})
示例#4
0
 def test_02_info(self):
     """
     test info level
     """
     Messager.info(u'Hello 世界!')
     json_dic = {}
     Messager.output_json(json_dic)
     self.assertEqual(
         json_dic,
         {'messages': [(u'Hello \u4e16\u754c\uff01', 'comment', 3)]})
示例#5
0
    def test_tokeniser_by_name(self):
        """
        tokeniser_by_name
        """
        self.assertEqual(tokenise.tokeniser_by_name('whitespace'),
                         tokenise.whitespace_token_boundary_gen)
        self.assertEqual(tokenise.tokeniser_by_name('ptblike'),
                         tokenise.gtb_token_boundary_gen)

        # check that no messsage has been published
        self.assertEqual(Messager.output_json({}), {'messages': []})

        # Any other name will returns default whitespace
        # and leave a message
        self.assertEqual(tokenise.tokeniser_by_name('invalid!'),
                         tokenise.whitespace_token_boundary_gen)
        self.assertEqual(
            Messager.output_json({}), {
                'messages': [('Unrecognized tokenisation option , '
                              'reverting to whitespace '
                              'tokenisation.', 'warning', 3)]
            })