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)
def test_remove_str_inside2(self): code = r'''print("with some string \'with another inside\' outside")''' self.assertEqual(remove_str_comments(code), "print('')")
def test_remove_str_escaped(self): code = r'a = \"; b = \"' self.assertEqual(remove_str_comments(code), code)
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('')")
def test_remove_anidated_comment(self): code = "a = 1 # first comment # inside comment" self.assertEqual(remove_str_comments(code), "a = 1 ")
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 ")
def test_remove_comment_whitespace(self): code = " # Yep, another comment \na = 1" self.assertEqual(remove_str_comments(code), " \na = 1")
def test_remove_comment(self): code = "# Yep, this is a comment \na = 1" self.assertEqual(remove_str_comments(code), "\na = 1")