Name | pytest-freezer JSON |
Version |
0.4.9
JSON |
| download |
home_page | None |
Summary | Pytest plugin providing a fixture interface for spulec/freezegun |
upload_time | 2024-12-12 08:53:08 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.6 |
license | None |
keywords |
|
VCS |
 |
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
[](https://github.com/pytest-dev/pytest-freezer/actions/workflows/tests.yml/)
[](https://codecov.io/gh/pytest-dev/pytest-freezer)
[](https://pypi.org/project/pytest-freezer)

# pytest-freezer
[Pytest][1] plugin providing a fixture interface for [freezegun][2].
## Installation:
``` bash
$ python -m pip install pytest-freezer
```
## Usage:
The fixture name is `freezer`. It is a `freezegun.api.FrozenDateTimeFactory` instance,
so refer to upstream freezegun [usage][3] for the methods.
Time is frozen by default when the fixture is injected:
``` python
def test_frozen_date(freezer):
now = datetime.now()
time.sleep(1)
later = datetime.now()
assert now == later
```
Time can be controlled within a test by using methods on the fixture:
``` python
def test_freezer_methods(freezer):
freezer.move_to("2022-10-17")
assert datetime.now() == datetime(2022, 10, 17)
freezer.tick()
assert datetime.now() == datetime(2022, 10, 17, 0, 0, 1)
freezer.tick(delta=12)
assert datetime.now() == datetime(2022, 10, 17, 0, 0, 13)
```
## Acknowledgements:
Credit to Tomasz Kontusz for the original [pytest-freezegun][4] plugin.
[1]: https://docs.pytest.org/
[2]: https://github.com/spulec/freezegun
[3]: https://github.com/spulec/freezegun#usage
[4]: https://github.com/ktosiek/pytest-freezegun
Raw data
{
"_id": null,
"home_page": null,
"name": "pytest-freezer",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": null,
"keywords": null,
"author": null,
"author_email": "Wim Jeantine-Glenn <hey@wimglenn.com>",
"download_url": "https://files.pythonhosted.org/packages/81/f0/98dcbc5324064360b19850b14c84cea9ca50785d921741dbfc442346e925/pytest_freezer-0.4.9.tar.gz",
"platform": null,
"description": "[](https://github.com/pytest-dev/pytest-freezer/actions/workflows/tests.yml/)\n[](https://codecov.io/gh/pytest-dev/pytest-freezer)\n[](https://pypi.org/project/pytest-freezer)\n\n\n# pytest-freezer\n\n[Pytest][1] plugin providing a fixture interface for [freezegun][2].\n\n## Installation:\n\n``` bash\n$ python -m pip install pytest-freezer\n```\n\n## Usage:\n\nThe fixture name is `freezer`. It is a `freezegun.api.FrozenDateTimeFactory` instance,\nso refer to upstream freezegun [usage][3] for the methods.\n\nTime is frozen by default when the fixture is injected:\n\n``` python\ndef test_frozen_date(freezer):\n now = datetime.now()\n time.sleep(1)\n later = datetime.now()\n assert now == later\n```\n\nTime can be controlled within a test by using methods on the fixture:\n\n``` python\ndef test_freezer_methods(freezer):\n freezer.move_to(\"2022-10-17\")\n assert datetime.now() == datetime(2022, 10, 17)\n freezer.tick()\n assert datetime.now() == datetime(2022, 10, 17, 0, 0, 1)\n freezer.tick(delta=12)\n assert datetime.now() == datetime(2022, 10, 17, 0, 0, 13)\n```\n\n## Acknowledgements:\n\nCredit to Tomasz Kontusz for the original [pytest-freezegun][4] plugin.\n\n[1]: https://docs.pytest.org/\n[2]: https://github.com/spulec/freezegun\n[3]: https://github.com/spulec/freezegun#usage\n[4]: https://github.com/ktosiek/pytest-freezegun\n\n",
"bugtrack_url": null,
"license": null,
"summary": "Pytest plugin providing a fixture interface for spulec/freezegun",
"version": "0.4.9",
"project_urls": {
"Homepage": "https://github.com/pytest-dev/pytest-freezer"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "c1e930252bc05bcf67200a17f4f0b4cc7598f0a68df4fa9fa356193aa899f145",
"md5": "389e999b2454b278963239e7d97940e4",
"sha256": "8b6c50523b7d4aec4590b52bfa5ff766d772ce506e2bf4846c88041ea9ccae59"
},
"downloads": -1,
"filename": "pytest_freezer-0.4.9-py3-none-any.whl",
"has_sig": false,
"md5_digest": "389e999b2454b278963239e7d97940e4",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6",
"size": 3192,
"upload_time": "2024-12-12T08:53:07",
"upload_time_iso_8601": "2024-12-12T08:53:07.641149Z",
"url": "https://files.pythonhosted.org/packages/c1/e9/30252bc05bcf67200a17f4f0b4cc7598f0a68df4fa9fa356193aa899f145/pytest_freezer-0.4.9-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "81f098dcbc5324064360b19850b14c84cea9ca50785d921741dbfc442346e925",
"md5": "9a1183950d820d51d5e77548d009c542",
"sha256": "21bf16bc9cc46bf98f94382c4b5c3c389be7056ff0be33029111ae11b3f1c82a"
},
"downloads": -1,
"filename": "pytest_freezer-0.4.9.tar.gz",
"has_sig": false,
"md5_digest": "9a1183950d820d51d5e77548d009c542",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 3177,
"upload_time": "2024-12-12T08:53:08",
"upload_time_iso_8601": "2024-12-12T08:53:08.684980Z",
"url": "https://files.pythonhosted.org/packages/81/f0/98dcbc5324064360b19850b14c84cea9ca50785d921741dbfc442346e925/pytest_freezer-0.4.9.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-12-12 08:53:08",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "pytest-dev",
"github_project": "pytest-freezer",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "pytest-freezer"
}