The NetBSD Project

CVS log for pkgsrc/time/py-time-machine/Makefile

[BACK] Up to [cvs.NetBSD.org] / pkgsrc / time / py-time-machine

Request diff between arbitrary revisions


Keyword substitution: kv
Default branch: MAIN


Revision 1.19: download - view: text, markup, annotated - select for diffs
Wed Oct 28 08:30:15 2026 UTC (2 weeks, 5 days ago) by adam
Branches: MAIN
CVS tags: HEAD
Diff to: previous 1.18: preferred, colored
Changes since revision 1.18: +2 -2 lines
py-time-machine: updated to 3.6.0

3.6.0 (2026-10-25)

Drop Python 3.10 support.
Extend the Migration CLI to migrate freeze_time() class decorators on pytest-style test classes to the pytest.mark.time_machine() marker. Previously, such decorators were left unchanged and reported, since time_machine.travel() only supports unittest.TestCase subclasses as a class decorator, but they can be migrated to the marker instead.

Extend the Migration CLI to migrate freeze_time() calls that pass the destination with the time_to_freeze keyword argument. The argument is made positional, or renamed to destination if it follows another kept keyword argument.

Revision 1.18: download - view: text, markup, annotated - select for diffs
Wed Sep 9 08:11:32 2026 UTC (2 months, 1 week ago) by adam
Branches: MAIN
CVS tags: pkgsrc-2026Q3-base, pkgsrc-2026Q3
Diff to: previous 1.17: preferred, colored
Changes since revision 1.17: +2 -2 lines
py-time-machine: updated to 3.5.1

3.5.1

Only pass the compiler option -mno-omit-leaf-frame-pointer when the compiler supports it, checked with a tiny probe program. The option is unsupported outside of x86 and ARM64, so this fixes building from source on other architectures, like PowerPC, which failed since the option was added in version 3.3.0.

Fix the mocked datetime.date.today() and datetime.datetime.today() to be exact for all supported dates, like datetime.datetime.now(). Previously, they went through a floating-point timestamp, which could round the microseconds, or even the whole day, for dates far in the future.

Fix the class decorator to stop time travelling when tearDownClass() raises an exception, or when setUpClass() raises an exception not deriving from Exception, such as the skip outcome from pytest.skip(). Previously, time remained mocked for the rest of the process in these cases.

Fix Traveller.move_to() to keep the current timezone mocked when the given destination is unsupported. Previously, the timezone was restored before the destination was checked, leaving it unmocked whilst still time travelling.

Fix the time_machine pytest fixture to not try to stop a traveller that failed to start.

Fix the mocked time.strftime() to raise TypeError when passed None as its second argument, like the unmocked function, rather than treating it as the current time.

Fix the Migration CLI to keep the rewritten imports on the same line when a freezegun import shares its line with other code, like if TYPE_CHECKING: from freezegun import freeze_time, FakeDate. Previously, the remaining from freezegun import FakeDate was moved to a new line, outside the block.

Extend the Migration CLI to migrate uses of FrozenDateTimeFactory in string annotations, like freezer: "FrozenDateTimeFactory". Previously, the import was removed whilst such annotations were left referring to it.

Fix the Migration CLI to not rename a freezer argument when the function already has a time_machine argument, which produced invalid syntax.

Fix the Migration CLI to report positions in the rewritten file, rather than the original. Previously, positions could be off when rewrites earlier in the file changed the number of lines, or the length of the same line.

Fix the Migration CLI to not report a freezegun usage for migrated calls with a parenthesized module name, like (freezegun).freeze_time(...).

Fix the Migration CLI to leave a pass statement when removing every unused FrozenDateTimeFactory import in a block, rather than producing invalid syntax.

Make TimeMachineFixture importable even when pytest isn’t installed. This avoids triggering possibly-missing-attribute or possibly-missing-import violations in ty for test files with annotations.

Revision 1.17: download - view: text, markup, annotated - select for diffs
Thu Aug 27 05:43:54 2026 UTC (2 months, 2 weeks ago) by adam
Branches: MAIN
Diff to: previous 1.16: preferred, colored
Changes since revision 1.16: +2 -2 lines
py-time-machine: updated to 3.5.0

