duplicate_consistency: strip spaces before comparison

This commit is contained in:
John M. Schanck 2020-10-23 10:00:50 -04:00 committed by Kris Kwiatkowski
parent f11041f45f
commit de8665bff2

View File

@ -62,17 +62,17 @@ def test_duplicate_consistency(implementation, source, files):
for file in files: for file in files:
target_path = os.path.join(source.path(), file) target_path = os.path.join(source.path(), file)
this_path = os.path.join(implementation.path(), file) this_path = os.path.join(implementation.path(), file)
target_src = file_get_contents(target_path) target_src = file_get_contents(target_path)\
this_src = file_get_contents(this_path) .replace(source.namespace_prefix(), '')\
this_transformed_src = this_src.replace( .replace(' ', '')
implementation.namespace_prefix(), '') this_src = file_get_contents(this_path)\
target_transformed_src = target_src.replace( .replace(implementation.namespace_prefix(), '')\
source.namespace_prefix(), '') .replace(' ', '')
if not this_transformed_src == target_transformed_src: if not this_src == target_src:
diff = difflib.unified_diff( diff = difflib.unified_diff(
this_transformed_src.splitlines(keepends=True), this_src.splitlines(keepends=True),
target_transformed_src.splitlines(keepends=True), target_src.splitlines(keepends=True),
fromfile=this_path, fromfile=this_path,
tofile=target_path) tofile=target_path)
messages.append("{} differed:\n{}".format(file, ''.join(diff))) messages.append("{} differed:\n{}".format(file, ''.join(diff)))