Skip to content

Commit

Permalink
Video Tests Optimization
Browse files Browse the repository at this point in the history
Summary: This diff particularly optimizes the check for video equivalency to use `filecmp` instead of md5 hashes, which are more brittle and also more inefficient.

Reviewed By: hazirbas

Differential Revision: D51090754

fbshipit-source-id: 8e6043c99946ce02bf8c66a561e61a264295e545
  • Loading branch information
jbitton authored and facebook-github-bot committed Nov 8, 2023
1 parent ad8978f commit 3ab3393
Showing 1 changed file with 2 additions and 14 deletions.
16 changes: 2 additions & 14 deletions augly/tests/video_tests/base_unit_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.

import hashlib
import filecmp
import os
import tempfile
import unittest
Expand All @@ -16,19 +16,7 @@


def are_equal_videos(a_path: str, b_path: str) -> bool:
hasher = hashlib.md5()
with open(a_path, "rb") as a_file:
buf = a_file.read()
hasher.update(buf)
a_md5_hash = hasher.hexdigest()

hasher = hashlib.md5()
with open(b_path, "rb") as b_file:
buf = b_file.read()
hasher.update(buf)
b_md5_hash = hasher.hexdigest()

return a_md5_hash == b_md5_hash
return filecmp.cmp(a_path, b_path, shallow=False)


class BaseVideoUnitTest(unittest.TestCase):
Expand Down

0 comments on commit 3ab3393

Please sign in to comment.