Skip to main content

Utilities to aid in testing for equality.

Project description

Travis Test Status

This package is pre-alpha. The API may change.

When comparing structures like this dict:

assert actual == {
    'id': 123,
    'created': "2017-11-10T23:59:58",
    'field1': 1,

This fails because ‘id’ and ‘created’ are different every test run. Fix this using:

assert actual == {
    'id': AnyInt(),
    'created': AnyTimestamp(, seconds=3),
    'field1': 1,

AnyInt compares equal to any integer. Timestamp compares equal to string timestamps that are within the given number of seconds.


Python 3.6 and 2.7.

Known Problems

If timestamps are generated locally, in-process, then it’s easier to patch out But if this is an end-to-end test that hits other services, that might not be an option. That’s when I find AnyTimestamp useful.

This is all hot off the press, so is doubtless full of mistakes.


This doubtless duplicates better work elsewhere. In particular the package ‘equals’ looks very nice, but it’s missing the central feature of ‘equality’, approximate comparison of string timestamps.


Users’ downloads & documentation:
Contributors’ souce & issues:
Author: Jonathan Hartley, email: tartley at domain, Twitter: @tartley.

Project details

Download files

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

Files for equality, version 0.1.1
Filename, size File type Python version Upload date Hashes
Filename, size equality-0.1.1-py2.py3-none-any.whl (5.0 kB) File type Wheel Python version py2.py3 Upload date Hashes View
Filename, size equality-0.1.1.tar.gz (4.6 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page