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
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
Close
Hashes for comparable_pattern-0.0.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5c0d087f8ec1dfc2e9f5a6ef6017c2ded3e2e1c74a62b63b0097701ce91f1e87 |
|
MD5 | 321a4009a00de64fe7b02112aceb185a |
|
BLAKE2b-256 | 5cd952de26005ba6f914cb991ad6beb86a5daca5e9e385efcc881c5497087529 |