def test_parse(self):
     """ Test credential parsing. """
     print("checking credential parsing")
     for (shouldpass, string) in parse_credential:
         if shouldpass:
             cred = credential.parse(string)
             result = credential.parse(cred.string())
             self.assertEqual(cred, result,
                              "expected to be equal:\n<%s>\n<%s>" %
                              (cred, result))
             continue
         # else
         try:
             credential.parse(string)
             self.fail("exception should have been raised for:\n<%s>" %
                       string)
         except InvalidCredential:
             pass
     print("...credential parsing ok")
 def test_decoding(self):
     """ Test decoding. """
     print("checking credential decoding")
     cred = credential.parse("plain name=%25%3d%2f pass=%00%3d%2f")
     self.assertEqual(cred.name, "%=/", "expected %=/")
     self.assertEqual(cred['pass'],
                      "\x00=\x2f",
                      "expected \\x00=\\x2f, got: %s" %
                      cred['pass'])
     print("...credential decoding ok")