Skip to main content
Warning: You are using the test version of PyPI. This is a pre-production deployment of Warehouse. Changes made here affect the production instance of TestPyPI (
Help us improve Python packaging - Donate today!

A fast alternative to freezegun that wraps libfaketime.

Project Description

python-libfaketime is a wrapper of libfaketime for python.

import datetime

from libfaketime import fake_time, reexec_if_needed

# libfaketime needs to be preloaded by the dynamic linker.
# This will exec the same command, but with the proper environment variables set.
# Or you can skip running this and manually manage your env (see get_reload_information()).

def get_tomorrow():
    return + datetime.timedelta(days=1)

@fake_time('2014-01-01 00:00:00')
def test_get_tomorrow():
    assert get_tomorrow() ==, 1, 2)

It serves as a fast drop-in replacement for freezegun. Here’s the output of a totally unscientific benchmark on my laptop:

$ python
re-exec with libfaketime dependencies
timing 1000 executions of <class 'libfaketime.fake_time'>
0.021755 seconds

$ python freezegun
timing 1000 executions of <function freeze_time at 0x10aaa1140>
6.561472 seconds

Some brief details:

  • linux and osx
  • microsecond resolution
  • accepts datetimes and strings that can be parsed by dateutil
  • not threadsafe

Release History

This version
History Node


History Node


Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Hash SHA256 Hash Help Version File Type Upload Date
(36.1 kB) Copy SHA256 Hash SHA256
Source Mar 28, 2015

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting