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.

Examples:

from matchmaker import matcher

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

@matcher
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:

AssertionError:
Expected: Is even
     but: was <3>

AssertionError:
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.

Source Distribution

matchmaker-0.1.2.tar.gz (2.1 kB view details)

Uploaded Source

File details

Details for the file matchmaker-0.1.2.tar.gz.

File metadata

  • Download URL: matchmaker-0.1.2.tar.gz
  • Upload date:
  • Size: 2.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for matchmaker-0.1.2.tar.gz
Algorithm Hash digest
SHA256 89d5834be308d11e83744ba144f456ddaeecd3717706344d7ea2f1ab34699830
MD5 9273b2f973a2712e72b92919384e3d1a
BLAKE2b-256 6a45cef8bbac96ae59f54c76f5db7d7f827b1196ee6edd1cbb915796878c5cb2

See more details on using hashes here.

Supported by

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