Commit b9f75914 authored by Daniel Tuulik's avatar Daniel Tuulik Committed by Daniel Tuulik

Remove unused code

Use system diff instead of the fancy python diff
parent a4662be9
......@@ -38,81 +38,6 @@ def init_logging(options):
handler_console = logging.StreamHandler()
handler_console.setFormatter(terminal_formatter)
LOG.addHandler(handler_console)
def diff(expected, actual, msg=None, count=1, case_sensitive=True,
update=None, silent=False, directory=''):
"""Compare EXPECTED and str2. If not equal, display a diff and raise an
error.
"""
# try looking in self.directory
full_expected = os.path.join(directory, expected)
if isinstance(expected, file):
str1 = expected.read()
frm = expected.name
elif os.path.isfile(expected):
str1 = file(expected).read()
frm = expected
elif os.path.isfile(full_expected):
expected = full_expected
str1 = file(expected).read()
frm = expected
elif update:
# Check if it's a valid file path, in which case use it. Because of
# --update, the file will be created and filled with the expected
# output further below.
try:
file(full_expected, 'w')
expected = full_expected
str1 = ''
frm = expected
except:
str1 = expected
frm = "Expected"
else:
str1 = expected
frm = "Expected"
if os.path.isfile(actual):
actual = file(actual).read()
string.replace(actual, "\r", "")
expected = str1 * count
diff = colored_unified_diff(
expected, actual, fromfile=frm, tofile="Output")
if diff:
if msg:
msg = msg + "\n"
else:
msg = ""
msg = msg + "------- EXPECTED: ----\n" \
+ expected + "\n" \
+ "------- ACTUAL: --------\n" + actual + "\n"
if update:
# If updating baselines, do not stop at the first difference
if frm != "Expected":
f = file(frm, "w")
f.close()
else:
d = re.sub("\n", "$\n", "\n".join(diff))
if not silent:
unittest.TestCase.fail(msg + "\n" + d)
else:
return msg + "\n" + d
def colored_unified_diff(a, b, fromfile='', tofile='',
fromfiledate='', tofiledate='', n=3, lineterm='\n',
onequal=None, onreplaceA=None, onreplaceB=None):
for line in difflib.unified_diff(a, b, fromfile, tofile):
yield line
def main():
start = time.time()
......@@ -193,6 +118,7 @@ def run_test(op):
stderr=subprocess.PIPE)
stdout, stderr = p0.communicate()
errcode = p0.wait()
if errcode != 0:
return (errcode, stdout, stderr, op.root_model, op.rule)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment