From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <v.shpilevoy@tarantool.org>
Received: from smtpng3.m.smailru.net (smtpng3.m.smailru.net [94.100.177.149])
 (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256
 bits)) (No client certificate requested)
 by dev.tarantool.org (Postfix) with ESMTPS id 1ECB24765E0
 for <tarantool-patches@dev.tarantool.org>;
 Wed, 23 Dec 2020 18:40:02 +0300 (MSK)
References: <cover.1608726409.git.estetus@gmail.com>
 <08178ecacdd61027c0cd159eca266fd2d5925c05.1608726409.git.estetus@gmail.com>
From: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>
Message-ID: <387c760d-8221-1c98-f104-06cc2907bdb9@tarantool.org>
Date: Wed, 23 Dec 2020 16:40:00 +0100
MIME-Version: 1.0
In-Reply-To: <08178ecacdd61027c0cd159eca266fd2d5925c05.1608726409.git.estetus@gmail.com>
Content-Type: text/plain; charset=utf-8
Content-Language: en-US
Content-Transfer-Encoding: 7bit
Subject: Re: [Tarantool-patches] [PATCH v3 3/5] test: make strings
 compatible with Python 3
List-Id: Tarantool development patches <tarantool-patches.dev.tarantool.org>
List-Unsubscribe: <https://lists.tarantool.org/mailman/options/tarantool-patches>, 
 <mailto:tarantool-patches-request@dev.tarantool.org?subject=unsubscribe>
List-Archive: <https://lists.tarantool.org/pipermail/tarantool-patches/>
List-Post: <mailto:tarantool-patches@dev.tarantool.org>
List-Help: <mailto:tarantool-patches-request@dev.tarantool.org?subject=help>
List-Subscribe: <https://lists.tarantool.org/mailman/listinfo/tarantool-patches>, 
 <mailto:tarantool-patches-request@dev.tarantool.org?subject=subscribe>
To: sergeyb@tarantool.org, tarantool-patches@dev.tarantool.org, lvasiliev@tarantool.org

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?

> +            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.

>  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".