freeze-uuid
Python package for mocking uuid.
What it is and what it does
freeze-uuid is a testing utility that replaces Python's uuid module with a mock that returns fixed or sequenced UUID values. It works as a decorator on test functions or as a context manager, allowing you to control exactly what UUIDs are generated during test execution. This eliminates randomness in tests that depend on UUID generation, making them deterministic and reproducible.
The package supports single fixed UUIDs, default zero-filled UUIDs, lists of sequential UUIDs, and async test functions. It mocks the underlying uuid.UUID class, so it works with any library that generates UUIDs through the standard module. With zero runtime dependencies and a pure-Python wheel, it installs with minimal friction.
Use it for:
- Write deterministic unit tests for code that generates or uses UUIDs without relying on random values.
- Test database operations where UUID primary keys must match expected values across test runs.
- Verify UUID handling in async functions using pytest with parametrized test cases.
- Mock UUID generation in libraries that build on the standard uuid module.
- Create reproducible integration tests where UUID sequences need to be predictable.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Decorator and context manager to mock Python's uuid module, returning fixed or sequenced UUIDs in tests instead of generating random ones.
Yes, if you write tests for code that generates UUIDs and need deterministic behavior. The package is lightweight, has no dependencies, and solves a real testing problem. However, maintenance is dormant, so it will not receive bug fixes or updates—acceptable for a stable, narrow-scope utility but worth noting if you need ongoing support.
Install
freeze-uuid on PyPI
pip
pip install freeze-uuiduv
uv add freeze-uuidpoetry
poetry add freeze-uuidInstalling freeze-uuid
Before you install
Low friction: pure Python wheel with no runtime dependencies. Maintenance is dormant—last commit 2024-05-04, no activity since—so expect no updates or bug fixes going forward.
License in practice
MIT license (permissive) means you can use, modify, and distribute freely with minimal restrictions.
Quickstart
pip install freeze-uuid
from freeze_uuid import freeze_uuid
import uuid
@freeze_uuid('12af6b44-8181-11ee-b890-628ab7cd4d99')
def test_example():
assert str(uuid.uuid4()) == '12af6b44-8181-11ee-b890-628ab7cd4d99'
Requires Python 3.9 or later.
Verify before relying
- Whether the package works correctly with all uuid generation methods beyond uuid1 and uuid4.
- Compatibility with async test frameworks beyond the pytest.mark.asyncio example shown.
- Whether dormant maintenance status will affect compatibility with future Python versions.
Package facts
| License | not declared (permissive) |
| Python support | supports the current Python release (>=3.9) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | dormant — 832 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 106,021/month — #12,671 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: freeze_uuid-0.4.3-py3-none-any.whl
Tags
More Testing packages
Pluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
pytestpytest is a testing framework that lets you…
permissive · top 100 on PyPI
virtualenvvirtualenv creates isolated Python environments…
permissive · top 100 on PyPI
coverageCoverage.py measures which lines of Python code…
permissive · top 1,000 on PyPI
pytest-asynciopytest-asyncio is a pytest plugin that enables…
permissive · top 1,000 on PyPI
pytest-json-ctrfA pytest plugin that generates test reports in…
permissive · top 1,000 on PyPI
uuid-utilsFast UUID generation and manipulation for all…
permissive · top 1,000 on PyPI
time-machineMocks and freezes time in tests, allowing you…
permissive · top 1,000 on PyPI
uuid6Generates time-based UUID formats (versions 6,…
permissive · top 5,000 on PyPI
uuid7-standardGenerates and parses UUIDv7 identifiers with…
permissive · top 15,000 on PyPI
uuid7Generates version 7 UUIDs that are…
permissive · top 5,000 on PyPI
uuid-extensionGenerates UUID version 7…
unclear · top 15,000 on PyPI
c_uuid_v7Generates UUID v7 identifiers via a CPython C…
permissive · top 15,000 on PyPI
shortuuidGenerates concise, URL-safe unique identifiers…
permissive · top 1,000 on PyPI
pytest-mockProvides a pytest fixture that wraps the mock…
permissive · top 1,000 on PyPI
pytest-freezegunpytest-freezegun provides a pytest plugin that…
permissive · top 5,000 on PyPI