adamchainz/time-machine

Public

Travel through time in your tests.

  • Stars1k+4 tuần này
  • Forks54
  • Watchers9
  • Issues8
  • Ngày tạo29/04/2020
  • Cập nhật gần nhất27/10/2026
  • Ngôn ngữPython
  • Giấy phépMIT
README.rst5.6 KBRaw

time-machine

https://img.shields.io/readthedocs/time-machine?style=for-the-badge https://img.shields.io/github/actions/workflow/status/adamchainz/time-machine/main.yml.svg?branch=main&style=for-the-badge https://img.shields.io/badge/Coverage-100%25-success?style=for-the-badge https://img.shields.io/pypi/v/time-machine.svg?style=for-the-badge https://img.shields.io/badge/code%20style-black-000000.svg?style=for-the-badge pre-commit
time-machine logo

Travel through time in your tests.

A quick example:

import datetime as dt
from zoneinfo import ZoneInfo
import time_machine

hill_valley_tz = ZoneInfo("America/Los_Angeles")


@time_machine.travel(dt.datetime(1985, 10, 26, 1, 24, tzinfo=hill_valley_tz))
def test_delorean():
    assert dt.date.today().isoformat() == "1985-10-26"

Documentation

Please see https://time-machine.readthedocs.io/.

Nội dung README thuộc về adamchainz và cộng đồng đóng góp, giấy phép MIT. Nguồn: github.com/adamchainz/time-machine