PyHamcrest is a framework for writing matcher objects, allowing you to declaratively define "match" rules. There are a number of situations where matchers are invaluable, such as UI validation, or data filtering, but it is in the area of writing flexible tests that matchers are most commonly used. This tutorial shows you how to use PyHamcrest for unit testing.
When writing tests it is sometimes difficult to get the balance right between overspecifying the test (and making it brittle to changes), and not specifying enough (making the test less valuable since it continues to pass even when the thing being tested is broken). Having a tool that allows you to pick out precisely the aspect under test and describe the values it should have, to a controlled level of precision, helps greatly in writing tests that are "just right." Such tests fail when the behavior of the aspect under test deviates from the expected behavior, yet continue to pass when minor, unrelated changes to the behaviour are made.
9 months, 3 weeks ago passed
.. image:: http://readthedocs.org/projects/pyhamcrest/badge/?version=release-1.8 :target: https://pyhamcrest.readthedocs.io/en/release-1.8/?badge=release-1.8 :alt: Documentation Status
<a href='https://pyhamcrest.readthedocs.io/en/release-1.8/?badge=release-1.8'> <img src='http://readthedocs.org/projects/pyhamcrest/badge/?version=release-1.8' alt='Documentation Status' /> </a>
Project Privacy Level