python-freezegun
Port variant v13
Summary Let your Python tests travel through time (3.13)
BROKEN
Package version 1.5.1
Homepage https://github.com/spulec/freezegun
Keywords python
Maintainer Python Automaton
License Not yet specified
Other variants v12
Ravenports Buildsheet | History
Ravensource Port Directory | History
Last modified 15 NOV 2024, 16:08:50 UTC
Port created 02 MAR 2023, 03:43:13 UTC
Subpackage Descriptions
single FreezeGun: Let your Python tests travel through time ==================================================== FreezeGun is a library that allows your Python tests to travel through time by mocking the datetime module. Usage ----- Once the decorator or context manager have been invoked, all calls to datetime.datetime.now(), datetime.datetime.utcnow(), datetime.date.today(), time.time(), time.localtime(), time.gmtime(), and time.strftime() will return the time that has been frozen. time.monotonic() and time.perf_counter() will also be frozen, but as usual it makes no guarantees about their absolute value, only their changes over time. Decorator ~~~~~~~~~ .. code-block:: python from freezegun import freeze_time import datetime import unittest # Freeze time for a pytest style test: @freeze_time("2012-01-14") def test(): assert datetime.datetime.now() == datetime.datetime(2012, 1, 14) # Or a unittest TestCase - freezes for every test, and set up and tear down code @freeze_time("1955-11-12") class MyTests(unittest.TestCase): def test_the_class(self): assert datetime.datetime.now() == datetime.datetime(1955, 11, 12) # Or any other class - freezes around each callable (may not work in every case) @freeze_time("2012-01-14") class Tester(object): def test_the_class(self): assert datetime.datetime.now() == datetime.datetime(2012, 1, 14) # Or method decorator, might also pass frozen time object as kwarg class TestUnitTestMethodDecorator(unittest.TestCase): @freeze_time('2013-04-09') def test_method_decorator_works_on_unittest(self): self.assertEqual(datetime.date(2013, 4, 9), datetime.date.today()) @freeze_time('2013-04-09', as_kwarg='frozen_time') def test_method_decorator_works_on_unittest(self, frozen_time): self.assertEqual(datetime.date(2013, 4, 9), datetime.date.today()) self.assertEqual(datetime.date(2013, 4, 9), frozen_time.time_to_freeze.today()) @freeze_time('2013-04-09', as_kwarg='hello') def test_method_decorator_works_on_unittest(self, **kwargs): self.assertEqual(datetime.date(2013, 4, 9), datetime.date.today()) self.assertEqual(datetime.date(2013, 4, 9), kwargs.get('hello').time_to_freeze.today()) Context manager ~~~~~~~~~~~~~~~ .. code-block:: python from freezegun import freeze_time def test(): assert datetime.datetime.now() != datetime.datetime(2012, 1, 14) with freeze_time("2012-01-14"): assert datetime.datetime.now() == datetime.datetime(2012, 1, 14) assert datetime.datetime.now() != datetime.datetime(2012, 1, 14) Raw use ~~~~~~~ .. code-block:: python from freezegun import freeze_time freezer = freeze_time("2012-01-14 12:00:01") freezer.start() assert datetime.datetime.now() == datetime.datetime(2012, 1, 14, 12, 0, 1) freezer.stop() Timezones ~~~~~~~~~
Configuration Switches (platform-specific settings discarded)
PY312 OFF Build using Python 3.12 PY313 ON Build using Python 3.13
Package Dependencies by Type
Build (only) python313:dev:std
python-pip:single:v13
autoselect-python:single:std
Build and Runtime python313:primary:std
Runtime (only) python-python-dateutil:single:v13
Download groups
main mirror://PYPIWHL/51/0b/0d7fee5919bccc1fdc1c2a7528b98f65c6f69b223a3fd8f809918c142c36
Distribution File Information
bf111d7138a8abe55ab48a71755673dbaa4ab87f4cff5634a4442dfec34c15f1 17569 python-src/freezegun-1.5.1-py3-none-any.whl
Ports that require python-freezegun:v13
python-rq-scheduler:v13 Job scheduling capabilities to Redis Queue (3.13)