3.5.0 (2026-08-25)
Support None as a destination for travel() and Traveller.move_to(), meaning the current time. Use this with tick=False to freeze time at the present moment, matching freezegun’s behaviour when freeze_time() is called with no arguments.

Extend the Migration CLI to migrate aliased imports: import freezegun as fg and from freezegun import freeze_time as ft, plus calls using such aliases.

Extend the Migration CLI to migrate the pytest.mark.freeze_time marker in module-level and class-level pytestmark assignments.

Extend the Migration CLI to migrate freeze_time() calls and markers that pass tz_offset with a literal zero value. The argument is dropped, since a zero offset has no effect.

Extend the Migration CLI to migrate freeze_time() calls and markers that pass real_asyncio. The argument is dropped, whatever its value, since time-machine does not mock time.monotonic(), so asyncio event loops always see real time.

Extend the Migration CLI to migrate freeze_time() calls and markers with no destination argument, which freeze at the current time. None is added as the destination, using the new support for None destinations (above).

Extend the Migration CLI to migrate freeze_time() calls and markers that pass ignore. The argument is dropped, since it works around problems with freezegun’s module patching, which time-machine’s C-level mocking doesn’t have.

Make the Migration CLI report freezegun-related usages that it recognizes but cannot migrate, with their positions, like:
example/tests.py:9:2: freeze_time usage not migrated

This makes it easier to find and fix the remaining usages manually.

Make the Migration CLI report files that cannot be parsed, rather than skipping them silently. This helps notice files using syntax from a newer Python version than the tool is run with.

Extend the Migration CLI to migrate “raw use” assignments of freeze_time() to variables or self. attributes used with start() and stop(), covering unittest setUp() / tearDown() patterns like self.freezer = freeze_time(...) with self.addCleanup(self.freezer.stop).

Extend the Migration CLI to migrate imports and uses of freezegun’s FrozenDateTimeFactory class, often used to annotate the freezer fixture argument, to time-machine’s newly-documented equivalent, time_machine.TimeMachineFixture.

Revision 1.16: download - view: text, markup, annotated - select for diffs
Mon Aug 17 12:27:11 2026 UTC (2 months, 4 weeks ago) by adam
Branches: MAIN
Diff to: previous 1.15: preferred, colored
Changes since revision 1.15: +2 -2 lines
py-time-machine: updated to 3.4.0

3.4.0

Publish wheels for Python 3.15.

Fix a reference leak in the patched datetime.datetime.utcnow() that occurred when its Python 3.12+ DeprecationWarning was raised as an error, such as under -W error. Each such call leaked a reference to the active traveller object.

Extend the Migration CLI to migrate patterns from freezegun’s pytest plugins, pytest-freezegun and pytest-freezer: the freezer fixture and the pytest.mark.freeze_time marker. Also make it migrate freeze_time() context managers that bind the result with as, including converting tick() method calls to shift().

Fix the Migration CLI to handle trailing commas in freeze_time() calls when adding tick=False. Previously, it produced invalid syntax, like travel("2023-01-01",, tick=False).

Fix the Migration CLI to not indent imports kept from a rewritten from-import when the import doesn’t start its line, such as after if True: on one line. Previously, the kept import gained leading whitespace, producing invalid syntax.

Revision 1.15: download - view: text, markup, annotated - select for diffs
Mon Aug 10 11:42:43 2026 UTC (3 months ago) by adam
Branches: MAIN
Diff to: previous 1.14: preferred, colored
Changes since revision 1.14: +2 -2 lines
py-time-machine: updated to 3.3.1

3.3.1

Fix small rounding errors in destination calculations.
Previously, time-machine computed destinations in floating-point seconds, which could lead to small rounding errors: up to a few hundred nanoseconds for present-day destinations, growing to several microseconds by the year 2500. This change fixes the pipeline to use integer nanoseconds throughout, so time-travel is precise for any supported date.


3.3.0

Support Python 3.15.

Mock datetime.date.today() directly, for Python 3.15 support.
Previously time-machine was mocked only indirectly, since CPython implemented it by calling cls.fromtimestamp(time.time()). Python 3.15 added a fast path that reads the system clock directly (CPython Issue 130980), so time travel no longer affected it, which the new mock fixes. Consequently, there are new escape hatch functions: escape_hatch.datetime.date.today() and escape_hatch.datetime.datetime.today().

