Produce lines of reproducible test fixture by repeated hashing
Project description
Produce lines of reproducible test fixture by repeated hashing.
For a given set of options the output is deterministic, it will always have the same checksum. So a large file can be reliably generated on demand, rather than downloaded or stored in version control. Conversely the expected checksum can be checked into version control, e.g. as part of a test suite.
Usage
>>> import hash_fixture
>>> lines = list(hash_fixture.lines(line_count=3))
>>> for line in lines: print(line)
b'000000001 hash-fixture/v0 sha256-47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=\n'
b'000000002 hash-fixture/v0 sha256-/ut7HrShdeoT1CKjUIP5z/V/AhSHvjknBr3HRo3H/j4=\n'
b'000000003 hash-fixture/v0 sha256-lL05gwF2SvDbQyK7C/2+JTFB4A3QMWYxn0fuLd9P5w0=\n'
>>>
>>> import hashlib
>>> hashlib.sha256(b''.join(lines)).hexdigest()
'3ef0546c961d1c40b848248cea7c552faa8ce1fdc49cda8c77a090f64e5a047f'
$ python3 -m hash_fixture --algorithm sha256 --line-count 3
000000001 hash-fixture/v0 sha256-47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=
000000002 hash-fixture/v0 sha256-/ut7HrShdeoT1CKjUIP5z/V/AhSHvjknBr3HRo3H/j4=
000000003 hash-fixture/v0 sha256-lL05gwF2SvDbQyK7C/2+JTFB4A3QMWYxn0fuLd9P5w0=
$ python3 -m hash_fixture --algorithm sha256 --line-count 3 | sha256sum
3ef0546c961d1c40b848248cea7c552faa8ce1fdc49cda8c77a090f64e5a047f
Install
Use
python3 -m pip install hash-fixture
or
uv pip install hash-fixture
or copy hash_fixture.py somewhere convenient, it is a self contained script.
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file hash_fixture-0.0.1.tar.gz.
File metadata
- Download URL: hash_fixture-0.0.1.tar.gz
- Upload date:
- Size: 8.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3512d069522c008953d3db08fb19be0dee55906aa8c72910b866e24c63cda2cb
|
|
| MD5 |
f3f98975b3f87fbd2e7e51374b3fff02
|
|
| BLAKE2b-256 |
f67db3ba6e1ac031998a74901d5d56e639e2f18640414f55e82f58e423577ddb
|
File details
Details for the file hash_fixture-0.0.1-py2.p3-none-any.whl.
File metadata
- Download URL: hash_fixture-0.0.1-py2.p3-none-any.whl
- Upload date:
- Size: 4.7 kB
- Tags: Python 2
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d5123a59bfcf74c4254ff1877ba16e1064500fc0799abe04ac4939f0496462ee
|
|
| MD5 |
9d0e922221e909b0b58ba2f74130fe22
|
|
| BLAKE2b-256 |
03691e2c0be91573d7ed61e19b3094974ecb60779e3325ce083e17a37508575f
|