Files
zulip/zerver/lib/mdiff.py
Anders Kaseorg 97e4e9886c python: Replace universal_newlines with text.
This is supported in Python ≥ 3.7.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-01-23 22:16:01 -08:00

21 lines
507 B
Python
Executable File

import logging
import os
import subprocess
class DiffException(Exception):
pass
def diff_strings(output: str, expected_output: str) -> str:
mdiff_path = "frontend_tests/zjsunit/mdiff.js"
if not os.path.isfile(mdiff_path): # nocoverage
msg = "Cannot find mdiff for Markdown diff rendering"
logging.error(msg)
raise DiffException(msg)
command = ["node", mdiff_path, output, expected_output]
diff = subprocess.check_output(command, text=True)
return diff