Support isolated subinterpreters, as created by concurrent.interpreters on Python 3.14+. Previously, importing time-machine in an isolated subinterpreter failed with an ImportError.

Move the intermediary functions that patched functions call from Python to C. This change reduces the overhead of calling patched functions like time.time() while time travelling, making them around 10-20% faster.

Fix returning datetime subclasses from their now() and utcnow() methods while time travelling. Previously, time-machine would always return a plain datetime.datetime instance, rather than the subclass.

Fix hiding of the DeprecationWarning from datetime.utcnow() on Python 3.12+ while time travelling. Previously, the mocked version of the function did not raise the warning at all, so deprecated calls could pass unnoticed in tests. The warning is attributed to the calling code, like the real function does.
The escape hatch function escape_hatch.datetime.datetime.utcnow() also now attributes its warning to the calling code, rather than to a line within time-machine.

Fix the standard uuid library functions uuid1(), uuid6(), and uuid7() to correctly generate values for the destination when time travels backwards. These functions cache the timestamp of the value they generated most recently, and never generate a value stamped before it. Previously, after time-travelling backwards, these functions would keep generating values stamped for the cached timestamp, rather than the new destination. The caches are now reset whenever time travel starts, stops, or moves backwards.

Build with frame pointers enabled, preparation for PEP 831.

Stop shipping wheels for 32-bit Linux and Windows.

Stop shipping wheels for free-threaded Python 3.13 since cibuildwheel 4.0.0 dropped support for building them.
Extend the Migration CLI to update freeze_time() calls that pass tick.

Extend the Migration CLI to rewrite freeze_time() decorators on async functions.

Fix the Migration CLI to leave relative imports called freezegun alone. Previously it rewrote from .freezegun import freeze_time, which imports from a local module that happens to share freezegun’s name.

Extend the Migration CLI to rewrite from-imports that import freeze_time alongside other names. For example, from freezegun import freeze_time, FakeDate now becomes import time_machine plus from freezegun import FakeDate.

Revision 1.14: download - view: text, markup, annotated - select for diffs
Mon Dec 22 10:05:18 2025 UTC (10 months, 3 weeks ago) by adam
Branches: MAIN
CVS tags: pkgsrc-2026Q2-base, pkgsrc-2026Q2, pkgsrc-2026Q1-base, pkgsrc-2026Q1
Diff to: previous 1.13: preferred, colored
Changes since revision 1.13: +2 -2 lines
py-time-machine: updated to 3.2.0

3.2.0

Add time_machine.naive_mode to control how time-machine interprets naive datetimes.
The default mode is MIXED, which preserves existing behaviour: naive datetime objects and date objects are interpreted as UTC, while naive datetime strings are interpreted as local time.

Three alternative modes are available:

UTC: naive datetimes are always interpreted as UTC.
LOCAL: naive datetimes are interpreted as local time, matching Python’s default semantics, and freezegun.
ERROR: naive datetimes raise a RuntimeError, ensuring your tests are isolated from the current timezone.
Note

It’s recommended you use LOCAL or ERROR to avoid confusion around naive datetimes.

Raise RuntimeError when attempting to start time travelling if freezegun is active.
This change should help avoid surprises when migrating complex test suites from freezegun to time-machine.

Revision 1.13: download - view: text, markup, annotated - select for diffs
Mon Dec 1 13:25:47 2025 UTC (11 months, 2 weeks ago) by adam
Branches: MAIN
CVS tags: pkgsrc-2025Q4-base, pkgsrc-2025Q4
Diff to: previous 1.12: preferred, colored
Changes since revision 1.12: +4 -3 lines
py-time-machine: updated to 3.1.0

3.1.0 (2025-11-21)
Optimize patching of uuid module. By avoiding using unittest.mock, this small overhead from starting time_machine.travel() has been reduced about 20x, from ~600ns to ~30ns by one benchmark.

3.0.0 (2025-11-18)
Remove mocking of time.monotonic() and time.monotonic_ns().
This mocking caused too many issues, such as causing freezes in asyncio event loops (Issue 387), preventing pytest-durations from timing tests correctly (Issue 505), and triggering timeouts in psycopg (Issue 509). The root cause here is that mocking the monotonic clock breaks its contract, allowing it to move backwards when it’s meant to only move forwards.

