Skip to main content

TimeTravel

Stop sleeping through expiry tests. Start controlling time.

A modern Robot Framework library for deterministic time-dependent testing.


PyPI version Python 3.11+ Robot Framework 7.5+ License CI Tests Docs Build

robotframework-timetravel lets Robot Framework tests freeze, travel, advance, and rewind perceived time using time-machine.

It is designed for deterministic expiry and scheduling scenarios without writing Python mocking glue in every suite.

You can find the keyword documentation here

Perfect for:

  • OTP expiration
  • JWT and access-token lifetime
  • License and subscription renewals
  • Scheduled jobs and future dates
  • Retry windows and cooldown periods
  • Timezone-sensitive business rules

Why TimeTravel?

Traditional Robot Framework time checks often become:

${expires}=    Evaluate    time.time() + 300    modules=time
Sleep    5 minutes
Should Be True    ${True}

That is slow, brittle, and hard to repeat.

With TimeTravel:

Freeze Time    2026-01-01T10:00:00+00:00
Create OTP
Advance Time    5 minutes
Verify OTP Is Expired

No long sleeps. No flaky wall-clock races. No ad-hoc Python mocks.


Quick Start

Install from PyPI:

pip install robotframework-timetravel

Install from the repository:

pip install .

Install development dependencies:

pip install -e ".[dev]"
# or
pip install -r requirements.txt
pip install -e .

Simple Example

*** Settings ***
Library    TimeTravel

*** Test Cases ***
OTP Expires After Five Minutes
    [Teardown]    Reset Time
    Freeze Time    2026-01-01T10:00:00+00:00
    Create OTP
    Advance Time    5 minutes
    Verify OTP Is Expired

By default TimeTravel auto-resets at the end of every test. Disable with:

Library    TimeTravel    auto_reset=${False}

Architecture

TimeTravel is built around:

  • A thin Robot Framework keyword layer on robotframework-pythonlibcore
  • An internal ClockController with explicit lifecycle semantics
  • time-machine as the process-local clock backend
  • Duration and datetime parsers with clear validation errors
  • Optional auto-reset after each test
Robot Framework Keywords
  ↓
ClockController lifecycle
  ↓
time-machine traveller
  ↓
Python time / datetime APIs in this process

Feature Matrix

Category Keywords
Clock control Freeze Time, Freeze At Timestamp, Freeze At Real Time, Travel To Time, Travel To Timestamp, Advance Time, Rewind Time, Shift Time, Start Ticking Time, Pause Time, Resume Ticking Time, Advance To Next Weekday, Reset Time
Inspection Get Current Simulated Time, Get Current Simulated Timestamp, Get Current Simulated Timestamp Ns, Get Clock Mode, Time Travel Is Active, Get Real Time, Get Real Timestamp
Timezone / calendar Set Timezone, Get Current Timezone, Convert Datetime To Timezone, Get Current Simulated Time In Timezone, Format Simulated Time, Get Simulated Weekday
Assertions Simulated Time Should Be, Simulated Time Should Be After, Simulated Time Should Be Before, Simulated Timestamp Should Equal, Time Until Should Be, Fail If Time Travel Is Active

Implementation note:

  • src/TimeTravel/keywords/clock_control.py — clock control and inspection
  • src/TimeTravel/keywords/timezone_control.py — timezone/calendar helpers
  • src/TimeTravel/keywords/assertions.py — assertion keywords

Datetime and Duration Inputs

Accepted datetimes:

  • 2026-01-01T10:00:00+00:00
  • 2026-01-01T10:00:00
  • 2026-01-01 10:00:00
  • 2026-01-01

Naive values are interpreted in the timezone from Set Timezone (default UTC). Aware values keep their own timezone.

Accepted durations:

  • 30 seconds
  • 5 minutes
  • 2 hours
  • 31 days
  • 1 week
  • 1 day 6 hours
  • -2 hours (for Shift Time only)

Lifecycle Semantics

Situation Behavior
Freeze Time / Start Ticking Time while active Replaces the current clock
Travel To Time while idle Starts a frozen clock
Travel To Time while active Replaces the instant; keeps frozen/ticking mode
Advance / Rewind / Shift while idle Clear error
Reset Time Restores real time and interpretation timezone UTC
End of test (auto_reset=${True}) Implicit Reset Time

Limitations

This library manipulates Python-level time in the current process only.

It does not:

  • Accelerate the operating-system clock
  • Advance database-server clocks
  • Control browser JavaScript Date
  • Make concurrent tests safe when they share process-global clock state

See docs/limitations.md for the full list.


Examples

See examples/:

  • otp_expiry.robot
  • jwt_expiry.robot
  • subscription_expiry.robot
  • license_expiry.robot
  • timezone_handling.robot

Running Tests

pytest
PYTHONPATH=src robot tests/acceptance.robot
./build.sh

License

Apache-2.0

Metadata

Release files for robotframework-timetravel 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for robotframework-timetravel 0.1.0
File Size Uploaded Provenance Actions
robotframework_timetravel-0.1.0.tar.gz 20.8 kB Without provenance Details for robotframework_timetravel-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for robotframework-timetravel 0.1.0
File Interpreter ABI Platform Actions
robotframework_timetravel-0.1.0-py3-none-any.whl Python 3 none any Details for robotframework_timetravel-0.1.0-py3-none-any.whl

Total release size: 43.0 kB

Release files / robotframework_timetravel-0.1.0.tar.gz

Download URL robotframework_timetravel-0.1.0.tar.gz
Size 20.8 kB
Tags Source
SHA-256 checksum
How to use checksums
770e7245fb05b6ad0d4186bbb39732af6550ccf594bc3a575a99af6b395a0c4e
BLAKE2b-256 checksum
How to use checksums
c604b7e06ea1742296414d46a9e37e5425910b10f8446a0c62db5b587c8be42d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.15

Release files / robotframework_timetravel-0.1.0-py3-none-any.whl

Download URL robotframework_timetravel-0.1.0-py3-none-any.whl
Size 22.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9fc1a0d19aabf41047c3e26bfa5c12120102d3cdafec6743c03bb6c0432a4292
BLAKE2b-256 checksum
How to use checksums
2ac60a4867b17877f2f715b282c073ed8cb4148bc16ed27548d44c32d4842e6f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.15

Security for robotframework-timetravel 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page