{"id":18676603,"url":"https://github.com/hitchdev/faketime","last_synced_at":"2025-04-12T02:13:54.719Z","repository":{"id":32585244,"uuid":"36168460","full_name":"hitchdev/faketime","owner":"hitchdev","description":"Python wrapper around libfaketime.","archived":false,"fork":false,"pushed_at":"2019-10-12T16:19:05.000Z","size":85,"stargazers_count":8,"open_issues_count":5,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-12T02:13:49.462Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hitchdev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-05-24T11:03:13.000Z","updated_at":"2025-04-11T21:21:00.000Z","dependencies_parsed_at":"2022-09-02T15:31:17.510Z","dependency_job_id":null,"html_url":"https://github.com/hitchdev/faketime","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hitchdev%2Ffaketime","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hitchdev%2Ffaketime/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hitchdev%2Ffaketime/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hitchdev%2Ffaketime/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hitchdev","download_url":"https://codeload.github.com/hitchdev/faketime/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248505925,"owners_count":21115354,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-07T09:29:58.717Z","updated_at":"2025-04-12T02:13:54.697Z","avatar_url":"https://github.com/hitchdev.png","language":"C","readme":"# Faketime\n\nFaketime is a thin python wrapper around the amazing C library [libfaketime](https://github.com/wolfcw/libfaketime), written\nby [Wolfgang Hommel](https://github.com/wolfcw) which you can use to lie to UNIX processes about what time and date it is.\n\n\n## Why does this wrapper exist?\n\n* It provides an interface that is convenient and pythonic that you can use to lie to subprocesses run with python.\n* It provides an python interface that is identical on both Mac OS X and Linux (libfaketime is used in a slightly different way on both).\n* It provides a self contained library that can be installed in a virtualenv that runs consistently in any environment - installing libfaketime from package manager can instead get you older, buggy versions on different operating systems and package managers.\n\n## Install\n\n```\npip install faketime\n```\n\n## Using\n\n```\n\u003e\u003e\u003e from commandlib import Command\n\u003e\u003e\u003e from faketime import Faketime\n\u003e\u003e\u003e from datetime import datetime\n\u003e\u003e\u003e faketime = Faketime(\"currenttime.txt\")\n\u003e\u003e\u003e datecmd\n{'LD_PRELOAD': '/full/path/to/virtualenv/site-packages/faketime/libfaketime.so.1', 'FAKETIME_TIMESTAMP_FILE': '/full/path/to/currenttime.txt'}\n\n\n\u003e\u003e\u003e datecmd = Command(\"date\").with_env(**faketime.env_vars)\n\u003e\u003e\u003e datecmd.run()\n[ should print current time ]\n\n\u003e\u003e\u003e faketime.change_time(datetime(2050, 6, 7, 10, 9, 22, 713689))\n\u003e\u003e\u003e datecmd.run()\nTue  7 Jun 10:09:21 BST 2050\n```\n\nThis above example shows how to use faketime with [commandlib](https://hitchdev.com/commandlib/), although\nthe environment variables in the dict can be used with any command runner (e.g. Popen).\n\n## What's the story behind this library?\n\nThis library can be used for a number of purposes, but I mainly built it so that I could write\ntests with [hitchstory](https://hitchdev.com/hitchstory) that would lie to postgres,\ndjango and celery simultaneously about what date and time it was.\n\nInitially I tried using [freezegun](https://github.com/spulec/freezegun) to test the python code, but I realized that it only really\nworked on one snippet of code at a time. Moreover:\n\n* If that code executed a python process that contained other code that other code would get the *current* time, not the frozen time, breaking the test.\n* It was simply incapable of faking, say, postgres's time, so if an SQL query embedded a datetime query then that would break the test.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhitchdev%2Ffaketime","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhitchdev%2Ffaketime","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhitchdev%2Ffaketime/lists"}