diff --git a/testsuite/drivers/unparser_driver.py b/testsuite/drivers/unparser_driver.py index cd68cb9ea..45814234f 100644 --- a/testsuite/drivers/unparser_driver.py +++ b/testsuite/drivers/unparser_driver.py @@ -1,5 +1,6 @@ from __future__ import annotations +import json import os.path from drivers.base_driver import BaseDriver @@ -52,16 +53,25 @@ def read_file(filename: str) -> str: return f.read() document_baseline_filename = self.test_dir( - self.document_baseline_filename + self.document_baseline_filename) + document_baseline = json.dumps( + json.loads(read_file(document_baseline_filename)), + indent=2, + sort_keys=True, + ) + document_actual = json.dumps( + json.loads(read_file(self.working_dir("doc.json"))), + indent=2, + sort_keys=True, + ) + + result.extend( + self.compute_diff( + baseline_file=document_baseline_filename, + baseline=document_baseline, + actual=document_actual, + failure_message="Prettier document mismatch", + ) ) - document_baseline = read_file(document_baseline_filename) - document_actual = read_file(self.working_dir("doc.json")) - - result.extend(self.compute_diff( - baseline_file=document_baseline_filename, - baseline=document_baseline, - actual=document_actual, - failure_message="Prettier document mismatch", - )) return result