Skip to content

Conversation

kingbuzzman
Copy link
Contributor

@kingbuzzman kingbuzzman commented Mar 25, 2025

This patch fixes a very niche scenario:

  1. When you have a fixture that depends on time.
  2. When you need to modify the time before the test is executed.
  3. AND be able to change the time while inside the test
import time

@pytest.fixture
def current_time():
     return time.time()

def test_normal(current_time):
    assert current_time > 1742943111.0

@pytest.mark.time_machine("2000-01-01")
def test_mod(current_time, time_machine):
    assert current_time == 946684800.0
    time_machine.shift(1)
    assert current_time == 946684800.0
    assert int(time.time()) == 946684801

Currently, the code fails:

    @time_machine.travel("2000-01-01")
    def test_mod(current_time, time_machine):
>       assert current_time == 946684800.0
E       assert 1742944978.9803169 == 946684800.0

If we ignore the ability of being able to modify a fixture before our test runs, we still get an error when trying to move the time along...

    @time_machine.travel("2000-01-01")
    def test_mod(current_time, time_machine):
        # assert current_time == 946684800.0
>       time_machine.shift(1)

test_file.py: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <time_machine.TimeMachineFixture object at 0xffff654ba2c0>, delta = 1

    def shift(self, delta: dt.timedelta | int | float) -> None:
        if self.traveller is None:
>           raise RuntimeError(
                "Initialize time_machine with move_to() before using shift()."
            )
E           RuntimeError: Initialize time_machine with move_to() before using shift().

Background: I am in the process of migrating pytest-freezegun to time-machine, in that migration I have a lot of code, specially testing celery tasks that rely on this methodology.

@pytest.mark.time_machine("2000-01-01")
def test_task(db_model_instances, time_machine):
    # Note: "db_model_instances" returns a model that has one or more 
    #       datetime fields that depends on the time set by the decorator
    task()
    assert thing == thing

    time_machine.shift(10)  # skip ahead X seconds
    task()
    assert thing == other_thing

This change would make my migration 100% smoother.

@kingbuzzman
Copy link
Contributor Author

@adamchainz can you authorize my PR to run all tests, i want to see the coverage. Thanks!

@kingbuzzman kingbuzzman marked this pull request as ready for review March 25, 2025 23:35
@kingbuzzman kingbuzzman changed the title Fixes fixture priority Integrate Marker-Based Time Machine Fixture in Pytest Mar 26, 2025
@kingbuzzman

This comment was marked as spam.

@kingbuzzman

This comment was marked as spam.

@kingbuzzman
Copy link
Contributor Author

@adamchainz can you explain to me what about this change you don't like? Maybe i can amend it?

@adamchainz
Copy link
Owner

My silence isn't rejection, just prioritisation. I like the feature. I will try do a sprint on Time Machine this month and integrate this PR.

@kingbuzzman kingbuzzman marked this pull request as draft July 7, 2025 16:22
@kingbuzzman
Copy link
Contributor Author

kingbuzzman commented Jul 7, 2025

For some reason 3.10 is is failing... Running tests here

@kingbuzzman
Copy link
Contributor Author

Woohoo! back in action! Not sure why this worked before..

@kingbuzzman kingbuzzman marked this pull request as ready for review July 9, 2025 17:58
@kingbuzzman
Copy link
Contributor Author

@adamchainz my bad, I didn't notice there were conflicts, and thus you couldn't merge it.

@kingbuzzman
Copy link
Contributor Author

Anything else you need me to do for this PR?

@adamchainz adamchainz changed the title Integrate Marker-Based Time Machine Fixture in Pytest Add marker support to pytest plugin Aug 19, 2025
@adamchainz adamchainz force-pushed the kingbuzzman-patch-1 branch from e9398ae to c253bf1 Compare August 19, 2025 14:31
@adamchainz adamchainz force-pushed the kingbuzzman-patch-1 branch from c253bf1 to bf430ff Compare August 19, 2025 14:33
@adamchainz adamchainz enabled auto-merge (squash) August 19, 2025 14:34
@adamchainz adamchainz merged commit 130333e into adamchainz:main Aug 19, 2025
12 checks passed
@kingbuzzman kingbuzzman deleted the kingbuzzman-patch-1 branch August 19, 2025 14:38
@kingbuzzman
Copy link
Contributor Author

