ClickHouse/dbms/tests/integration/helpers/test_tools.py

14 lines
452 B
Python
Raw Normal View History

import difflib
class TSV:
"""Helper to get pretty diffs between expected and actual tab-separated value files"""
def __init__(self, contents):
self.lines = contents.readlines() if isinstance(contents, file) else contents.splitlines(True)
def __eq__(self, other):
return self.lines == other.lines
def diff(self, other):
return list(line.rstrip() for line in difflib.context_diff(self.lines, other.lines))[2:]