MCPcopy Create free account
hub / github.com/aboutcode-org/scancode-toolkit / check_json

Function check_json

src/scancode/cli_test_utils.py:402–415  ·  view source on GitHub ↗

Assert if the results JSON file is the same as the expected JSON file.

(expected, results, regen=REGEN_TEST_FIXTURES)

Source from the content-addressed store, hash-verified

400
401
402def check_json(expected, results, regen=REGEN_TEST_FIXTURES):
403 """
404 Assert if the results JSON file is the same as the expected JSON file.
405 """
406 if regen:
407 with open(expected, 'w') as ex:
408 json.dump(results, ex, indent=2, separators=(',', ': '))
409 with open(expected) as ex:
410 expected = json.load(ex)
411
412 if results != expected:
413 expected = saneyaml.dump(expected)
414 results = saneyaml.dump(results)
415 assert results == expected
416
417
418def load_both_and_check_json(expected, results, regen=REGEN_TEST_FIXTURES):

Calls 2

dumpMethod · 0.45
loadMethod · 0.45

Tested by

no test coverage detected