Ejemplo n.º 1
0
 def test_handles_single_line_comments(self):
     comments, source = split(self.get_tokens('python.py'))
     self.assertEqual(tuple(comments), (
         (Comment, u'# This is a header comment'), (Text, u'\n'),
         (Comment, u'# splitted into two lines.'), (Text, u'\n'),
         (Text, u'\n'), (Comment, u'# Hello!'), (Text, u'\n'),
     ))
     self.assertEqual(tuple(source), (
         (Keyword, u'print'), (Text, u' '), (String, u"'"),
         (String, u'Hello, World!'), (String, u"'"), (Text, u'\n'),
     ))
Ejemplo n.º 2
0
 def test_handles_multi_line_comments(self):
     comments, source = split(self.get_tokens('style.css'))
     self.assertEqual(tuple(comments), (
         (Comment, u'/*\n * !tags: base\n */'), (Text, u'\n\n'),
     ))
     self.assertEqual(tuple(source), (
         (Operator, u'*'), (Text, u' '), (Punctuation, u'{'),
         (Text, u'\n  '), (Keyword, u'padding'), (Operator, u':'),
         (Text, u' '), (Number, u'0'), (Punctuation, u';'),
         (Text, u'\n  '), (Keyword, u'margin'), (Operator, u':'),
         (Text, u' '), (Number, u'0'), (Punctuation, u';'), (Text, u'\n'),
         (Punctuation, u'}'), (Text, u'\n'),
     ))