2020-06-11 00:54:34 +02:00
|
|
|
import logging
|
2017-12-04 10:10:15 +01:00
|
|
|
import os
|
|
|
|
import subprocess
|
2020-06-11 00:54:34 +02:00
|
|
|
|
2017-12-04 10:10:15 +01:00
|
|
|
|
2017-12-23 21:26:09 +01:00
|
|
|
class DiffException(Exception):
|
|
|
|
pass
|
|
|
|
|
2017-12-04 10:10:15 +01:00
|
|
|
def diff_strings(output: str, expected_output: str) -> str:
|
|
|
|
|
|
|
|
mdiff_path = "frontend_tests/zjsunit/mdiff.js"
|
|
|
|
if not os.path.isfile(mdiff_path): # nocoverage
|
2020-08-11 01:47:49 +02:00
|
|
|
msg = "Cannot find mdiff for Markdown diff rendering"
|
2017-12-23 21:26:09 +01:00
|
|
|
logging.error(msg)
|
|
|
|
raise DiffException(msg)
|
2017-12-04 10:10:15 +01:00
|
|
|
|
|
|
|
command = ['node', mdiff_path, output, expected_output]
|
2020-10-30 01:36:18 +01:00
|
|
|
diff = subprocess.check_output(command, universal_newlines=True)
|
2017-12-04 10:10:15 +01:00
|
|
|
return diff
|