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: .. code-block:
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: .. code-block:: sh
$ 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)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Hashes for libfaketime-tz-wrapper-1.0.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 77b51ff8a5c408b785c412cca95eebd4d6114ea689fc672904799e1e130dac4a |
|
MD5 | 21bc420f05fa4e3d30760d9c1dfd73e4 |
|
BLAKE2b-256 | a196e1e80775dced61c89d59fa13a2ac3af413204876b5e91061facb19f9e2e7 |