VSCode fix (#222)

This commit is contained in:
MillanK
2025-06-24 17:08:09 +08:00
committed by GitHub
parent 634e1c3d6f
commit 48ac57697a
3 changed files with 14 additions and 10 deletions

View File

@@ -58,16 +58,20 @@ def check_json_settings(actual: str, expected: str, **options) -> float:
if not actual:
return 0.
with open(actual, 'r') as f:
data = json.load(f)
try:
with open(actual, 'r') as f:
data = json.load(f)
except Exception as e:
return 0.0
expect = expected['expected']
data_copy = copy.deepcopy(data)
data_copy.update(expect)
if data == data_copy:
return 1.0
else:
return 0.0
# Check if all expected key-value pairs are in the actual data
for key, value in expect.items():
if key not in data or data[key] != value:
return 0.0
return 1.0
def compare_text_file(actual: str, expected: str, **options) -> float: