Skip to main content

.. image:: https://travis-ci.org/tartley/equality.svg?branch=master :target: https://travis-ci.org/tartley/equality

Project description

Utilities to aid in testing for equality.

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(datetime.now(), seconds=3),
    'field1': 1,
    ...
}

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

Compatibility

Python 3.6 and 2.7.

Known Problems

If timestamps are generated locally, in-process, then it’s easier to patch out datetime.now(). 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.

Alternatives

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.

Contact

For users:

Downloads & documentation: http://pypi.python.org/pypi/equality/

For contributors:

Souce code & issues: https://github.com/tartley/equality/

Contact the author:

Jonathan Hartley, email: tartley at domain tartley.com, 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.

Source Distribution

equality-0.0.8.tar.gz (4.7 kB view details)

Uploaded Source

Built Distribution

equality-0.0.8-py2.py3-none-any.whl (5.1 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file equality-0.0.8.tar.gz.

File metadata

  • Download URL: equality-0.0.8.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for equality-0.0.8.tar.gz
Algorithm Hash digest
SHA256 03a3e48c600e21c9b3d7dae60bf9c63002bd7af1e4487e98e87cac976339996b
MD5 c918eb89a94fae87a53ba839e70f8842
BLAKE2b-256 ce805e7e594efb8a84247aea02de52e1072e0c59b694307c9141d996071d8e0b

See more details on using hashes here.

File details

Details for the file equality-0.0.8-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for equality-0.0.8-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 3197c0f8c4899cba26e998805a3c6e9ecbc43075ca14c9d558d35c30a415de32
MD5 0c455e63fbcca25f709008ccd91cc94e
BLAKE2b-256 7b996c228891f0b5faf767226875ba681e630d5c705680ffa2058eed221336b0

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page