Skip to content

Replace mock.patch("utcnow") with time_machine. - #53642

Merged
ashb merged 1 commit into
apache:mainfrom
astronomer:timemachine-not-patch-utcnow
Jul 22, 2025
Merged

Replace mock.patch("utcnow") with time_machine.#53642
ashb merged 1 commit into
apache:mainfrom
astronomer:timemachine-not-patch-utcnow

Conversation

@ashb

@ashbashb commented Jul 22, 2025

Copy link
Copy Markdown
Member

As part of a future PR (#53149) we are going to move the location of this function, and more
generally we shouldn't be mocking a specific function, time_machine is better
suited to this task.

It would be nice if we could add a ruff/etc rule to forbid this, but I can't
think of a way of enforcing this.

@ashb

ashb commented Jul 22, 2025

Copy link
Copy Markdown
MemberAuthor

There are one or two uses in tests in core, but that I will do as part of the mentioned PR -- this one is providers only to isolate changes for release easier.

@ashbashb added the log exception Set the label if you want to accept change with caplog label Jul 22, 2025
@ashbashb closed this Jul 22, 2025
@ashbashb reopened this Jul 22, 2025
@ashb

ashb commented Jul 22, 2025

Copy link
Copy Markdown
MemberAuthor

Added log exception label as I didn't change the use of the fixture in this PR

@ashb
ashbforce-pushed the timemachine-not-patch-utcnow branch 2 times, most recently from f1f1558 to b2aa877CompareJuly 22, 2025 16:21
As part of a future PR we are going to move the location of this function, and more
generally we shouldn't be mocking a specific function, time_machine is better
suited to this task.
It would be nice if we could add a ruff/etc rule to forbid this, but I can't
think of a way of enforcing this.
@ashb
ashbforce-pushed the timemachine-not-patch-utcnow branch from b2aa877 to 31b2eefCompareJuly 22, 2025 19:27
@ashb
ashb merged commit 584050d into apache:mainJul 22, 2025
75 checks passed
@ashb
ashb deleted the timemachine-not-patch-utcnow branch July 22, 2025 20:16
ashb added a commit that referenced this pull request Jul 23, 2025
ashb added a commit that referenced this pull request Jul 23, 2025
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:providerslog exceptionSet the label if you want to accept change with caplogprovider:amazonAWS/Amazon - related issuesprovider:databricksprovider:openlineageAIP-53provider:snowflakeIssues related to Snowflake providerprovider:standard

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

@ashb@potiuk@kaxil@eladkal@jedcunningham