Whole file

kellyjonbrazil/jello

The author described this change as make compact output more compact and fix compact output tests. It counts as a record because the checks below fail on the code as it stood at 0b69ca19b and pass on f38107772, with nothing else changed between the two runs.

Fix saved2021-06-01
Sharing licenceMIT · LICENSE
Change size+5 11

What the code was meant to do, written into the code itself as a save note

make compact output more compact and fix compact output tests

The change

220220 separators = None
221221 indent = 2
222222
223- if compact:
223+ if compact or lines:
224224 separators = (',', ':')
225225 indent = None
226226
227227 if isinstance(data, dict):
228- if compact or lines:
229- return json.dumps(data)
230- else:
231- return json.dumps(data, indent=2)
228+ return json.dumps(data, separators=separators, indent=indent, ensure_ascii=False)
232229
233230 if isinstance(data, list):
234231 if not lines:
235- if compact:
236- return json.dumps(data)
237- else:
238- return json.dumps(data, indent=2)
232+ return json.dumps(data, separators=separators, indent=indent, ensure_ascii=False)
239233
240234 # check if this list includes lists
241235 list_includes_list = False
258252 flat_list += '\n'
259253
260254 elif isinstance(entry, (dict, bool, int, float)):
261- flat_list += json.dumps(entry) + '\n'
255+ flat_list += json.dumps(entry, separators=separators, ensure_ascii=False) + '\n'
262256
263257 elif isinstance(entry, str):
264258 # replace \n with \\n here so lines with newlines literally print the \n char
278272 return ''
279273
280274 elif isinstance(data, (bool, int, float)):
281- return json.dumps(data)
275+ return json.dumps(data, ensure_ascii=False)
282276
283277 elif isinstance(data, str):
284278 # replace \n with \\n here so lines with newlines literally print the \n char

The check that tells the two apart

failpass·tests/test_create_json.py::MyTests::test_dict_c
failpass·tests/test_create_json.py::MyTests::test_dict_cl
failpass·tests/test_create_json.py::MyTests::test_dict_cr
failpass·tests/test_create_json.py::MyTests::test_dict_crl
failpass·tests/test_create_json.py::MyTests::test_dict_l
failpass·tests/test_create_json.py::MyTests::test_dict_rl
failpass·tests/test_create_json.py::MyTests::test_list_dict_c
failpass·tests/test_create_json.py::MyTests::test_list_dict_cl
failpass·tests/test_create_json.py::MyTests::test_list_dict_cr
failpass·tests/test_create_json.py::MyTests::test_list_dict_crl
failpass·tests/test_create_json.py::MyTests::test_list_dict_l
failpass·tests/test_create_json.py::MyTests::test_list_dict_rl
failpass·tests/test_create_json.py::MyTests::test_list_list_c
failpass·tests/test_create_json.py::MyTests::test_list_list_cr
failpass·tests/test_create_json.py::MyTests::test_list_sample_c
failpass·tests/test_create_json.py::MyTests::test_list_sample_rc

Check file tests/test_create_json.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.

Origin and history

The code before it0b69ca19bce4885907918b8fe6c27136fcfcbd45
Broken version dated2021-06-01
Modulejello.cli
Units changedcreate_json
Fingerprintb29af38501cd1d8e
Checked2026-08-18 by goldset/0.1

Every field above is generated by our program. None of it is written by hand.

Other bugs found in kellyjonbrazil/jello