Skip to main content

A comparable string / regex object for flexible string comparisons.

Project description

comparable_pattern

A comparable string / regex object for flexible string comparisons.

Useful for making unit tests less brittle without extensive mocking of things like timestamps and hashes which maybe change from one run to another.

Examples

>>> p = compile("foo")
>>> c = ComparablePattern(p)
>>> p == "foo"
False
>>> c == "foo"
True
>>> c == "bar"
False

>>> c = "foo" + ComparablePattern(compile("\d{3}"))
>>> c == "foo"
False
>>> c == "123"
False
>>> c == "foo123"
True

>>> c = ComparablePattern(compile("\d{3}")) + "bar"
>>> c == "bar"
False
>>> c == "123"
False
>>> c == "123bar"
True

>>> c = ComparablePattern(compile("\d{3}")) + ComparablePattern(compile("\w{3}"))
>>> c == "123"
False
>>> c == "abc"
False
>>> c == "123abc"
True

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

comparable_pattern-0.0.4.tar.gz (5.8 kB view details)

Uploaded Source

Built Distribution

comparable_pattern-0.0.4-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

Details for the file comparable_pattern-0.0.4.tar.gz.

File metadata

  • Download URL: comparable_pattern-0.0.4.tar.gz
  • Upload date:
  • Size: 5.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for comparable_pattern-0.0.4.tar.gz
Algorithm Hash digest
SHA256 36caea8c4cc89a3a6cf023836bc120ef0ab69713face58917077c5a0cb2a2ebc
MD5 5cad1ff87ddd1ca90bf3ac63ca034b74
BLAKE2b-256 52dcfdc137781d6882ebb086c69c31de68161a53ad8bacc9e188c497a247ea5a

See more details on using hashes here.

File details

Details for the file comparable_pattern-0.0.4-py3-none-any.whl.

File metadata

File hashes

Hashes for comparable_pattern-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 0e88c788d1f932ed65090eaa35ad7561fd76dd3e292a9b153f329f7eda9e218a
MD5 aafabe5159abc4ab4532a7f67da5043d
BLAKE2b-256 20799d1f6561bb2b9755a8485d75cb39b9be37f088d1e83351deabc209d4fbe6

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