spulec

freezegun: Freeze Time in Python Tests

Freezegun is a Python testing library that mocks the datetime module so tests can run against a fixed or moving time. It suits tests for date-sensitive behavior, with options for ticking, time zones, and asyncio.

InactivePythonApache-2.0LibraryTestingDeveloper Tools
View on GitHub Compare
Stars
4.5k
Forks
308
Stars, last 30 days
+4
Last commit
1.2 years ago
Contributors
100+

Our take

Inactiveno commits in over a year

Health score

36/100

How it is scored
Activity
19
Community
83
Issues
21
Pull requests
21

+4 stars in the last 30 days

  • More contributors than 78% of the projects we track

Freezegun is a focused, flexible choice for controlling time in Python tests, but its inactive status makes future maintenance a consideration.

Good fit if

  • Your Python tests need deterministic dates or controlled clock changes.
  • You want decorator, context-manager, and manual control options for a test freezer.
  • Your team is comfortable adopting an Apache-2.0 licensed project that is currently inactive.

Look elsewhere if

  • Your project needs a dependency with recent commits or active issue and pull-request handling.
  • You need a tool for a language other than Python.
  • Your time-testing needs are outside the datetime and time functions described by Freezegun.
All health signals
Last commit2025-08-19 (1.2 years ago)
Commits, last 90 days0
Releases, last 12 months0 (latest 1.5.5, 2025-08-09)
Contributors100+ (top contributor: 43% of commits)
Issues closed, last 90 days0
Pull requests merged, last 90 days0
Project age13 years

Checked on 2026-10-26 with the GitHub API.

Project history

Daily GitHub snapshots since Oct 7, 2026. History covers stars and forks; health signals are not tracked historically.

Selected snapshot

Stars

4,534

Forks

307

Change since Nov 9, 2026: -1 stars·-1 forks

Overview

Freezegun is a Python testing library that mocks Python's datetime module to let tests travel through time. It solves the problem of testing date- and time-dependent behavior against the actual clock, which can make results harder to control.

Use it as a decorator, context manager, or manually started freezer. It also controls several time functions, and supports advancing or moving the frozen time. The project is currently marked inactive, so teams should weigh that maintenance status when choosing it.

Key Features

  • Freeze datetime.now(), datetime.utcnow(), and date.today() during a test.
  • Freeze calls including time.time(), time.localtime(), and time.gmtime().
  • Apply a freeze to a function, test class, or code block.
  • Configure time zone offsets and parse readable date strings.
  • Keep time ticking, increment it automatically, or advance it manually.
  • Move the frozen clock to another date while a test is running.
  • Set real_asyncio=True so asyncio event loops can use real monotonic time.
  • Ignore selected packages when freezing time would interfere with them.

Use Cases

  • Python developers can test date-based rules, such as expiry or scheduling, without depending on the current date.
  • Test authors can check behavior across time zones using a controlled offset.
  • Teams can test code that measures elapsed time by advancing a frozen clock manually.
  • Async Python test authors can freeze wall-clock dates while allowing asyncio to see real monotonic time.

What you need

Detected in the repository

  • Python (from pyproject.toml)
  • A test suite and automated checks on GitHub Actions

License in plain words

Apache-2.0permissive

  • Commercial use: yes
  • Modify and redistribute: yes
  • You must keep: the license, the NOTICE file and a note of your changes
  • Share your changes: no
  • Includes an explicit patent grant from the contributors:

A summary, not legal advice: the LICENSE file is what applies.

Getting Started

Install with pip:

pip install freezegun

See the README for usage details and API options.

Considerations

The repository has had no commits in over a year and is marked inactive. It has at least 100 contributors, and contributor activity is not concentrated in one person, but the measured period shows no recent releases, merged pull requests, or closed issues. The README also notes that freezing does not modify function default arguments, and that class decoration may not work in every case. Review these constraints against your test suite before adopting it.

Found this useful?

Share it with someone who would like freezegun.