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.
Projectkellyjonbrazil/jello
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
| 220 | 220 | separators = None | |
| 221 | 221 | indent = 2 | |
| 222 | 222 | ||
| 223 | - | if compact: | |
| 223 | + | if compact or lines: | |
| 224 | 224 | separators = (',', ':') | |
| 225 | 225 | indent = None | |
| 226 | 226 | ||
| 227 | 227 | 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) | |
| 232 | 229 | ||
| 233 | 230 | if isinstance(data, list): | |
| 234 | 231 | 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) | |
| 239 | 233 | ||
| 240 | 234 | # check if this list includes lists | |
| 241 | 235 | list_includes_list = False | |
| ⋯ | |||
| 258 | 252 | flat_list += '\n' | |
| 259 | 253 | ||
| 260 | 254 | 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' | |
| 262 | 256 | ||
| 263 | 257 | elif isinstance(entry, str): | |
| 264 | 258 | # replace \n with \\n here so lines with newlines literally print the \n char | |
| ⋯ | |||
| 278 | 272 | return '' | |
| 279 | 273 | ||
| 280 | 274 | elif isinstance(data, (bool, int, float)): | |
| 281 | - | return json.dumps(data) | |
| 275 | + | return json.dumps(data, ensure_ascii=False) | |
| 282 | 276 | ||
| 283 | 277 | elif isinstance(data, str): | |
| 284 | 278 | # replace \n with \\n here so lines with newlines literally print the \n char | |
The check that tells the two apart
fail→pass·tests/test_create_json.py::MyTests::test_dict_c
fail→pass·tests/test_create_json.py::MyTests::test_dict_cl
fail→pass·tests/test_create_json.py::MyTests::test_dict_cr
fail→pass·tests/test_create_json.py::MyTests::test_dict_crl
fail→pass·tests/test_create_json.py::MyTests::test_dict_l
fail→pass·tests/test_create_json.py::MyTests::test_dict_rl
fail→pass·tests/test_create_json.py::MyTests::test_list_dict_c
fail→pass·tests/test_create_json.py::MyTests::test_list_dict_cl
fail→pass·tests/test_create_json.py::MyTests::test_list_dict_cr
fail→pass·tests/test_create_json.py::MyTests::test_list_dict_crl
fail→pass·tests/test_create_json.py::MyTests::test_list_dict_l
fail→pass·tests/test_create_json.py::MyTests::test_list_dict_rl
fail→pass·tests/test_create_json.py::MyTests::test_list_list_c
fail→pass·tests/test_create_json.py::MyTests::test_list_list_cr
fail→pass·tests/test_create_json.py::MyTests::test_list_sample_c
fail→pass·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.