Metadata-Version: 2.0
Name: verify
Version: 0.1.0
Summary: A painless assertion library for Python.
Home-page: https://github.com/dgilland/verify
Author: Derrick Gilland
Author-email: dgilland@gmail.com
License: MIT License
Keywords: test testing assertion validation unittest unittesting
Platform: UNKNOWN
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: License :: OSI Approved :: MIT License
Classifier: Topic :: Software Development :: Libraries
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Software Development :: Testing
Classifier: Topic :: Utilities
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 2
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.3
Classifier: Programming Language :: Python :: 3.4
Requires-Dist: pydash (>=3.2.2)

******
verify
******

|version| |travis| |coveralls| |license|

Verify is a painless assertion library for Python.


Links
=====

- Project: https://github.com/dgilland/verify
- Documentation: http://verify.readthedocs.org
- PyPI: https://pypi.python.org/pypi/verify/
- TravisCI: https://travis-ci.org/dgilland/verify


Quickstart
==========

Install using pip:


::

    pip install verify


Verify some value using multiple assertions:


.. code-block:: python

    from verify import expect, Not, Truthy, Falsy, Less, Greater

    expect(5 * 5,
           Truthy(),
           Not(Falsy),
           Greater(15),
           Less(30))


Verify using your own assert functions:


.. code-block:: python

    def is_just_right(value):
        assert value != 'too cold' and value != 'too hot', 'Not just right!'

    # Passes
    expect(25, is_just_right)

    # Fails
    try:
        expect(31, is_just_right)
    except AssertionError:
        raise

Or your own predicate functions:


.. code-block:: python

    def is_awesome(value):
        return 'awesome' in value

    def is_more_awesome(value):
        return value > 'awesome'

    expect('so awesome', is_awesome, is_more_awesome)


But you don't have to use ``expect`` since the ``verify`` assertions can be used on their own:


.. code-block:: python

    import verify

    # These would pass.
    verify.Truthy(1)
    verify.Equal(2, 2)
    verify.Greater(3, 2)

    # These would fail with an AssertionError
    verify.Truthy(0)
    verify.Equal(2, 3)
    verify.Greater(2, 3)


And if you'd prefer to see ``assert`` being used, all ``verify`` assertions will return ``True`` if no ``AssertionError`` is raised:


.. code-block:: python

    assert Truthy(1)
    assert Except(1, Truthy(), Number())


Validators
==========

All of the validators in ``verify`` are callables that can be used in two contexts:

1. By themselves as in ``Equal(a, b)`` which will raise an ``AssertionError`` if false.
2. In combination with ``except`` as in ``expect(a, Equal(b))`` which could also raise an ``AssertionError``.

The available validators are:

==================   ===========
Validator            Description
==================   ===========
``Not``              Assert that a callable doesn't raise an ``AssertionError``.
``Predicate``        Assert that ``predicate(a)`` (``predicate()`` should return a boolean).
``Equal``            Assert that ``a == b``.
``Greater``          Assert that ``a > b``.
``GreaterEqual``     Assert that ``a >= b``.
``Less``             Assert that ``a < b``.
``LessEqual``        Assert that ``a <= b``.
``Is``               Assert that ``a is b``.
``IsTrue``           Assert that ``a is True``.
``IsFalse``          Assert that ``a is False``.
``IsNone``           Assert that ``a is None``.
``In``               Assert that ``a in b``.
``InstanceOf``       Assert that ``isinstance(a, b)``.
``Truthy``           Assert that ``bool(a)``.
``Falsy``            Assert that ``not bool(a)``.
``Boolean``          Assert that ``isinstance(a, bool)``.
``String``           Assert that ``isinstance(a, (str, unicode))``.
``Dict``             Assert that ``isinstance(a, dict)``.
``List``             Assert that ``isinstance(a, list)``.
``Tuple``            Assert that ``isinstance(a, tuple)``.
``Int``              Assert that ``isinstance(a, int)``.
``Float``            Assert that ``isinstance(a, float)``.
``Number``           Assert that ``isinstance(a, (int, float, Decimal, long))``.
``NaN``              Assert that ``not isinstance(a, (int, float, Decimal, long))``.
``Date``             TODO
``Datetime``         TODO
``Negative``         TODO
``Positive``         TODO
``Odd``              TODO
``Even``             TODO
``Monotone``         TODO
``Increasing``       TODO
``Decreasing``       TODO
``Contains``         TODO
``ContainsOnly``     TODO
``Any``              TODO
``All``              TODO
``Match``            TODO
``Range``            TODO
``Length``           TODO
``DatetimeString``   TODO
``Unique``           TODO
``ExactSequence``    TODO
``Subset``           TODO
``Superset``         TODO
==================   ===========


For more details, please see the full documentation at http://verify.readthedocs.org.


.. |version| image:: http://img.shields.io/pypi/v/verify.svg?style=flat-square
    :target: https://pypi.python.org/pypi/verify/

.. |travis| image:: http://img.shields.io/travis/dgilland/verify/master.svg?style=flat-square
    :target: https://travis-ci.org/dgilland/verify

.. |coveralls| image:: http://img.shields.io/coveralls/dgilland/verify/master.svg?style=flat-square
    :target: https://coveralls.io/r/dgilland/verify

.. |license| image:: http://img.shields.io/pypi/l/verify.svg?style=flat-square
    :target: https://pypi.python.org/pypi/verify/


