From: Sergey Bronnikov <sergeyb@tarantool.org>
To: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>,
tarantool-patches@dev.tarantool.org, lvasiliev@tarantool.org
Subject: Re: [Tarantool-patches] [PATCH v3 3/5] test: make strings compatible with Python 3
Date: Thu, 24 Dec 2020 14:03:23 +0300 [thread overview]
Message-ID: <0abda5a7-6622-6fc9-21f3-0ebd13c058dc@tarantool.org> (raw)
In-Reply-To: <387c760d-8221-1c98-f104-06cc2907bdb9@tarantool.org>
Thanks for review!
On 23.12.2020 18:40, Vladislav Shpilevoy wrote:
> Thanks for the patch!
>
> See 3 comments below.
>
>> diff --git a/test/box-py/iproto.test.py b/test/box-py/iproto.test.py
>> index 6723e03f5..c518b0d73 100644
>> --- a/test/box-py/iproto.test.py
>> +++ b/test/box-py/iproto.test.py
>> @@ -197,16 +197,19 @@ for test in TESTS:
>> print("STR", size)
>> print("--")
>> for fmt in it:
>> - print("0x" + fmt.encode("hex"), "=>", end=" ")
>> + if sys.version[0] == '2':
> 1. '2' -> "2". It is a normal string, not byte string. Correct?
Yep.
--- a/test/box-py/iproto.test.py
+++ b/test/box-py/iproto.test.py
@@ -197,7 +197,7 @@ for test in TESTS:
print("STR", size)
print("--")
for fmt in it:
- if sys.version[0] == '2':
+ if sys.version[0] == "2":
print("0x" + fmt.encode("hex"), "=>", end=" ")
else:
print("0x" + fmt.hex(), "=>", end=" ")
>> + print("0x" + fmt.encode("hex"), "=>", end=" ")
>> + else:
>> + print("0x" + fmt.hex(), "=>", end=" ")
>> field = "*" * size
>> - c._send_request(RawInsert(c, space_id, "\x91" + fmt + field))
>> + c._send_request(RawInsert(c, space_id, b'\x91' + fmt + field.encode("utf-8")))
>> tuple = space.select(field)[0]
>> print(len(tuple[0])== size and "ok" or "fail", end=" ")
>> it2 = iter(test)
>> next(it2)
>> for fmt2 in it2:
>> tuple = c._send_request(RawSelect(c, space_id,
>> - "\x91" + fmt2 + field))[0]
>> + b'\x91' + fmt2 + field.encode("utf-8")))[0]
>> print(len(tuple[0]) == size and "ok" or "fail", end=" ")
>> tuple = space.delete(field)[0]
>> print(len(tuple[0]) == size and "ok" or "fail", end="")
>> @@ -357,15 +360,18 @@ s = c._socket
>> header = { "hello": "world"}
>> body = { "bug": 272 }
>> resp = test_request(header, body)
>> -print("sync={}, {}".format(resp["header"][IPROTO_SYNC], resp["body"].get(IPROTO_ERROR)))
>> +print("sync={}, {}".format(resp["header"][IPROTO_SYNC],
>> + resp["body"].get(IPROTO_ERROR).decode("utf-8")))
> 2. It seems this file used 4 char indentation. Lets conform.
it seems same indentation used in lines above and below, so I kept it as is.
>> header = { IPROTO_CODE : REQUEST_TYPE_SELECT }
>> header[IPROTO_SYNC] = 1234
>> resp = test_request(header, body)
>> -print("sync={}, {}".format(resp["header"][IPROTO_SYNC], resp["body"].get(IPROTO_ERROR)))
>> +print("sync={}, {}".format(resp["header"][IPROTO_SYNC],
>> + resp["body"].get(IPROTO_ERROR).decode("utf-8")))
>> header[IPROTO_SYNC] = 5678
>> body = { IPROTO_SPACE_ID: 304, IPROTO_KEY: [], IPROTO_LIMIT: 1 }
>> resp = test_request(header, body)
>> -print("sync={}, {}".format(resp["header"][IPROTO_SYNC], resp["body"].get(IPROTO_ERROR)))
>> +print("sync={}, {}".format(resp["header"][IPROTO_SYNC],
>> + resp["body"].get(IPROTO_ERROR).decode("utf-8")))
>> c.close()
>>
>>
>> @@ -424,7 +430,10 @@ header = { IPROTO_CODE: REQUEST_TYPE_CALL, IPROTO_SYNC: 100 }
>> body = { IPROTO_FUNCTION_NAME: "kek" }
>> resp = test_request(header, body)
>> print("Sync: ", resp["header"][IPROTO_SYNC])
>> -print("Retcode: ", resp["body"][IPROTO_DATA])
>> +body = resp["body"][IPROTO_DATA]
>> +if sys.version[0] == '3':
> 3. '3' -> "3".
@@ -431,7 +431,7 @@ body = { IPROTO_FUNCTION_NAME: "kek" }
resp = test_request(header, body)
print("Sync: ", resp["header"][IPROTO_SYNC])
body = resp["body"][IPROTO_DATA]
-if sys.version[0] == '3':
+if sys.version[0] == "3":
body = [body[0].decode("utf-8")]
print("Retcode: ", body)
next prev parent reply other threads:[~2020-12-24 11:03 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-23 12:36 [Tarantool-patches] [PATCH v3 0/5] Support Python 3 in tests and PEPify source code sergeyb
2020-12-23 12:36 ` [Tarantool-patches] [PATCH v3 1/5] test: convert print to function and make quotes use consistent sergeyb
2020-12-23 15:39 ` Vladislav Shpilevoy
2020-12-24 10:50 ` Sergey Bronnikov
2020-12-23 12:36 ` [Tarantool-patches] [PATCH v3 2/5] test: make dict.items() compatible with Python 3.x sergeyb
2020-12-23 12:36 ` [Tarantool-patches] [PATCH v3 3/5] test: make strings compatible with Python 3 sergeyb
2020-12-23 15:40 ` Vladislav Shpilevoy
2020-12-24 11:03 ` Sergey Bronnikov [this message]
2020-12-23 12:36 ` [Tarantool-patches] [PATCH v3 4/5] test: get rid of iteritems() sergeyb
2020-12-23 12:36 ` [Tarantool-patches] [PATCH v3 5/5] test: remove dead code in Python tests end extra newlines sergeyb
2020-12-23 23:42 ` [Tarantool-patches] [PATCH v3 0/5] Support Python 3 in tests and PEPify source code Leonid Vasiliev
2020-12-24 16:05 ` Vladislav Shpilevoy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=0abda5a7-6622-6fc9-21f3-0ebd13c058dc@tarantool.org \
--to=sergeyb@tarantool.org \
--cc=lvasiliev@tarantool.org \
--cc=tarantool-patches@dev.tarantool.org \
--cc=v.shpilevoy@tarantool.org \
--subject='Re: [Tarantool-patches] [PATCH v3 3/5] test: make strings compatible with Python 3' \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox