def testExceptionToken(self): def func(): pass pattern = lexers.Pattern(name='foo', regex=re.compile('\S'), function=func) tokens.ExceptionToken(pattern=pattern, traceback='foo')
def testErrorToken(self): def func(): pass pattern = lexers.Pattern(name='foo', regex=re.compile('\S'), function=func) tokens.ErrorToken(pattern=pattern)
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)
def testInfo(self): regex = re.compile(r'(?P<key>foo)') match = regex.search('foo bar') pattern = lexers.Pattern(name='name', regex=regex, function=Proxy()) info = lexers.LexerInformation(match=match, pattern=pattern, line=42) self.assertEqual(info.line, 42) self.assertEqual(info.pattern, 'name') self.assertEqual(list(info.keys()), [0, 1, 'key']) self.assertIn('key', info) self.assertIn('line:42', str(info))