def testCommentValidator(self): good_comments = [ 'Responses with Content-Type', 'application/json', ',', '[minimum: 4.4.1]', 'API key. Your API key identifies your project', 'OAuth 2.0 token for the current user.' ] # A list of input comments, and their expected replacements bad_comments = [ ('/*', ''), ('*/', ''), ('\"""', ''), ('///', ''), ('\\*', ''), ('/*Some Comment String*/', 'Some Comment String'), ('\""" A long comment string """', ' A long comment string '), ('///Escaped comment string', 'Escaped comment string'), ] for comment in good_comments: name_validator.ValidateAndSanitizeComment(comment) for comment, replacement in bad_comments: self.assertEqual( replacement, name_validator.ValidateAndSanitizeComment(comment))
def testUtf8InComment(self): comment = 'Base64-encoded (RFC 4648 §5) data.' unicode_comment = comment.decode('utf-8') self.assertEqual(unicode_comment, name_validator.ValidateAndSanitizeComment(comment)) self.assertEqual( unicode_comment, name_validator.ValidateAndSanitizeComment(unicode_comment))
def testUtf8InComment(self): comment = u'Base64-encoded (RFC 4648 §5) data.' self.assertEqual(comment, name_validator.ValidateAndSanitizeComment(comment)) self.assertEqual(comment, name_validator.ValidateAndSanitizeComment(comment))