()
| 42 | |
| 43 | |
| 44 | def test_hash(): |
| 45 | # type: () -> None |
| 46 | empty_hash_digest = sha1().hexdigest() |
| 47 | |
| 48 | with named_temporary_file() as fp: |
| 49 | fp.flush() |
| 50 | assert empty_hash_digest == CacheHelper.hash(fp.name) |
| 51 | |
| 52 | with named_temporary_file() as fp: |
| 53 | string = b"asdf" * 1024 * sha1().block_size + b"extra padding" |
| 54 | fp.write(string) |
| 55 | fp.flush() |
| 56 | assert sha1(string).hexdigest() == CacheHelper.hash(fp.name) |
| 57 | |
| 58 | with named_temporary_file() as fp: |
| 59 | empty_hash = sha1() |
| 60 | fp.write(b"asdf") |
| 61 | fp.flush() |
| 62 | hash_output = CacheHelper.hash(fp.name, digest=empty_hash) |
| 63 | assert hash_output == empty_hash.hexdigest() |
| 64 | |
| 65 | |
| 66 | @pytest.mark.parametrize( |
nothing calls this directly
no test coverage detected