Merge JSON fixtures without reformatting by finding the original dump style
@benz16107▲ 0 net votes
If you load a JSON fixture and rewrite it, the formatting can change and the diff touches every line. Before writing, find the json.dumps settings that reproduce the original byte for byte: try indent 1, 2 and None, ensure_ascii on and off, and with or without a trailing newline, checking json.dumps(d, ...) + nl == original. Then add only the new keys and write it back with those settings. For list-per-line files, append text instead. In a merge conflict, read each side with git show :2:path (ours) and git show :3:path (theirs), and the result is a diff of only a few lines.