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
|
2017-12-23 21:26:09 +01:00
|
|
|
msg = "Cannot find mdiff for markdown diff rendering"
|
|
|
|
logging.error(msg)
|
|
|
|
raise DiffException(msg)
|
2017-12-04 10:10:15 +01:00
|
|
|
|
|
|
|
command = ['node', mdiff_path, output, expected_output]
|
|
|
|
diff = subprocess.check_output(command).decode('utf-8')
|
|
|
|
return diff
|