From 60dba3a304341d40e51b38983ea36725f529a0fb Mon Sep 17 00:00:00 2001 From: Kevin Lloyd Bernal Date: Thu, 4 Jul 2024 17:45:44 +1000 Subject: [PATCH] add test for bad formatting --- tests/test_rules.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/test_rules.py b/tests/test_rules.py index fb0cb7d..e8283eb 100644 --- a/tests/test_rules.py +++ b/tests/test_rules.py @@ -9,7 +9,8 @@ def test_rule_validity(): for path in RULE_PATHS: try: with open(path, "r") as f: - data = json.loads(f.read()) + raw_text = f.read() + data = json.loads(raw_text) except Exception as e: raise ValueError(f"Something went wrong when reading '{path}': {str(e)}.") @@ -32,3 +33,7 @@ def test_rule_validity(): if "args" in rule: assert isinstance(rule["args"], (list, tuple)) + + assert ( + json.dumps(data, indent=2, sort_keys=True) == raw_text.rstrip() + ), f"Check {path} for formatting issue"