Skip to main content

Easy creation of hamcrest matchers

Project description

Decorators that simplify the creation of Hamcrest matchers.

From a function (with an optional appropriate docstring), create hamcrest matchers with minimum extra coding.

The sources can be found in GitHub.


from matchmaker import matcher

def is_even(item):
    return item % 2 == 0

def ends_like(item, data, length=3):
    "String whose last {1} chars match those for '{0}'"
    return item.endswith(data[-length:])

You can then use these in your tests as:

assert_that(number, is_even())
assert_that(word, ends_like(other_word, 4))

Errors will display as:

Expected: Is even
     but: was <3>

Expected: String whose last 4 chars match those for 'cello'
     but: was 'hullo'

Project details

Download files

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

Filename, size & hash SHA256 hash help File type Python version Upload date
matchmaker-0.1.3-py2-none-any.whl (3.9 kB) Copy SHA256 hash SHA256 Wheel 2.7
matchmaker-0.1.3.tar.gz (2.1 kB) Copy SHA256 hash SHA256 Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page