As an alternative, use unittest.mock to mock the monotonic function for the specific tested modules that need it. That means that your code should import monotonic() or monotonic_ns() directly, so that your tests can mock it in those places only. For example, if your system under test looks like:

# example.py
from time import monotonic


def measurement():
    start = monotonic()
    ...
    end = monotonic()
    return end - start

…then your tests can mock monotonic() like this:

from unittest import TestCase, mock

import example


class MeasurementTests(TestCase):
    def test_success(self):
        with mock.patch.object(example, "monotonic", side_effect=[0.0, 1.23]):
            result = example.measurement()
        assert result == 1.23

Parse str destinations with datetime.fromisoformat() first, before falling back to dateutil if installed. datetime.fromisoformat() can parse most valid ISO 8601 formats, with better performance and no extra dependencies.

Make the dependency on dateutil optional. To include dateutil support, install with the dateutil extra:
python -m pip install time-machine[dateutil]

Beware that some of the formats that dateutil parses are ambiguous and may lead to unexpected results.

Rename the Coordinates class to Traveller, to match the recommended context manager variable name.

Drop Python 3.9 support.
Make the escape_hatch functions raise ValueError when called outside of time-travelling, rather than triggering segmentation faults.

Revision 1.12: download - view: text, markup, annotated - select for diffs
Thu Aug 21 07:11:27 2025 UTC (14 months, 3 weeks ago) by adam
Branches: MAIN
CVS tags: pkgsrc-2025Q3-base, pkgsrc-2025Q3
Diff to: previous 1.11: preferred, colored
Changes since revision 1.11: +2 -2 lines
py-time-machine: updated to 2.19.0

2.19.0 (2025-08-19)
Add marker support to the pytest plugin. Decorate tests with @pytest.mark.time_machine(<destination>) to set time during a test, affecting function-level fixtures as well.

Add asynchronous context manager support to time_machine.travel(). You can now use async with time_machine.travel(...): in asynchronous code, per the documentation.

Import date and time functions once in the C extension.
This should improve speed a little bit, and avoid segmentation faults when the functions have been swapped out, such as when freezegun is in effect. (time-machine still won’t apply if freezegun is in effect.)


2.18.0 (2025-08-18)
Update the migration CLI to detect unittest classes based on whether they use self.assert* methods like self.assertEqual().
Fix free-threaded Python warning: RuntimeWarning: The global interpreter lock (GIL) has been enabled... as seen on Python 3.13+.

Add support to travel() for datetime destinations with tzinfo set to datetime.UTC (datetime.timezone.utc).

Prevent segmentation faults in unlikely scenarios, such as if the time_machine module cannot be imported.

Make travel() fully unpatch date and time functions when travel ends. This may fix certain edge cases.

Revision 1.11: download - view: text, markup, annotated - select for diffs
Sun Aug 10 08:18:57 2025 UTC (15 months ago) by adam
Branches: MAIN
Diff to: previous 1.10: preferred, colored
Changes since revision 1.10: +2 -3 lines
py-time-machine: updated to 2.17.0

2.17.0

Include wheels for Python 3.14.

Support free-threaded Python.

Add a new CLI for migrating code from freezegun to time-machine.
Install with pip install time-machine[cli] and run with python -m time_machine migrate.

See more in the documentation.

Move the documentation to Read the Docs, and add a retro-futuristic logo.

Revision 1.10: download - view: text, markup, annotated - select for diffs
Mon Apr 14 08:49:21 2025 UTC (19 months ago) by adam
Branches: MAIN
CVS tags: pkgsrc-2025Q2-base, pkgsrc-2025Q2
Diff to: previous 1.9: preferred, colored
Changes since revision 1.9: +3 -2 lines
Fix PLIST after py-setuptools update; bump depends and revision

Revision 1.9: download - view: text, markup, annotated - select for diffs
Mon Nov 11 07:29:13 2024 UTC (2 years ago) by wiz
Branches: MAIN
CVS tags: pkgsrc-2025Q1-base, pkgsrc-2025Q1, pkgsrc-2024Q4-base, pkgsrc-2024Q4
Diff to: previous 1.8: preferred, colored
Changes since revision 1.8: +1 -2 lines
py-*: remove unused tool dependency

py-setuptools includes the py-wheel functionality nowadays

