Skip to content

Commit 66db8b7

Browse files
committed
testsuite: add missing python kvs test
Problem: In python/t0005-kvs.py an illegally stored json object was stored as binary and tested. A legally stored json object stored as binary was not tested. Add a legally stored json object in binary for coverage.
1 parent 7693cd7 commit 66db8b7

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

t/python/t0005-kvs.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
# SPDX-License-Identifier: LGPL-3.0
1111
###############################################################
1212

13+
import ast
1314
import unittest
1415

1516
import flux
@@ -39,6 +40,10 @@ def set_and_check_context(self, key, value, type):
3940
nv = kd2[key]
4041
if isinstance(value, bytes) and type is str:
4142
self.assertEqual(value.decode("utf-8"), nv)
43+
elif isinstance(value, bytes) and type is dict:
44+
# convert value bytes into string, then convert into
45+
# Python dict via ast.literal_evl for comparison.
46+
self.assertDictEqual(ast.literal_eval(value.decode("utf-8")), nv)
4247
else:
4348
self.assertEqual(value, nv)
4449
if type is not None:
@@ -72,6 +77,9 @@ def test_set_dict(self):
7277
"dict", {"thing": "stuff", "other thing": "more stuff"}, dict
7378
)
7479

80+
def test_set_legal_json(self):
81+
self.set_and_check_context("badjson", b"{}", dict)
82+
7583
def test_set_not_legal_json(self):
7684
self.set_and_check_context("badjson", b"{", str)
7785

0 commit comments

Comments
 (0)