def auth_password(self, password): self.__auth_password = Parser.coerce_string_to_ascii(password)
def test_coerce_string_to_ascii(self): self.assertEqual(b'stuff', Parser.coerce_string_to_ascii(u'stuff')) self.assertRaises(UnicodeEncodeError, Parser.coerce_string_to_ascii, u'st😽uff') self.assertRaises(TypeError, Parser.coerce_string_to_ascii, 1) self.assertRaises(TypeError, Parser.coerce_string_to_ascii, None)
def auth_username(self, username): self.__auth_username = Parser.coerce_string_to_ascii(username)
def test_coerce_string_to_ascii(self): result = Parser.coerce_string_to_ascii(bytes("Hello", 'utf-8')) self.assertEqual(result, "Hello".encode('ascii'))