Example #1
0
 def test_remove_str_triple(self):
     code = '''triple = """
         some stuff
         inside and
         multiline"""; b = 3'''
     result = "triple = ''; b = 3"
     self.assertEqual(remove_str_comments(code), result)
Example #2
0
 def test_remove_str_inside2(self):
     code = r'''print("with some string \'with another inside\' outside")'''
     self.assertEqual(remove_str_comments(code), "print('')")
Example #3
0
 def test_remove_str_escaped(self):
     code = r'a = \"; b = \"'
     self.assertEqual(remove_str_comments(code), code)
Example #4
0
 def test_remove_simple_str(self):
     code = 'print("with some string")'
     self.assertEqual(remove_str_comments(code), "print('')")
     code = "print('with some string')"
     self.assertEqual(remove_str_comments(code), "print('')")
Example #5
0
 def test_remove_anidated_comment(self):
     code = "a = 1 # first comment # inside comment"
     self.assertEqual(remove_str_comments(code), "a = 1 ")
Example #6
0
 def test_remove_comment_mixed(self):
     code = "b = 2 # set b to two (dont do this please)"
     self.assertEqual(remove_str_comments(code), "b = 2 ")
Example #7
0
 def test_remove_comment_whitespace(self):
     code = "   # Yep, another comment   \na = 1"
     self.assertEqual(remove_str_comments(code), "   \na = 1")
Example #8
0
 def test_remove_comment(self):
     code = "# Yep, this is a comment \na = 1"
     self.assertEqual(remove_str_comments(code), "\na = 1")