Compare two submit files by loading them as Submit objects.
This provides a semantic comparison rather than exact string matching,
making tests more robust to formatting changes.
Source code in ezdag/tests/test_dags.py
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56 | def compare_submit_files(file1: Path, file2: Path) -> bool:
"""Compare two submit files by loading them as Submit objects.
This provides a semantic comparison rather than exact string matching,
making tests more robust to formatting changes.
"""
# Read both files
submit1_text = file1.read_text()
submit2_text = file2.read_text()
# Parse into Submit objects
submit1 = htcondor.Submit(submit1_text)
submit2 = htcondor.Submit(submit2_text)
# Get all keys from both submits
keys1 = set(submit1.keys())
keys2 = set(submit2.keys())
# Check if keys match
if keys1 != keys2:
missing_in_1 = keys2 - keys1
missing_in_2 = keys1 - keys2
if missing_in_1:
print(f"Keys in {file2.name} but not in {file1.name}: {missing_in_1}")
if missing_in_2:
print(f"Keys in {file1.name} but not in {file2.name}: {missing_in_2}")
return False
# Compare values for each key
for key in keys1:
val1 = submit1.get(key, "").strip()
val2 = submit2.get(key, "").strip()
if val1 != val2:
print(f"Value mismatch for key '{key}':")
print(f" {file1.name}: {val1}")
print(f" {file2.name}: {val2}")
return False
return True
|