Skip to content

Commit f375aee

Browse files
committed
cosmetic changes
1 parent 5ea14e9 commit f375aee

File tree

1 file changed

+17
-18
lines changed

1 file changed

+17
-18
lines changed

tests/pytest/test.py

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1273,32 +1273,31 @@ def testOutOfRangeValues(env):
12731273
}
12741274

12751275
doc_float_ok = {
1276-
"max_f64": 1.7976931348623157e+308,
1277-
"beyond_max_f64": 1.7976931348623158e+308, # why OK?
1278-
"min_f64": -1.7976931348623157e+308,
1279-
"below_min_f64": -1.7976931348623158e+308, # why OK?
1276+
"max_f64" : 1.7976931348623157e+308,
1277+
"max2_f64": 1.7976931348623158e+308,
1278+
"min_f64" : -1.7976931348623157e+308,
1279+
"min2_f64": -1.7976931348623158e+308,
12801280
}
12811281

12821282
doc_bad_values = {
1283-
"beyond1_max_f64": 1.7976931348623159e+308,
1284-
"below1_min_f64": -1.7976931348623159e+308
1283+
"beyond_max_f64": 1.7976931348623159e+308,
1284+
"below_min_f64": -1.7976931348623159e+308
12851285
}
12861286

12871287
r.expect('JSON.SET', 'doc_int_ok', '$', json.dumps(doc_int_ok)).ok()
12881288
r.expect('JSON.SET', 'doc_float_ok', '$', json.dumps(doc_float_ok)).ok()
1289-
epsilon = 0
1290-
for k, v in iter(doc_int_ok.items()):
1291-
r.assertTrue(True, message='GET {}={}'.format(k, v))
1292-
res = r.execute_command('JSON.GET', 'doc_int_ok', '$.{}'.format(k))
1293-
r.assertAlmostEqual(json.loads(res)[0], v, epsilon, message=res)
1294-
1295-
epsilon = sys.float_info.epsilon
1296-
for k, v in iter(doc_float_ok.items()):
1297-
r.assertTrue(True, message='GET {}={}'.format(k, v))
1298-
res = r.execute_command('JSON.GET', 'doc_float_ok', '$.{}'.format(k))
1299-
r.assertAlmostEqual(json.loads(res)[0], v, epsilon, message=res)
1289+
1290+
def check_object_values(obj, name, epsilon):
1291+
for k, v in iter(obj.items()):
1292+
r.assertTrue(True, message='GET {}={}'.format(k, v))
1293+
res = r.execute_command('JSON.GET', name, '$.{}'.format(k))
1294+
r.assertAlmostEqual(json.loads(res)[0], v, epsilon, message=res)
13001295

1301-
# Do not use json.dumps with out-of-range values here (would be converted to a string representation such as 'Infinity')
1296+
# Test values from JSON.GET are equal to JSON.SET
1297+
check_object_values(doc_int_ok, 'doc_int_ok', 0)
1298+
check_object_values(doc_float_ok, 'doc_float_ok', sys.float_info.epsilon)
1299+
1300+
# Not using json.dumps with out-of-range values here (would be converted to a string representation such as 'Infinity')
13021301
r.expect('JSON.SET', 'doc_bad_values', '$', '{}').ok()
13031302
for k, v in iter(doc_bad_values.items()):
13041303
r.assertTrue(True, message='SET {}={}'.format(k, v))

0 commit comments

Comments
 (0)