Utilities to aid in testing for equality.
Project description
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file equality-0.1.1.tar.gz.
File metadata
- Download URL: equality-0.1.1.tar.gz
- Upload date:
- Size: 4.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4342928f394b538eb633a691a8ef6a1fcfd2d26ca33c220ec481b767a5bb9f41
|
|
| MD5 |
f47ee66758395aab77bc73439e0c4802
|
|
| BLAKE2b-256 |
37b43e3b51e5759969073b9aab95fc079cff04e6d4271ff352fe93d5957fb0a6
|
File details
Details for the file equality-0.1.1-py2.py3-none-any.whl.
File metadata
- Download URL: equality-0.1.1-py2.py3-none-any.whl
- Upload date:
- Size: 5.0 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1f820eb75b18847286cdd6c5c5582481e67110d1a21465a558fcc165808a8c02
|
|
| MD5 |
b70aa295293ad26f93368c357cd1d6cf
|
|
| BLAKE2b-256 |
227faea0fdbceddb55c4eef88d92769e108bce001a7bbeb7134b7dfa6ce2cc23
|