예제 #1
0
 def test_remove_one_line_comment_with_sql(self):
     for answer, question in (("sql ", "sql -- lala"),
                              ("sql ", "sql --lala"),
                              ("sql", "sql--lala"),
                              ("sql ", "sql --"),
                              ("sql", "sql--"),
                              ("sql", "sql--------"),
                              ("sql", "sql-- lala --")):
         unCommentedLine, comment = pysqlhelpers.removeComment(question)
         self.assertFalse(comment)
         self.assertEqual(unCommentedLine, answer)
예제 #2
0
 def test_remove_multiline_comment(self):
     for anwser, lines in (("sql  sql", ("sql /*", "nice comment", "another comment */", "sql")),
                           ("sql  sql sql", ("sql /* begin of comment", "blabla / * ", "*/sql", "sql")),
                           ("sql  sql", ("sql /*", "lala -- ", "comment */", "sql")),
                           ("sql", ("/*", "nice comment", "*/", "sql")),
                           ("sql /*+ smart hint */ sql", ("sql /*+ smart hint */", "sql")),
                           ("sql   /*+ smart hint */  sql", ("sql /* bla */ /*+ smart hint */ /*", "*/", "sql"))):
         result = []
         comment = False
         for line in lines:
             unCommentedLine, comment = pysqlhelpers.removeComment(line, comment)
             if unCommentedLine:
                 result.append(unCommentedLine)
         self.assertEqual(" ".join(result), anwser)
예제 #3
0
 def test_remove_one_line_comment(self):
     for line in ("--foo", "-- foo", "--foo ", "--foo--", "--foo --", "--", "-- ", "---", "----", "---- foo ",
                  "/**/", "/* */", "/** */", "/* **/", "/***/", "/* lala */", "/*lala */", "/* lala*/", "/*lala*/"):
         unCommentedLine, comment = pysqlhelpers.removeComment(line)
         self.assertFalse(comment)
         self.assertEqual(unCommentedLine.strip(), "")