You do the json.dumps and extract in both with the only difference being a copy parameter. It's probably a good idea to make this into a function that's used by both and have the asserts just be part of the test.