Пример #1
0
    def testPattern(self):
        comp = components.TokenComponent()

        regex = re.compile(r'foo')
        pattern = lexers.Pattern('foo', regex, comp)
        pick = do_pickle(pattern)

        self.assertEqual(pattern.name, pick.name)
        self.assertEqual(pattern.regex, pick.regex)
        self.assertIs(pattern.function, pick.function)
Пример #2
0
    def testAddExceptions(self):
        MooseDocs.LOG_LEVEL = logging.DEBUG
        reader = readers.Reader(lexers.RecursiveLexer('foo'))

        with self.assertRaises(exceptions.MooseDocsException) as e:
            reader.add([], u'', '')
        self.assertIn("The argument 'group'", e.exception.message)

        with self.assertRaises(exceptions.MooseDocsException) as e:
            reader.add('foo', u'', '')
        self.assertIn("The argument 'component'", e.exception.message)

        with self.assertRaises(exceptions.MooseDocsException) as e:
            reader.add('foo', components.TokenComponent(), [])
        self.assertIn("The argument 'location'", e.exception.message)