Skip to content

Commit

Permalink
fix(ingest): hint at --update-golden-files option when tests fail (#8507
Browse files Browse the repository at this point in the history
)
  • Loading branch information
hsheth2 authored Jul 26, 2023
1 parent 8a23c37 commit c585a1b
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions metadata-ingestion/src/datahub/testing/compare_metadata_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def assert_metadata_files_equal(

if copy_output:
shutil.copyfile(str(output_path), str(golden_path) + ".output")
print(f"Copied output file to {golden_path}.output")
logger.info(f"Copied output file to {golden_path}.output")

if not update_golden and not golden_exists:
raise FileNotFoundError(
Expand Down Expand Up @@ -77,11 +77,15 @@ def assert_metadata_files_equal(

if diff:
# Call pytest.fail rather than raise an exception to omit stack trace
message = (
"Metadata files differ (use `pytest --update-golden-files` to update):\n"
)
if isinstance(diff, MCPDiff):
print(diff.pretty(verbose=True))
pytest.fail(diff.pretty(), pytrace=False)
logger.error(message + diff.pretty(verbose=True))
pytest.fail(message + diff.pretty(), pytrace=False)
else:
pytest.fail(pprint.pformat(diff), pytrace=False)
logger.error(message + pprint.pformat(diff))
pytest.fail(message + pprint.pformat(diff), pytrace=False)


def diff_metadata_json(
Expand Down

0 comments on commit c585a1b

Please sign in to comment.