[V1] tests/telemetry: Optimize the parameter for function json.load
Checks
Context |
Check |
Description |
ci/Intel-dts-format-test |
success
|
Testing OK
|
ci/Intel-dts-pylama-test |
success
|
Testing OK
|
ci/Intel-dts-suite-test |
success
|
Testing OK
|
Commit Message
In Python 3.10, the json.load() function removed the encoding parameter,
because in Python 3, the json module uses UTF-8 encoding by default to process JSON data.
As such, the encoding argument is no longer required, and has been removed in Python 3.10.
If you need to specify other encoding methods,
you can use the encoding parameter in the open() function to specify.
Please refer to the Python official documentation for more details.
https://docs.python.org/3/library/json.html
Signed-off-by: Dukai Yuan <dukaix.yuan@intel.com>
---
tests/TestSuite_telemetry.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
Comments
On Fri, 26 May 2023 14:08:12 +0000, Dukai Yuan <dukaix.yuan@intel.com> wrote:
> In Python 3.10, the json.load() function removed the encoding parameter,
> because in Python 3, the json module uses UTF-8 encoding by default to process JSON data.
> As such, the encoding argument is no longer required, and has been removed in Python 3.10.
> If you need to specify other encoding methods,
> you can use the encoding parameter in the open() function to specify.
> Please refer to the Python official documentation for more details.
> https://docs.python.org/3/library/json.html
>
> Signed-off-by: Dukai Yuan <dukaix.yuan@intel.com>
Acked-by: Lijuan Tu <lijuan.tu@intel.com>
Applied, thanks
@@ -270,9 +270,9 @@ class TestTelemetry(TestCase):
self.dut.session.copy_file_from(json_file, dst_file)
msg = "failed to get {}".format(json_name)
self.verify(os.path.exists(dst_file), msg)
- with open(dst_file, "r") as fp:
+ with open(dst_file, "r", encoding="utf-8") as fp:
try:
- query_data = json.load(fp, encoding="utf-8")
+ query_data = json.load(fp)
except Exception as e:
msg = "failed to load metrics json data"
self.verify(False, msg)