Revision 1.8: download - view: text, markup, annotated - select for diffs
Mon Oct 14 05:18:43 2024 UTC (2 years, 1 month ago) by adam
Branches: MAIN
Diff to: previous 1.7: preferred, colored
Changes since revision 1.7: +2 -4 lines
py-time-machine: updated to 2.16.0

2.16.0 (2024-10-08)

* Drop Python 3.8 support.

Revision 1.7: download - view: text, markup, annotated - select for diffs
Wed Aug 7 10:31:13 2024 UTC (2 years, 3 months ago) by adam
Branches: MAIN
CVS tags: pkgsrc-2024Q3-base, pkgsrc-2024Q3
Diff to: previous 1.6: preferred, colored
Changes since revision 1.6: +2 -2 lines
py-time-machine: updated to 2.15.0

2.15.0 (2024-08-06)

* Include wheels for Python 3.13.

Revision 1.6: download - view: text, markup, annotated - select for diffs
Sun Jun 30 09:50:30 2024 UTC (2 years, 4 months ago) by adam
Branches: MAIN
Diff to: previous 1.5: preferred, colored
Changes since revision 1.5: +3 -3 lines
py-time-machine: updated to 2.14.2

2.14.2 (2024-06-29)

* Fix ``SystemError`` on Python 3.13 and Windows when starting time travelling.

Revision 1.5: download - view: text, markup, annotated - select for diffs
Sat Mar 23 07:16:23 2024 UTC (2 years, 7 months ago) by adam
Branches: MAIN
CVS tags: pkgsrc-2024Q2-base, pkgsrc-2024Q2, pkgsrc-2024Q1-base, pkgsrc-2024Q1
Diff to: previous 1.4: preferred, colored
Changes since revision 1.4: +2 -2 lines
py-time-machine: updated to 2.14.1

2.14.1 (2024-03-22)

* Fix segmentation fault when the first ``travel()`` call in a process uses a ``timedelta``.

Revision 1.4: download - view: text, markup, annotated - select for diffs
Tue Mar 5 17:07:59 2024 UTC (2 years, 8 months ago) by adam
Branches: MAIN
Diff to: previous 1.3: preferred, colored
Changes since revision 1.3: +6 -4 lines
py-time-machine: updated to 2.14.0

2.14.0 (2024-03-03)

* Fix ``utcfromtimestamp()`` warning on Python 3.12+.
* Fix class decorator for classmethod overrides.
* Avoid calling deprecated ``uuid._load_system_functions()`` on Python 3.9+.
* Support Python 3.13 alpha 4.

Revision 1.3: download - view: text, markup, annotated - select for diffs
Wed Sep 27 09:37:32 2023 UTC (3 years, 1 month ago) by adam
Branches: MAIN
CVS tags: pkgsrc-2023Q4-base, pkgsrc-2023Q4
Diff to: previous 1.2: preferred, colored
Changes since revision 1.2: +2 -2 lines
py-time-machine: updated to 2.13.0

2.13.0 (2023-09-19)
-------------------
* Add support for ``datetime.timedelta`` to ``time_machine.travel()``.
* Fix documentation about using local time for naive date(time) strings.
* Add ``shift()`` method to the ``time_machine`` pytest fixture.
* Mock ``time.monotonic()`` and ``time.monotonic_ns()``.
  They return the values of ``time.time()`` and ``time.time_ns()`` respectively, rather than real monotonic clocks.

Revision 1.2: download - view: text, markup, annotated - select for diffs
Thu Aug 31 18:00:08 2023 UTC (3 years, 2 months ago) by adam
Branches: MAIN
CVS tags: pkgsrc-2023Q3-base, pkgsrc-2023Q3
Diff to: previous 1.1: preferred, colored
Changes since revision 1.1: +2 -2 lines
py-time-machine: updated to 2.12.0

2.12.0 (2023-08-14)
-------------------

* Include wheels for Python 3.12.

Revision 1.1: download - view: text, markup, annotated - select for diffs
Mon Jul 17 16:08:31 2023 UTC (3 years, 4 months ago) by adam
Branches: MAIN
py-time-machine: added version 2.11.0

Travel through time in your tests.

Diff request

This form allows you to request diffs between any two revisions of a file. You may select a symbolic revision name using the selection box or you may type in a numeric name using the type-in text box.

Log view options

CVSweb <webmaster@jp.NetBSD.org>