def test_extract_inline_comment(self): code_node = get_code_node( "<html>", " <body>", " <code>print 'hello' # inline comment</code>", " </body>", "</html>", ) comments = extract_comments(code_node) self.assertEqual(comments, ["inline comment"])
def test_extract_multiple_inline_comments(self): code_node = get_code_node( "<html>", " <body>", " <code>print 'hello' # comment 1", "print 'hello' # comment 2</code>", " </body>", "</html>", ) comments = extract_comments(code_node) self.assertEqual(comments, ["comment 1", "comment 2"])
def test_get_partial_results_upon_indentation_error(self): code_node = get_code_node( "<html>", " <body>", " <code>for i in l:", " pass", " # comment", " print 'Hello'", "</code>", " </body>", "</html>", ) comments = extract_comments(code_node) self.assertEqual(comments, ['comment'])
def test_extract_block_comment(self): code_node = get_code_node( "<html>", " <body>", " <code>'''", "Multi-", "line", "comment.", "'''</code>", " </body>", "</html>", ) comments = extract_comments(code_node) self.assertEqual(comments, ["\nMulti-\nline\ncomment.\n"])
def test_ignore_plain_string(self): code_node = get_code_node( "<html>", " <body>", " <code>print 'hello'", "'''" "Multi-", "line", "comment.", "'''</code>", " </body>", "</html>", ) comments = extract_comments(code_node) self.assertEqual(len(comments), 1)