def test_collect(self): """Test collecting a list of signatures into a new signature value """ for algorithm, expected in { 'md5': ('698d51a19d8a121ce581499d7b701668', '8980c988edc2c78cc43ccb718c06efd5', '53fd88c84ff8a285eb6e0a687e55b8c7'), 'sha1': ('6216f8a75fd5bb3d5f22b6f9958cdede3fc086c2', '42eda1b5dcb3586bccfb1c69f22f923145271d97', '2eb2f7be4e883ebe52034281d818c91e1cf16256'), 'sha256': ('f6e0a1e2ac41945a9aa7ff8a8aaa0cebc12a3bcc981a929ad5cf810a090e11ae', '25235f0fcab8767b7b5ac6568786fbc4f7d5d83468f0626bf07c3dbeed391a7a', 'f8d3d0729bf2427e2e81007588356332e7e8c4133fae4bceb173b93f33411d17'), }.items(): # if the current platform does not support the algorithm we're looking at, # skip the test steps for that algorithm, but display a warning to the user if algorithm not in ALLOWED_HASH_FORMATS: warnings.warn("Missing hash algorithm {} on this platform, cannot test with it".format(algorithm), ResourceWarning) else: hs = functools.partial(hash_signature, hash_format=algorithm) s = list(map(hs, ('111', '222', '333'))) assert expected[0] == hash_collect(s[0:1], hash_format=algorithm) assert expected[1] == hash_collect(s[0:2], hash_format=algorithm) assert expected[2] == hash_collect(s, hash_format=algorithm)
def test_collect(self): """Test collecting a list of signatures into a new signature value """ for algorithm, expected in { 'md5': ('698d51a19d8a121ce581499d7b701668', '8980c988edc2c78cc43ccb718c06efd5', '53fd88c84ff8a285eb6e0a687e55b8c7'), 'sha1': ('6216f8a75fd5bb3d5f22b6f9958cdede3fc086c2', '42eda1b5dcb3586bccfb1c69f22f923145271d97', '2eb2f7be4e883ebe52034281d818c91e1cf16256'), 'sha256': ('f6e0a1e2ac41945a9aa7ff8a8aaa0cebc12a3bcc981a929ad5cf810a090e11ae', '25235f0fcab8767b7b5ac6568786fbc4f7d5d83468f0626bf07c3dbeed391a7a', 'f8d3d0729bf2427e2e81007588356332e7e8c4133fae4bceb173b93f33411d17'), }.items(): hs = functools.partial(hash_signature, hash_format=algorithm) s = list(map(hs, ('111', '222', '333'))) assert expected[0] == hash_collect(s[0:1], hash_format=algorithm) assert expected[1] == hash_collect(s[0:2], hash_format=algorithm) assert expected[2] == hash_collect(s, hash_format=algorithm)