Skip to content

Commit 4006d49

Browse files
committed
step7
1 parent 607b1f0 commit 4006d49

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

gendiff/tests/diff_generator_test.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,15 @@ def test_generate_diff(file1, file2, expected_file):
1818
with open(expected_file, "r") as f:
1919
expected_result = f.read().strip()
2020

21-
# Нормализация пробелов перед сравнением
22-
def normalize_whitespace(text):
23-
return re.sub(r'\s+', ' ', text).strip()
21+
# Улучшенная нормализация пробелов
22+
def normalize_text(text):
23+
text = re.sub(r'\s*:\s*', ': ', text) # Гарантируем ровный пробел перед двоеточием
24+
text = re.sub(r'\s*{\s*', ' { ', text) # Гарантируем пробел перед `{`
25+
text = re.sub(r'\s+', ' ', text).strip() # Убираем лишние пробелы
26+
return text
2427

25-
actual_result = normalize_whitespace(actual_result)
26-
expected_result = normalize_whitespace(expected_result)
28+
actual_result = normalize_text(actual_result)
29+
expected_result = normalize_text(expected_result)
2730

2831
assert actual_result == expected_result, (
2932
f"\nExpected:\n{expected_result}\n\nGot:\n{actual_result}"

0 commit comments

Comments
 (0)