Skip to main content
Help us improve Python packaging – donate today!

A wrapper around python-libfaketime that introduces timezone-awareness.

Project Description

A wrapper around python-libfaketime that introduces awareness for (django) timezones.

Installation

Install with pip:

$ pip install libfaketime-tz-wrapper

Setup

libfaketime needs the LD_PRELOAD variable to be set.

If you run your tests in PyCharm, add it to the environment variables of your test configuration in PyCharm:

name: LD_PRELOAD
value: /home/foo/<snip>/vendor/libfaketime/src/libfaketime.so.1

If you run tests in the command line, export this environment variable when running the test command:

$ LD_PRELOAD=/home/foo/<snip>/vendor/libfaketime/src/libfaketime.so.1 <run test command>

In both cases, replace the <snip> part with the correct path to where the libfaketime package was installed.

Usage

import datetime

from libfaketime import fake_time

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


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

Release history Release notifications

This version
History Node

1.1.1

History Node

1.1.0

History Node

1.0.7

History Node

1.0.6

History Node

1.0.5

History Node

1.0.4

History Node

1.0.3

History Node

1.0.2

History Node

1.0.1

History Node

1.0.0

History Node

0.1.3

History Node

0.1.2

History Node

0.1.1

History Node

0.1.0

Download files

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

Filename, size & hash SHA256 hash help File type Python version Upload date
libfaketime-tz-wrapper-1.1.1.tar.gz (2.6 kB) Copy SHA256 hash SHA256 Source None Aug 1, 2016

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page