From: Jeremy Stanley Date: Sun, 21 Jul 2013 20:03:58 +0000 (+0000) Subject: Correct byte types and encoding in test script X-Git-Url: https://mudpy.org/gitweb?a=commitdiff_plain;h=9a847f750030e34944db934d746cd2f02d2d98b4;p=mudpy.git Correct byte types and encoding in test script * bin/test: It is sufficient to encode lookahead and written values on the Telnet socket into UTF-8, and works correctly with Py3K now. --- diff --git a/bin/test b/bin/test index 480c7be..45ce5aa 100755 --- a/bin/test +++ b/bin/test @@ -7,27 +7,27 @@ # terms provided in the LICENSE file distributed with this software. conversation = ( - (b"Identify yourself:", b"testuser"), - (b"Enter your choice:", b"n"), - (b"Enter a new password for \"testuser\":", b"Test123"), - (b"Enter the same new password again:", b"Test123"), - (b"What would you like to do?", b"c"), - (b"Pick a gender for your new avatar:", b"f"), - (b"Choose a name for her:", b"1"), - (b"What would you like to do?", b"a"), - (b"Whom would you like to awaken?", b""), - (b">", b"quit"), - (b"What would you like to do?", b"d"), - (b"Whom would you like to delete?", b""), - (b"What would you like to do?", b"p"), - (b"permanently delete your account?", b"y"), - (b"Disconnecting...", b""), + ("Identify yourself:", "testuser"), + ("Enter your choice:", "n"), + ("Enter a new password for \"testuser\":", "Test123"), + ("Enter the same new password again:", "Test123"), + ("What would you like to do?", "c"), + ("Pick a gender for your new avatar:", "f"), + ("Choose a name for her:", "1"), + ("What would you like to do?", "a"), + ("Whom would you like to awaken?", ""), + (">", "quit"), + ("What would you like to do?", "d"), + ("Whom would you like to delete?", ""), + ("What would you like to do?", "p"), + ("permanently delete your account?", "y"), + ("Disconnecting...", ""), ) import telnetlib mud = telnetlib.Telnet() mud.open("::1", 6669) for question, answer in conversation: - mud.read_until(b"%s " % question) - mud.write(b"%s\r\n" % answer) + mud.read_until(("%s " % question).encode("utf-8")) + mud.write(("%s\r\n" % answer).encode("utf-8")) mud.close()