freeze-uuid
Python package for mocking uuid
Usage Example
from freeze_uuid import freeze_uuid
@freeze_uuid('12af6b44-8181-11ee-b890-628ab7cd4d99')
def test_uuid():
assert str(uuid.uuid1()) == '12af6b44-8181-11ee-b890-628ab7cd4d99'
assert str(uuid.uuid4()) == '12af6b44-8181-11ee-b890-628ab7cd4d99'
@freeze_uuid()
def test_uuid_default():
assert str(uuid.uuid1()) == '00000000-0000-0000-0000-000000000000'
assert str(uuid.uuid4()) == '00000000-0000-0000-0000-000000000000'
@pytest.mark.asyncio
@freeze_uuid('12af6b44-8181-11ee-b890-628ab7cd4d99')
async def test_uuid_async():
assert str(uuid.uuid1()) == '12af6b44-8181-11ee-b890-628ab7cd4d99'
assert str(uuid.uuid4()) == '12af6b44-8181-11ee-b890-628ab7cd4d99'
Also you can use list of uuids for multiple usage
@freeze_uuid(['12af6b44-8181-11ee-b890-628ab7cd4d99', '12af6b44-8181-11ee-b890-628ab7cd4d98'])
def test_uuid_list():
assert str(uuid.uuid1()) == '12af6b44-8181-11ee-b890-628ab7cd4d99'
assert str(uuid.uuid4()) == '12af6b44-8181-11ee-b890-628ab7cd4d98'
assert str(uuid.uuid4()) == '12af6b44-8181-11ee-b890-628ab7cd4d98'
assert str(uuid.uuid4()) == '12af6b44-8181-11ee-b890-628ab7cd4d98'
Since library mocks uuid.UUID class, it can be used with all libraries, that support UUID class, i.e. uuid7
from uuid_extensions import uuid7
@freeze_uuid(TEST_UUID)
def test_uuid_7():
assert str(uuid7()) == TEST_UUID
With freeze_uuid context manager you can create tests with pytest parametrize
from freeze_uuid import freeze_uuid_manager
@pytest.mark.parametrize(
['expected_result', 'freeze_data'],
[
pytest.param(
TEST_UUID_2,
[TEST_UUID_2],
),
pytest.param(
TEST_UUID_3,
[TEST_UUID_3],
),
pytest.param(
TEST_UUID_4,
[TEST_UUID_4],
),
pytest.param(
TEST_UUID_5,
[TEST_UUID_5],
),
]
)
def test_parametrize(expected_result, freeze_data):
with freeze_uuid_manager(freeze_data):
assert str(uuid.uuid4()) == expected_result
Metadata
Release files for freeze-uuid 0.4.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| freeze_uuid-0.4.3.tar.gz | 3.9 kB | Without provenance | Details for freeze_uuid-0.4.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| freeze_uuid-0.4.3-py3-none-any.whl | Python 3 | none | any | Details for freeze_uuid-0.4.3-py3-none-any.whl |
Total release size: 8.7 kB
Release files / freeze_uuid-0.4.3.tar.gz
| Download URL | freeze_uuid-0.4.3.tar.gz |
|---|---|
| Size | 3.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fc229deb02e3bf41918ad9c377b304af79403ac6e3b8779c1212da2788be48ca
|
|
BLAKE2b-256 checksum How to use checksums |
6513bb583bb19c1ee627c57ff62087aacf2ee4cfba8d1241b8acb0e89969aa58
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.9.19
|
Release files / freeze_uuid-0.4.3-py3-none-any.whl
| Download URL | freeze_uuid-0.4.3-py3-none-any.whl |
|---|---|
| Size | 4.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
19e28068cafb4f1ca0f1632aee2d82103b6f56c353c6b4d297406eb15dd4f6cd
|
|
BLAKE2b-256 checksum How to use checksums |
a95cb4b99e178ef24ef651ade7d5114d1fde3eec84554ac0c5593aacd1bcbeca
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.9.19
|
Security for freeze-uuid 0.4.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.