Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Update goldens only when diff fails
  • Loading branch information
kevinhu committed Jul 12, 2021
commit 3202d7bd4639c79c8c6a02eb865a997453fa09de
13 changes: 9 additions & 4 deletions metadata-ingestion/tests/test_helpers/mce_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,15 @@ def check_golden_file(
golden_path: Union[str, os.PathLike],
ignore_paths: Optional[List[str]] = None,
) -> None:
if pytestconfig.getoption("--update-golden-files"):
shutil.copyfile(str(output_path), str(golden_path))
return

output = load_json_file(output_path)
golden = load_json_file(golden_path)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should still work when the golden file doesn't exist yet

assert_mces_equal(output, golden, ignore_paths)

try:
assert_mces_equal(output, golden, ignore_paths)

except AssertionError as e:
# only update golden files if the diffs are not empty
if pytestconfig.getoption("--update-golden-files"):
shutil.copyfile(str(output_path), str(golden_path))
raise e