@adamchainz thank you so much! Now I can start the freeze-gun migration! 🥳

inmantaci pushed a commit to inmanta/inmanta-core that referenced this pull request Aug 20, 2025
Bumps [time-machine](https://github.com/adamchainz/time-machine) from 2.18.0 to 2.19.0.
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a href="https://github.com/adamchainz/time-machine/blob/main/docs/changelog.rst">time-machine's changelog</a>.</em></p>
<blockquote>
<h2>2.19.0 (2025-08-19)</h2>
<ul>
<li>
<p>Add marker support to :doc:<code>the pytest plugin &lt;pytest_plugin&gt;</code>.
Decorate tests with <code>@pytest.mark.time_machine(&lt;destination&gt;)</code> to set time during a test, affecting function-level fixtures as well.</p>
<p>Thanks to Javier Buzzi in <code>PR [#499](adamchainz/time-machine#499) &lt;https://github.com/adamchainz/time-machine/pull/499&gt;</code>__.</p>
</li>
<li>
<p>Add asynchronous context manager support to <code>time_machine.travel()</code>.
You can now use <code>async with time_machine.travel(...):</code> in asynchronous code, per :ref:<code>the documentation &lt;travel-context-manager&gt;</code>.</p>
<p><code>PR [#556](adamchainz/time-machine#556) &lt;https://github.com/adamchainz/time-machine/issues/556&gt;</code>__.</p>
</li>
<li>
<p>Import date and time functions once in the C extension.</p>
<p>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.)</p>
<p><code>PR [#555](adamchainz/time-machine#555) &lt;https://github.com/adamchainz/time-machine/issues/555&gt;</code>__.</p>
</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="https://github.com/adamchainz/time-machine/commit/c64e79f89bdb02ed01866eb9f74c86006606ecd6"><code>c64e79f</code></a> Version 2.19.0</li>
<li><a href="https://github.com/adamchainz/time-machine/commit/aa78214ad6415c96d8e2f6e350457811927e9f3f"><code>aa78214</code></a> Edit changelog</li>
<li><a href="https://github.com/adamchainz/time-machine/commit/d4c2e643b7870728ca0b09ea79053d8da5ae7289"><code>d4c2e64</code></a> Edit changelog</li>
<li><a href="https://github.com/adamchainz/time-machine/commit/c271664fed8bdd4617f2cdea83e64aec621b449c"><code>c271664</code></a> Tweak title capitalization</li>
<li><a href="https://github.com/adamchainz/time-machine/commit/c9775a3c2aed74619db909110152f28dc9cae4cf"><code>c9775a3</code></a> Add asynchronous context manager support (<a href="https://redirect.github.com/adamchainz/time-machine/issues/556">#556</a>)</li>
<li><a href="https://github.com/adamchainz/time-machine/commit/130333ed769a2c9e2b87e30dd68414f00dfdde9b"><code>130333e</code></a> Add marker support to pytest plugin (<a href="https://redirect.github.com/adamchainz/time-machine/issues/499">#499</a>)</li>
<li><a href="https://github.com/adamchainz/time-machine/commit/428491ed7abc2ce9bc440b2898adea73a676128a"><code>428491e</code></a> Import more once in C extension (<a href="https://redirect.github.com/adamchainz/time-machine/issues/555">#555</a>)</li>
<li>See full diff in <a href="https://github.com/adamchainz/time-machine/compare/2.18.0...2.19.0">compare view</a></li>
</ul>
</details>
<br />

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=time-machine&package-manager=pip&previous-version=2.18.0&new-version=2.19.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)

</details>
inmantaci pushed a commit to inmanta/inmanta-core that referenced this pull request Aug 21, 2025
Bumps [time-machine](https://github.com/adamchainz/time-machine) from 2.18.0 to 2.19.0.
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a href="https://github.com/adamchainz/time-machine/blob/main/docs/changelog.rst">time-machine's changelog</a>.</em></p>
<blockquote>
<h2>2.19.0 (2025-08-19)</h2>
<ul>
<li>
<p>Add marker support to :doc:<code>the pytest plugin &lt;pytest_plugin&gt;</code>.
Decorate tests with <code>@pytest.mark.time_machine(&lt;destination&gt;)</code> to set time during a test, affecting function-level fixtures as well.</p>
<p>Thanks to Javier Buzzi in <code>PR [#499](adamchainz/time-machine#499) &lt;https://github.com/adamchainz/time-machine/pull/499&gt;</code>__.</p>
</li>
<li>
<p>Add asynchronous context manager support to <code>time_machine.travel()</code>.
You can now use <code>async with time_machine.travel(...):</code> in asynchronous code, per :ref:<code>the documentation &lt;travel-context-manager&gt;</code>.</p>
<p><code>PR [#556](adamchainz/time-machine#556) &lt;https://github.com/adamchainz/time-machine/issues/556&gt;</code>__.</p>
</li>
<li>
<p>Import date and time functions once in the C extension.</p>
<p>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.)</p>
<p><code>PR [#555](adamchainz/time-machine#555) &lt;https://github.com/adamchainz/time-machine/issues/555&gt;</code>__.</p>
</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="https://github.com/adamchainz/time-machine/commit/c64e79f89bdb02ed01866eb9f74c86006606ecd6"><code>c64e79f</code></a> Version 2.19.0</li>
<li><a href="https://github.com/adamchainz/time-machine/commit/aa78214ad6415c96d8e2f6e350457811927e9f3f"><code>aa78214</code></a> Edit changelog</li>
<li><a href="https://github.com/adamchainz/time-machine/commit/d4c2e643b7870728ca0b09ea79053d8da5ae7289"><code>d4c2e64</code></a> Edit changelog</li>
<li><a href="https://github.com/adamchainz/time-machine/commit/c271664fed8bdd4617f2cdea83e64aec621b449c"><code>c271664</code></a> Tweak title capitalization</li>
<li><a href="https://github.com/adamchainz/time-machine/commit/c9775a3c2aed74619db909110152f28dc9cae4cf"><code>c9775a3</code></a> Add asynchronous context manager support (<a href="https://redirect.github.com/adamchainz/time-machine/issues/556">#556</a>)</li>
<li><a href="https://github.com/adamchainz/time-machine/commit/130333ed769a2c9e2b87e30dd68414f00dfdde9b"><code>130333e</code></a> Add marker support to pytest plugin (<a href="https://redirect.github.com/adamchainz/time-machine/issues/499">#499</a>)</li>
<li><a href="https://github.com/adamchainz/time-machine/commit/428491ed7abc2ce9bc440b2898adea73a676128a"><code>428491e</code></a> Import more once in C extension (<a href="https://redirect.github.com/adamchainz/time-machine/issues/555">#555</a>)</li>
<li>See full diff in <a href="https://github.com/adamchainz/time-machine/compare/2.18.0...2.19.0">compare view</a></li>
</ul>
</details>
<br />

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=time-machine&package-manager=pip&previous-version=2.18.0&new-version=2.19.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)

</details>
ejfine pushed a commit to LabAutomationAndScreening/cloud-courier that referenced this pull request Aug 24, 2025
…p across 1 directory (#34)

Bumps the prod-dependencies group with 1 update in the / directory:
[time-machine](https://github.com/adamchainz/time-machine).

Updates `time-machine` from 2.17.0 to 2.19.0
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a
href="https://github.com/adamchainz/time-machine/blob/main/docs/changelog.rst">time-machine's
changelog</a>.</em></p>
<blockquote>
<h2>2.19.0 (2025-08-19)</h2>
<ul>
<li>
<p>Add marker support to :doc:<code>the pytest plugin
&lt;pytest_plugin&gt;</code>.
Decorate tests with
<code>@pytest.mark.time_machine(&lt;destination&gt;)</code> to set time
during a test, affecting function-level fixtures as well.</p>
<p>Thanks to Javier Buzzi in <code>PR
[#499](adamchainz/time-machine#499)
&lt;https://github.com/adamchainz/time-machine/pull/499&gt;</code>__.</p>
</li>
<li>
<p>Add asynchronous context manager support to
<code>time_machine.travel()</code>.
You can now use <code>async with time_machine.travel(...):</code> in
asynchronous code, per :ref:<code>the documentation
&lt;travel-context-manager&gt;</code>.</p>
<p><code>PR
[#556](adamchainz/time-machine#556)
&lt;https://github.com/adamchainz/time-machine/issues/556&gt;</code>__.</p>
</li>
<li>
<p>Import date and time functions once in the C extension.</p>
<p>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.)</p>
<p><code>PR
[#555](adamchainz/time-machine#555)
&lt;https://github.com/adamchainz/time-machine/issues/555&gt;</code>__.</p>
</li>
</ul>
<h2>2.18.0 (2025-08-18)</h2>
<ul>
<li>
<p>Update the :ref:<code>migration CLI &lt;migration-cli&gt;</code> to
detect unittest classes based on whether they use
<code>self.assert*</code> methods like
<code>self.assertEqual()</code>.</p>
</li>
<li>
<p>Fix free-threaded Python warning: <code>RuntimeWarning: The global
interpreter lock (GIL) has been enabled...</code> as seen on Python
3.13+.</p>
<p>Thanks to Javier Buzzi in <code>PR
[#531](adamchainz/time-machine#531)
&lt;https://github.com/adamchainz/time-machine/pull/531&gt;</code>__.</p>
</li>
<li>
<p>Add support to <code>travel()</code> for <code>datetime</code>
destinations with <code>tzinfo</code> set to <code>datetime.UTC</code>
(<code>datetime.timezone.utc</code>).</p>
<p>Thanks to Lawrence Law in <code>PR
[#502](adamchainz/time-machine#502)
&lt;https://github.com/adamchainz/time-machine/pull/502&gt;</code>__.</p>
</li>
<li>
<p>Prevent segmentation faults in unlikely scenarios, such as if the
<code>time_machine</code> module cannot be imported.</p>
<p><code>PR
[#543](adamchainz/time-machine#543)
&lt;https://github.com/adamchainz/time-machine/pull/543&gt;</code><strong>,
<code>PR [#545](adamchainz/time-machine#545)
&lt;https://github.com/adamchainz/time-machine/pull/545&gt;</code></strong>.</p>
</li>
<li>
<p>Make <code>travel()</code> fully unpatch date and time functions when
travel ends. This may fix certain edge cases.</p>
<p><code>Issue
[#532](adamchainz/time-machine#532)
&lt;https://github.com/adamchainz/time-machine/issues/532&gt;</code>__.</p>
</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/adamchainz/time-machine/commit/c64e79f89bdb02ed01866eb9f74c86006606ecd6"><code>c64e79f</code></a>
Version 2.19.0</li>
<li><a
href="https://github.com/adamchainz/time-machine/commit/aa78214ad6415c96d8e2f6e350457811927e9f3f"><code>aa78214</code></a>
Edit changelog</li>
<li><a
href="https://github.com/adamchainz/time-machine/commit/d4c2e643b7870728ca0b09ea79053d8da5ae7289"><code>d4c2e64</code></a>
Edit changelog</li>
<li><a
href="https://github.com/adamchainz/time-machine/commit/c271664fed8bdd4617f2cdea83e64aec621b449c"><code>c271664</code></a>
Tweak title capitalization</li>
<li><a
href="https://github.com/adamchainz/time-machine/commit/c9775a3c2aed74619db909110152f28dc9cae4cf"><code>c9775a3</code></a>
Add asynchronous context manager support (<a
href="https://redirect.github.com/adamchainz/time-machine/issues/556">#556</a>)</li>
<li><a
href="https://github.com/adamchainz/time-machine/commit/130333ed769a2c9e2b87e30dd68414f00dfdde9b"><code>130333e</code></a>
Add marker support to pytest plugin (<a
href="https://redirect.github.com/adamchainz/time-machine/issues/499">#499</a>)</li>
<li><a
href="https://github.com/adamchainz/time-machine/commit/428491ed7abc2ce9bc440b2898adea73a676128a"><code>428491e</code></a>
Import more once in C extension (<a
href="https://redirect.github.com/adamchainz/time-machine/issues/555">#555</a>)</li>
<li><a
href="https://github.com/adamchainz/time-machine/commit/728d0a6ec442d9b76ebc03f3ad7fcee94ffe6b24"><code>728d0a6</code></a>
Version 2.18.0</li>
<li><a
href="https://github.com/adamchainz/time-machine/commit/65a214ca8bf85d3e865109ff692773ea7eb60b92"><code>65a214c</code></a>
Import date/time modules once in C extension (<a
href="https://redirect.github.com/adamchainz/time-machine/issues/553">#553</a>)</li>
<li><a
href="https://github.com/adamchainz/time-machine/commit/9ff207b86d7b9c6cff95fdceab4093a4ddef16e9"><code>9ff207b</code></a>
Unpatch functions when travel ends (<a
href="https://redirect.github.com/adamchainz/time-machine/issues/550">#550</a>)</li>
<li>Additional commits viewable in <a
href="https://github.com/adamchainz/time-machine/compare/2.17.0...2.19.0">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=time-machine&package-manager=uv&previous-version=2.17.0&new-version=2.19.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore <dependency name> major version` will close this
group update PR and stop Dependabot creating any more for the specific
dependency's major version (unless you unignore this specific
dependency's major version or upgrade to it yourself)
- `@dependabot ignore <dependency name> minor version` will close this
group update PR and stop Dependabot creating any more for the specific
dependency's minor version (unless you unignore this specific
dependency's minor version or upgrade to it yourself)
- `@dependabot ignore <dependency name>` will close this group update PR
and stop Dependabot creating any more for the specific dependency
(unless you unignore this specific dependency or upgrade to it yourself)
- `@dependabot unignore <dependency name>` will remove all of the ignore
conditions of the specified dependency
- `@dependabot unignore <dependency name> <ignore condition>` will
remove the ignore condition of the specified dependency and ignore
conditions


</details>

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
github-merge-queue bot pushed a commit to frequenz-floss/frequenz-dispatch-python that referenced this pull request Sep 1, 2025
Bumps the minor group with 1 update:
[time-machine](https://github.com/adamchainz/time-machine).

Updates `time-machine` from 2.16.0 to 2.19.0
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a
href="https://github.com/adamchainz/time-machine/blob/main/docs/changelog.rst">time-machine's
changelog</a>.</em></p>
<blockquote>
<h2>2.19.0 (2025-08-19)</h2>
<ul>
<li>
<p>Add marker support to :doc:<code>the pytest plugin
&lt;pytest_plugin&gt;</code>.
Decorate tests with
<code>@pytest.mark.time_machine(&lt;destination&gt;)</code> to set time
during a test, affecting function-level fixtures as well.</p>
<p>Thanks to Javier Buzzi in <code>PR
[#499](adamchainz/time-machine#499)
&lt;https://github.com/adamchainz/time-machine/pull/499&gt;</code>__.</p>
</li>
<li>
<p>Add asynchronous context manager support to
<code>time_machine.travel()</code>.
You can now use <code>async with time_machine.travel(...):</code> in
asynchronous code, per :ref:<code>the documentation
&lt;travel-context-manager&gt;</code>.</p>
<p><code>PR
[#556](adamchainz/time-machine#556)
&lt;https://github.com/adamchainz/time-machine/issues/556&gt;</code>__.</p>
</li>
<li>
<p>Import date and time functions once in the C extension.</p>
<p>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.)</p>
<p><code>PR
[#555](adamchainz/time-machine#555)
&lt;https://github.com/adamchainz/time-machine/issues/555&gt;</code>__.</p>
</li>
</ul>
<h2>2.18.0 (2025-08-18)</h2>
<ul>
<li>
<p>Update the :ref:<code>migration CLI &lt;migration-cli&gt;</code> to
detect unittest classes based on whether they use
<code>self.assert*</code> methods like
<code>self.assertEqual()</code>.</p>
</li>
<li>
<p>Fix free-threaded Python warning: <code>RuntimeWarning: The global
interpreter lock (GIL) has been enabled...</code> as seen on Python
3.13+.</p>
<p>Thanks to Javier Buzzi in <code>PR
[#531](adamchainz/time-machine#531)
&lt;https://github.com/adamchainz/time-machine/pull/531&gt;</code>__.</p>
</li>
<li>
<p>Add support to <code>travel()</code> for <code>datetime</code>
destinations with <code>tzinfo</code> set to <code>datetime.UTC</code>
(<code>datetime.timezone.utc</code>).</p>
<p>Thanks to Lawrence Law in <code>PR
[#502](adamchainz/time-machine#502)
&lt;https://github.com/adamchainz/time-machine/pull/502&gt;</code>__.</p>
</li>
<li>
<p>Prevent segmentation faults in unlikely scenarios, such as if the
<code>time_machine</code> module cannot be imported.</p>
<p><code>PR
[#543](adamchainz/time-machine#543)
&lt;https://github.com/adamchainz/time-machine/pull/543&gt;</code><strong>,
<code>PR [#545](adamchainz/time-machine#545)
&lt;https://github.com/adamchainz/time-machine/pull/545&gt;</code></strong>.</p>
</li>
<li>
<p>Make <code>travel()</code> fully unpatch date and time functions when
travel ends. This may fix certain edge cases.</p>
<p><code>Issue
[#532](adamchainz/time-machine#532)
&lt;https://github.com/adamchainz/time-machine/issues/532&gt;</code>__.</p>
</li>
</ul>
<h2>2.17.0 (2025-08-05)</h2>
<ul>
<li>
<p>Include wheels for Python 3.14.</p>
<p>Thanks to Edgar Ramírez Mondragón in <code>PR
[#521](adamchainz/time-machine#521)
&lt;https://github.com/adamchainz/time-machine/pull/521&gt;</code>__.</p>
</li>
<li>
<p>Support free-threaded Python.</p>
</li>
</ul>
<!-- raw HTML omitted -->
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/adamchainz/time-machine/commit/c64e79f89bdb02ed01866eb9f74c86006606ecd6"><code>c64e79f</code></a>
Version 2.19.0</li>
<li><a
href="https://github.com/adamchainz/time-machine/commit/aa78214ad6415c96d8e2f6e350457811927e9f3f"><code>aa78214</code></a>
Edit changelog</li>
<li><a
href="https://github.com/adamchainz/time-machine/commit/d4c2e643b7870728ca0b09ea79053d8da5ae7289"><code>d4c2e64</code></a>
Edit changelog</li>
<li><a
href="https://github.com/adamchainz/time-machine/commit/c271664fed8bdd4617f2cdea83e64aec621b449c"><code>c271664</code></a>
Tweak title capitalization</li>
<li><a
href="https://github.com/adamchainz/time-machine/commit/c9775a3c2aed74619db909110152f28dc9cae4cf"><code>c9775a3</code></a>
Add asynchronous context manager support (<a
href="https://redirect.github.com/adamchainz/time-machine/issues/556">#556</a>)</li>
<li><a
href="https://github.com/adamchainz/time-machine/commit/130333ed769a2c9e2b87e30dd68414f00dfdde9b"><code>130333e</code></a>
Add marker support to pytest plugin (<a
href="https://redirect.github.com/adamchainz/time-machine/issues/499">#499</a>)</li>
<li><a
href="https://github.com/adamchainz/time-machine/commit/428491ed7abc2ce9bc440b2898adea73a676128a"><code>428491e</code></a>
Import more once in C extension (<a
href="https://redirect.github.com/adamchainz/time-machine/issues/555">#555</a>)</li>
<li><a
href="https://github.com/adamchainz/time-machine/commit/728d0a6ec442d9b76ebc03f3ad7fcee94ffe6b24"><code>728d0a6</code></a>
Version 2.18.0</li>
<li><a
href="https://github.com/adamchainz/time-machine/commit/65a214ca8bf85d3e865109ff692773ea7eb60b92"><code>65a214c</code></a>
Import date/time modules once in C extension (<a
href="https://redirect.github.com/adamchainz/time-machine/issues/553">#553</a>)</li>
<li><a
href="https://github.com/adamchainz/time-machine/commit/9ff207b86d7b9c6cff95fdceab4093a4ddef16e9"><code>9ff207b</code></a>
Unpatch functions when travel ends (<a
href="https://redirect.github.com/adamchainz/time-machine/issues/550">#550</a>)</li>
<li>Additional commits viewable in <a
href="https://github.com/adamchainz/time-machine/compare/2.16.0...2.19.0">compare
view</a></li>
</ul>
</details>
<br />

[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=time-machine&package-manager=pip&previous-version=2.16.0&new-version=2.19.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore <dependency name> major version` will close this
group update PR and stop Dependabot creating any more for the specific
dependency's major version (unless you unignore this specific
dependency's major version or upgrade to it yourself)
- `@dependabot ignore <dependency name> minor version` will close this
group update PR and stop Dependabot creating any more for the specific
dependency's minor version (unless you unignore this specific
dependency's minor version or upgrade to it yourself)
- `@dependabot ignore <dependency name>` will close this group update PR
and stop Dependabot creating any more for the specific dependency
(unless you unignore this specific dependency or upgrade to it yourself)
- `@dependabot unignore <dependency name>` will remove all of the ignore
conditions of the specified dependency
- `@dependabot unignore <dependency name> <ignore condition>` will
remove the ignore condition of the specified dependency and ignore
conditions

</details>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants