



  

verify 1.1.1 documentation

 [verify](index.html#document-index) 

 stable

 

* [Installation](index.html#document-install)

* [API Reference](index.html#document-api)

* [License](index.html#document-license)

* [Versioning](index.html#document-versioning)

* [Changelog](index.html#document-changelog)

* [Authors](index.html#document-authors)

* [How to Contribute](index.html#document-contributing)

[verify](index.html#document-index)

* [Docs](index.html#document-index) »

* verify 1.1.1 documentation

* [Edit on GitHub](https://github.com/dgilland/verify/blob/c4331becf7a6b812fe50bcf19dfe4fe155481694/docs/index.rst)

---

verify[¶](#verify "Permalink to this headline")

===============================================

[![version](https://img.shields.io/pypi/v/verify.svg?style=flat-square)](https://pypi.python.org/pypi/verify/) [![travis](https://img.shields.io/travis/dgilland/verify/master.svg?style=flat-square)](https://travis-ci.org/dgilland/verify) [![coveralls](https://img.shields.io/coveralls/dgilland/verify/master.svg?style=flat-square)](https://coveralls.io/r/dgilland/verify) [![license](https://img.shields.io/pypi/l/verify.svg?style=flat-square)](https://pypi.python.org/pypi/verify/)

Verify is a painless assertion library for Python.

Links[¶](#links "Permalink to this headline")

---------------------------------------------

* 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[¶](#quickstart "Permalink to this headline")

-------------------------------------------------------

Install using pip:

```

pip install verify

```

Verify some value using multiple assertions:

```

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:

```

def is\_just\_right(value):

    assert value == 'just right', 'Not just right!'

# Passes

expect('just right', is\_just\_right)

# Fails

try:

    expect('too cold', is\_just\_right)

except AssertionError:

    raise

```

**NOTE:** The assert function should return a truthy value, otherwise, `expect` will treat the falsy return from the function as an indication that it failed and subsequently raise it’s own `AssertionError`.

Verify using your own predicate functions:

```

def is\_awesome(value):

    return 'awesome' in value

def is\_more\_awesome(value):

    return value > 'awesome'

expect('so awesome', is\_awesome, is\_more\_awesome)

```

Verify using chaining syntax:

```

expect(1).Truthy().Number().NotBoolean().Not(is\_awesome)

```

Verify without `expect` since the `verify` assertions can be used on their own:

```

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)

```

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

```

assert Truthy(1)

assert expect(1, Truthy(), Number())

```

Multiple Syntax Styles[¶](#multiple-syntax-styles "Permalink to this headline")

-------------------------------------------------------------------------------

There are several syntax styles available to help construct more natural sounding assertion chains.

### Expect...To Be[¶](#expect-to-be "Permalink to this headline")

Use `expect` with the `to\_be` aliases. All Pascal case assertions have `to\_be\_\*` and `to\_not\_be\_\*` prefixes (with a few expections).

```

expect(something).to\_be\_int().to\_be\_less\_or\_equal(5).to\_be\_greater\_or\_equal(1)

expect(something\_else).to\_not\_be\_float().to\_be\_number()

```

### Ensure...Is[¶](#ensure-is "Permalink to this headline")

Use `ensure` with `is` aliases. All Pascal case assertions have `is\_\*` and `is\_not\_\*` prefixes (with a few expections).

```

ensure(something).is\_int().is\_less\_or\_equal(5).is\_greater\_or\_equal(1)

ensure(something\_else).is\_not\_float().is\_number()

```

### Classical[¶](#classical "Permalink to this headline")

Use `expect` or `ensure` with the Pascal case assertions.

```

ensure(something).Int().LessOrEqual(5).GreaterOrEqual(1)

expect(something\_else).Float().Number()

```

**NOTE:** While it’s suggested to not mix styles, each of the assertion syntaxes are available with both `expect` and `ensure`. So you can call `expect(..).is\_int()` as well as `ensure(..).to\_be\_int()`.

### Naming Convention Exceptions[¶](#naming-convention-exceptions "Permalink to this headline")

As mentioned above, there are some assertions that have nonstandard aliases:

* `Not`: `not\_`, `does\_not`, `to\_fail`, and `fails`

* `Predicate`: `does`, `to\_pass`, and `passes`

* `All`: `all\_`, `does\_all`, and `passes\_all`

* `NotAll`: `not\_all`, `does\_not\_all`, and `fails\_all`

* `Any`: `any\_`, `does\_any`, and `passes\_any`

* `NotAny`: `not\_any`, `does\_not\_any`, and `fails\_any`

* `Match`: `to\_match`, `is\_match` and `matches`

* `NotMatch`: `to\_not\_match`, `is\_not\_match` and `does\_not\_match`

* `Is`: `to\_be` and `is\_`

* `Contains`: `to\_contain` and `contains`

* `NotContains`: `to\_not\_contain` and `does\_not\_contain`

* `ContainsOnly`: `to\_contain\_only` and `contains\_only`

* `NotContainsOnly`: `to\_not\_contain\_only` and `does\_not\_contain\_only`

* `Length`: `to\_have\_length` and `has\_length`

* `NotLength`: `to\_not\_have\_length` and `does\_not\_have\_length`

Validators[¶](#validators "Permalink to this headline")

-------------------------------------------------------

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 `expect` as in `expect(a, Equal(b))` which could also raise an `AssertionError`.

The available validators are:

| Validator | Description |

| --- | --- |

| `Truthy` | Assert that `bool(a)`. |

| `Falsy` | Assert that `not bool(a)`. |

| `Not` | Assert that a callable doesn’t raise an `AssertionError`. |

| `Predicate` | Assert that `predicate(a)`. |

| `All` | Assert that all of the list of predicates evaluate `a` as truthy. |

| `NotAll` | Assert `not All`. |

| `Any` | Assert that any of the list of predicates evaluate `a` as truthy. |

| `NotAny` | Assert `not Any`. |

| `Equal` | Assert that `a == b`. |

| `NotEqual` | Assert `not Equal`. |

| `Match` | Assert that `a` matches regular expression `b`. |

| `NotMatch` | Assert `not Match`. |

| `Is` | Assert that `a is b`. |

| `IsNot` | Assert `not Is`. |

| `IsTrue` | Assert that `a is True`. |

| `IsNotTrue` | Assert `not IsTrue`. |

| `IsFalse` | Assert that `a is False`. |

| `IsNotFalse` | Assert `not IsFalse`. |

| `IsNone` | Assert that `a is None`. |

| `IsNotNone` | Assert `not IsNone`. |

| `Type` | Assert that `isinstance(a, b)`. |

| `NotType` | Assert `not Type`. |

| `Boolean` | Assert that `isinstance(a, bool)`. |

| `NotBoolean` | Assert `not Boolean`. |

| `String` | Assert that `isinstance(a, (str, unicode))`. |

| `NotString` | Assert `not String`. |

| `Dict` | Assert that `isinstance(a, dict)`. |

| `NotDict` | Assert `not Dict`. |

| `List` | Assert that `isinstance(a, list)`. |

| `NotList` | Assert `not List`. |

| `Tuple` | Assert that `isinstance(a, tuple)`. |

| `NotTuple` | Assert `not Tuple`. |

| `Date` | Assert that `isinstance(a, datetime.date)`. |

| `NotDate` | Assert `not Date`. |

| `DateString` | Assert that `a` matches the datetime format string `b`. |

| `NotDateString` | Assert `not DateString`. |

| `Int` | Assert that `isinstance(a, int)`. |

| `NotInt` | Assert `not Int`. |

| `Float` | Assert that `isinstance(a, float)`. |

| `NotFloat` | Assert `not Float`. |

| `Number` | Assert that `isinstance(a, (int, float, Decimal, long))`. |

| `NotNumber` | Assert `not Number`. |

| `In` | Assert that `a in b`. |

| `NotIn` | Assert `not In`. |

| `Contains` | Assert that `b in a`. |

| `NotContains` | Assert `not Contains`. |

| `ContainsOnly` | Assert that values from `b` are the only ones contained in `a`. |

| `NotContainsOnly` | Assert `not ContainsOnly`. |

| `Subset` | Assert that `a` is a subset of `b`. |

| `NotSubset` | Assert `not Subset`. |

| `Superset` | Assert that `a` is a superset of `b`. |

| `NotSuperset` | Assert `not Superset`. |

| `Unique` | Assert that `a` contains unique items. |

| `NotUnique` | Assert `not Unique`. |

| `Length` | Assert that `b <= len(a) <= c`. |

| `NotLength` | Assert that `not Length`. |

| `Greater`/`GreaterThan` | Assert that `a > b`. |

| `GreaterEqual`/`GreaterOrEqual` | Assert that `a >= b`. |

| `Less`/`LessThan` | Assert that `a < b`. |

| `LessEqual`/`LessOrEqual` | Assert that `a <= b`. |

| `Between` | Assert that `b <= a <= c`. |

| `NotBetween` | Assert `not Between`. |

| `Positive` | Assert that `a > 0`. |

| `Negative` | Assert that `a < 0`. |

| `Even` | Assert that `a % 2 == 0`. |

| `Odd` | Assert that `a % 2 != 1`. |

| `Monotone` | Assert that `a` is monotonic with respect to `b()`. |

| `Increasing` | Assert that `a` is monotonically increasing. |

| `StrictlyIncreasing` | Assert that `a` is strictly increasing. |

| `Decreasing` | Assert that `a` is monotonically decreasing. |

| `StrictlyDecreasing` | Assert that `a` is strictly decreasing. |

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

Guide[¶](#guide "Permalink to this headline")

---------------------------------------------

### Installation[¶](#installation "Permalink to this headline")

Verify requires Python >= 2.7 or >= 3.3.

To install from [PyPI](https://pypi.python.org/pypi/verify):

```

pip install verify

```

### API Reference[¶](#api-reference "Permalink to this headline")

The verify module is composed of various assertion callables (in this case,

callable classes) that can be called in two contexts:

1. By themselves as in `Equal(a, b)` which will raise an `AssertionError`

if `a` does not equal `b`.

2. In combination with `expect()` as in `expect(a, Equal(b))` which

could also raise an `AssertionError`.

Thus, for all assertion classes below, the value argument defaults to

`NotSet` which is a custom singleton to indicate that nothing was passed in

for value. Whether value is set or `NotSet` is used to indicate which

context the assertion class is being used. Whenever value is set, the

comparable is swapped with value (internally inside the class’ `\_\_init\_\_`

method). This allows the assertion to be used in the two contexts above.

This module’s main focus is on testing, which is why all assertions raise an

`AssertionError` on failure. Therefore, all assertion classes function

similarly:

* If the evaluation of value with comparable returns `False`, then an

`AssertionError` is raised with a custom message.

* If the evaluation of value with comparable returns `True` and the class

was only created (e.g. `Equal(a, b)`), then nothing is raised or returned

(obviously, since all we did was create a class instance).

* If the evaluation of value with comparable returns `True` and the class

was called (e.g. `expect(a, Equal(b))` or `Equal(b)(a)`), then `True`

is returned from the class call.

There are two general types of assertions within this module:

1. Assertions that evaulate a single object: value. Referred to here as a

plain assertion.

2. Assertions that evaulate two objects: value and comparable. Referred to

here as a comparator assertion.

When using plain assertions with `expect()`, you can pass the bare

assertion or initialize it.

```

>>> expect(True, Truthy)

<expect(True)>

>>> expect(True, Truthy())

<expect(True)>

```

When using any of the assertions, inserting `assert` in front is optional as

each assertion will raise if the evaluation is false. However, having that

`assert` in front may be aesthetically appealing to you, but keep in mind

that any assert message included will not be shown since the assertion error

will occur within the class itself and raised with it’s own custom error

message.

```

>>> Truthy(True)

<Truthy()>

>>> assert Truthy(True)

```

```

# Both of these would raise an assertion error.

>>> Falsy(True)

Traceback (most recent call last):

...

AssertionError: True is not falsy

>>> assert Falsy(True)

Traceback (most recent call last):

...

AssertionError: True is not falsy

# But assert messages will not make it to the traceback.

>>> assert Falsy(True), 'this message will not be shown'

Traceback (most recent call last):

...

AssertionError: True is not falsy

```

#### Assertion Runner[¶](#assertion-runner "Permalink to this headline")

The [`expect`](#verify.runners.expect "verify.runners.expect") class is basically an assertion runner that takes an input value and passes it through any number of assertions or predicate functions. If all assertions pass **and** return truthy, then all is well and `True` is returned. Otherwise, either one of the assertion functions will raise an `AssertionError` or no exceptiosn were raised but at least one of the functions returned a non-truthy value which means that `expect()` will return `False`.

The [`expect`](#verify.runners.expect "verify.runners.expect") has alias in the same module under name of `ensure`, so

you can use both of these names according to your needs.

*class* `verify.runners.``expect`(*value*, *\*assertions*)[[source]](_modules/verify/runners.html#expect)[¶](#verify.runners.expect "Permalink to this definition")

Pass value through a set of assertable functions.

There are two styles for invoking `expect`:

1. Pass value and all assertions as arguments to the `\_\_init\_\_`

method of `expect`.

2. Pass value to the `\_\_init\_\_` method of `expect` and invoke

assertions via method chaining.

Examples

Passing value and assertions to `expect.\_\_init\_\_`:

```

>>> from verify import *

>>> expect(5, Truthy(), Greater(4))

<expect(5)>

>>> expect(5, Falsy())

Traceback (most recent call last):

...

AssertionError...

```

Using method chaining:

```

>>> expect(5).Truthy().Greater(4)

<expect(5)>

>>> expect(5).Falsy()

Traceback (most recent call last):

...

AssertionError...

```

| Parameters: | * **value** (*mixed*) – Value to test.

* **\*assertions** (*callable, optional*) – Callable objects that accept value

as its first argument. It’s expected that these callables assert

something.

 |

| Returns: | Allows for method assertion chaining. |

| Return type: | self |

| Raises: | `AssertionError` –

If the evaluation of all assertions returns `False`. |

Aliases:

* `ensure`

New in version 0.0.1.

Changed in version 0.1.0: * Rename from `Expect` to `expect` and change implementation from a

class to a function.

* Passed in value is no longer called if it’s a callable.

* Return `True` if all assertions pass.

Changed in version 0.6.0: * Re-implement as class.

* Support method chaining of assertion classes.

* Wrap assertions that are not derived from Assertion in

[`Predicate`](#verify.logic.Predicate "verify.logic.Predicate") for consistent behavior from external assertion

functions.

`__getattr__`(*attr*)[[source]](_modules/verify/runners.html#expect.__getattr__)[¶](#verify.runners.expect.__getattr__ "Permalink to this definition")

Invoke assertions via attribute access. All [`verify`](#module-verify "verify") assertions

are available.

#### Assertions[¶](#assertions "Permalink to this headline")

For all assertion classes, the value argument is optional, but when provided the assertion will be evaluated immediately. When passing both the value and comparable arguments, be sure that value comes first even though comparable is listed as the first argument. Internally, when both variables are passed in, value and comparable are swapped in order to support late evaulation, i.e., all of the following are equivalent ways to assert validity:

```

>>> Less(5, 10)

<Less()>

>>> Less(10)(5)

True

>>> expect(5, Less(10))

<expect(5)>

>>> Truthy(5)

<Truthy()>

>>> Truthy()(5)

True

>>> expect(5, Truthy())

<expect(5)>

```

Below are the various assertion classes that can be used for validation.

##### Base Classes[¶](#module-verify.base "Permalink to this headline")

Base classes and mixins.

*class* `verify.base.``Assertion`(*value=NotSet*, *\*\*opts*)[[source]](_modules/verify/base.html#Assertion)[¶](#verify.base.Assertion "Permalink to this definition")

Base class for assertions.

If value **is not** provided, then assertion isn’t executed. This style

of usage is used in conjuction with [`expect`](#verify.runners.expect "verify.runners.expect").

If value **is** provided, then assertion is executed immediately. This

style of usage is used when making assertions using only the class and not

an assertion runner like [`expect`](#verify.runners.expect "verify.runners.expect").

| Keyword Arguments: |

| --- |

|  | **msg** (*str, optional*) –

Override assert message to use when performing

assertion. |

`__call__`(*\*args*, *\*\*opts*)[[source]](_modules/verify/base.html#Assertion.__call__)[¶](#verify.base.Assertion.__call__ "Permalink to this definition")

Execute validation.

| Keyword Arguments: |

| --- |

|  | **msg** (*str, optional*) –

Override assert message to use when performing

assertion. |

| Returns: | `True` if comparison passes, otherwise, an

`AssertionError` is raised. |

| Return type: | bool |

| Raises: | `AssertionError` –

If comparison returns `False`. |

`format_msg`(*\*args*, *\*\*kargs*)[[source]](_modules/verify/base.html#Assertion.format_msg)[¶](#verify.base.Assertion.format_msg "Permalink to this definition")

Return formatted assert message. This is used to generate the assert

message during [`\_\_call\_\_()`](#verify.base.Assertion.__call__ "verify.base.Assertion.__call__"). If no `msg` keyword argument is

provided, then [`reason`](#verify.base.Assertion.reason "verify.base.Assertion.reason") will be used as the format string. By

default, passed in `args` and `kargs` along with the classes

`\_\_dict\_\_` dictionary are given to the format string. In all cases,

`arg[0]` will be the value that is being validated.

`op` *= None*[¶](#verify.base.Assertion.op "Permalink to this definition")

Operation to perform to determine whether value is valid. **This must

be set in subclass**.

`reason` *= ''*[¶](#verify.base.Assertion.reason "Permalink to this definition")

Default format string used for assert message.

*class* `verify.base.``Comparator`(*comparable*, *value=NotSet*, *\*\*opts*)[[source]](_modules/verify/base.html#Comparator)[¶](#verify.base.Comparator "Permalink to this definition")

Base class for assertions that compare two values.

*class* `verify.base.``Negate`[[source]](_modules/verify/base.html#Negate)[¶](#verify.base.Negate "Permalink to this definition")

Mixin class that negates the results of `compare()` from the parent

class.

`verify.base.``NotSet` *= NotSet*[¶](#verify.base.NotSet "Permalink to this definition")

Singleton to indicate that a keyword argument was not provided.

`verify.base.``is_assertion`(*obj*)[[source]](_modules/verify/base.html#is_assertion)[¶](#verify.base.is_assertion "Permalink to this definition")

Return whether obj is either an instance or subclass of

[`Assertion`](#verify.base.Assertion "verify.base.Assertion").

##### Logic[¶](#module-verify.logic "Permalink to this headline")

Assertions related to logical operations.

*class* `verify.logic.``Truthy`(*value=NotSet*, *\*\*opts*)[[source]](_modules/verify/logic.html#Truthy)[¶](#verify.logic.Truthy "Permalink to this definition")

Asserts that value is truthy.

Aliases:

* `to\_be\_truthy`

* `is\_truthy`

New in version 0.0.1.

`reason` *= '{0} is not truthy'*[¶](#verify.logic.Truthy.reason "Permalink to this definition")

*class* `verify.logic.``Falsy`(*value=NotSet*, *\*\*opts*)[[source]](_modules/verify/logic.html#Falsy)[¶](#verify.logic.Falsy "Permalink to this definition")

Asserts that value is falsy.

Aliases:

* `to\_be\_falsy`

* `is\_falsy`

New in version 0.0.1.

`reason` *= '{0} is not falsy'*[¶](#verify.logic.Falsy.reason "Permalink to this definition")

*class* `verify.logic.``Not`(*comparable*, *value=NotSet*, *\*\*opts*)[[source]](_modules/verify/logic.html#Not)[¶](#verify.logic.Not "Permalink to this definition")

Asserts that comparable doesn’t raise an `AssertionError`. Can be

used to create “opposite” comparators.

Examples

```

>>> from verify import \*

>>> expect(5, Not(In([1, 2, 3])))

<expect(5)>

>>> Not(5, In([1, 2, 3]))

<Not()>

>>> Not(In([1, 2, 3]))(5)

True

```

Aliases:

* `not\_`

* `does\_not`

* `to\_fail`

* `fails`

New in version 0.0.1.

`reason` *= 'The negation of {comparable} should not be true when evaluated with {0}'*[¶](#verify.logic.Not.reason "Permalink to this definition")

*class* `verify.logic.``Predicate`(*comparable*, *value=NotSet*, *\*\*opts*)[[source]](_modules/verify/logic.html#Predicate)[¶](#verify.logic.Predicate "Permalink to this definition")

Asserts that value evaluated by the predicate comparable is

`True`.

Aliases:

* `does`

* `to\_pass`

* `passes`

New in version 0.1.0.

Changed in version 0.6.0: Catch `AssertionError` thrown by comparable and return `False`

as comparison value instead.

`reason` *= 'The evaluation of {0} using {comparable} is false'*[¶](#verify.logic.Predicate.reason "Permalink to this definition")

*class* `verify.logic.``All`(*comparable*, *value=NotSet*, *\*\*opts*)[[source]](_modules/verify/logic.html#All)[¶](#verify.logic.All "Permalink to this definition")

Asserts that value evaluates as truthy for **all** predicates in

comparable.

Aliases:

* `all\_`

* `does\_all`

* `passes\_all`

New in version 0.2.0.

`reason` *= '{0} is not true for all {comparable}'*[¶](#verify.logic.All.reason "Permalink to this definition")

*class* `verify.logic.``NotAll`(*comparable*, *value=NotSet*, *\*\*opts*)[[source]](_modules/verify/logic.html#NotAll)[¶](#verify.logic.NotAll "Permalink to this definition")

Asserts that value evaluates as falsy for **all** predicates in

comparable.

Aliases:

* `to\_be\_not\_all`

* `does\_not\_all`

* `fails\_all`

New in version 0.5.0.

`reason` *= '{0} is true for all {comparable}'*[¶](#verify.logic.NotAll.reason "Permalink to this definition")

*class* `verify.logic.``Any`(*comparable*, *value=NotSet*, *\*\*opts*)[[source]](_modules/verify/logic.html#Any)[¶](#verify.logic.Any "Permalink to this definition")

Asserts that value evaluates as truthy for **any** predicates in

comparable.

Aliases:

* `any\_`

* `does\_any`

* `passes\_any`

New in version 0.2.0.

`reason` *= '{0} is not true for any {comparable}'*[¶](#verify.logic.Any.reason "Permalink to this definition")

*class* `verify.logic.``NotAny`(*comparable*, *value=NotSet*, *\*\*opts*)[[source]](_modules/verify/logic.html#NotAny)[¶](#verify.logic.NotAny "Permalink to this definition")

Asserts that value evaluates as falsy for **any** predicates in

comparable.

Aliases:

* `not\_any`

* `does\_not\_any`

* `fails\_any`

New in version 0.5.0.

`reason` *= '{0} is true for some {comparable}'*[¶](#verify.logic.NotAny.reason "Permalink to this definition")

##### Equality[¶](#module-verify.equality "Permalink to this headline")

Assertions related to equality.

*class* `verify.equality.``Equal`(*comparable*, *value=NotSet*, *\*\*opts*)[[source]](_modules/verify/equality.html#Equal)[¶](#verify.equality.Equal "Permalink to this definition")

Asserts that two values are equal.

Aliases:

* `to\_be\_equal`

* `is\_equal`

New in version 0.0.1.

`reason` *= '{0} is not equal to {comparable}'*[¶](#verify.equality.Equal.reason "Permalink to this definition")

*class* `verify.equality.``NotEqual`(*comparable*, *value=NotSet*, *\*\*opts*)[[source]](_modules/verify/equality.html#NotEqual)[¶](#verify.equality.NotEqual "Permalink to this definition")

Asserts that two values are not equal.

Aliases:

* `to\_not\_be\_equal`

* `is\_not\_equal`

New in version 0.5.0.

`reason` *= '{0} is equal to {comparable}'*[¶](#verify.equality.NotEqual.reason "Permalink to this definition")

*class* `verify.equality.``Match`(*comparable*, *value=NotSet*, *\*\*opts*)[[source]](_modules/verify/equality.html#Match)[¶](#verify.equality.Match "Permalink to this definition")

Asserts that value matches the regular expression comparable.

| Parameters: | * **value** (*mixed, optional*) – Value to compare.

* **comparable** (*str|RegExp*) – String or RegExp object used for matching.

 |

| Keyword Arguments: |

|  | **flags** (*int, optional*) –

Used when compiling regular expression when

regular expression is a string. Defaults to `0`. |

Aliases:

* `to\_match`

* `is\_match`

* `matches`

New in version 0.3.0.

`reason` *= '{0} does not match the regular expression {comparable}'*[¶](#verify.equality.Match.reason "Permalink to this definition")

*class* `verify.equality.``NotMatch`(*comparable*, *value=NotSet*, *\*\*opts*)[[source]](_modules/verify/equality.html#NotMatch)[¶](#verify.equality.NotMatch "Permalink to this definition")

Asserts that value does not match the regular expression comparable.

Aliases:

* `to\_not\_be\_match`

* `is\_not\_match`

* `not\_matches`

New in version 0.5.0.

`reason` *= '{0} matches the regular expression {comparable}'*[¶](#verify.equality.NotMatch.reason "Permalink to this definition")

*class* `verify.equality.``Is`(*comparable*, *value=NotSet*, *\*\*opts*)[[source]](_modules/verify/equality.html#Is)[¶](#verify.equality.Is "Permalink to this definition")

Asserts that value is comparable.

Aliases:

* `to\_be`

* `is\_`

New in version 0.0.1.

`reason` *= '{0} is not {comparable}'*[¶](#verify.equality.Is.reason "Permalink to this definition")

*class* `verify.equality.``IsNot`(*comparable*, *value=NotSet*, *\*\*opts*)[[source]](_modules/verify/equality.html#IsNot)[¶](#verify.equality.IsNot "Permalink to this definition")

Asserts that value is not comparable.

Aliases:

* `to\_not\_be`

* `is\_not`

New in version 0.5.0.

`reason` *= '{0} is {comparable}'*[¶](#verify.equality.IsNot.reason "Permalink to this definition")

*class* `verify.equality.``IsTrue`(*value=NotSet*, *\*\*opts*)[[source]](_modules/verify/equality.html#IsTrue)[¶](#verify.equality.IsTrue "Permalink to this definition")

Asserts that value is `True`.

Aliases:

* `to\_be\_true`

* `is\_true`

New in version 0.1.0.

`reason` *= '{0} is not True'*[¶](#verify.equality.IsTrue.reason "Permalink to this definition")

*class* `verify.equality.``IsNotTrue`(*value=NotSet*, *\*\*opts*)[[source]](_modules/verify/equality.html#IsNotTrue)[¶](#verify.equality.IsNotTrue "Permalink to this definition")

Asserts that value is not `True`.

Aliases:

* `to\_not\_be\_true`

* `is\_not\_true`

New in version 0.5.0.

`reason` *= '{0} is True'*[¶](#verify.equality.IsNotTrue.reason "Permalink to this definition")

*class* `verify.equality.``IsFalse`(*value=NotSet*, *\*\*opts*)[[source]](_modules/verify/equality.html#IsFalse)[¶](#verify.equality.IsFalse "Permalink to this definition")

Asserts that value is `False`.

Aliases:

* `to\_be\_false`

* `is\_false`

New in version 0.1.0.

`reason` *= '{0} is not False'*[¶](#verify.equality.IsFalse.reason "Permalink to this definition")

*class* `verify.equality.``IsNotFalse`(*value=NotSet*, *\*\*opts*)[[source]](_modules/verify/equality.html#IsNotFalse)[¶](#verify.equality.IsNotFalse "Permalink to this definition")

Asserts that value is not `False`.

Aliases:

* `to\_not\_be\_false`

* `is\_not\_false`

New in version 0.5.0.

`reason` *= '{0} is False'*[¶](#verify.equality.IsNotFalse.reason "Permalink to this definition")

*class* `verify.equality.``IsNotNone`(*value=NotSet*, *\*\*opts*)[[source]](_modules/verify/equality.html#IsNotNone)[¶](#verify.equality.IsNotNone "Permalink to this definition")

Asserts that value is not `None`.

Aliases:

* `to\_be\_not\_none`

* `is\_not\_none`

New in version 0.5.0.

`reason` *= '{0} is None'*[¶](#verify.equality.IsNotNone.reason "Permalink to this definition")

*class* `verify.equality.``IsNone`(*value=NotSet*, *\*\*opts*)[[source]](_modules/verify/equality.html#IsNone)[¶](#verify.equality.IsNone "Permalink to this definition")

Asserts that value is `None`.

Aliases:

* `to\_be\_none`

* `is\_none`

New in version 0.0.1.

`reason` *= '{0} is not None'*[¶](#verify.equality.IsNone.reason "Permalink to this definition")

##### Types[¶](#module-verify.types "Permalink to this headline")

Assertions related to types.

*class* `verify.types.``Type`(*comparable*, *value=NotSet*, *\*\*opts*)[[source]](_modules/verify/types.html#Type)[¶](#verify.types.Type "Permalink to this definition")

Asserts that value is an instance of comparable.

Aliases:

* `to\_be\_type`

* `is\_type`

New in version 0.0.1.

Changed in version 0.6.0: Renamed from `InstanceOf` to `Type`

`reason` *= '{0} is not an instance of {comparable}'*[¶](#verify.types.Type.reason "Permalink to this definition")

*class* `verify.types.``NotType`(*comparable*, *value=NotSet*, *\*\*opts*)[[source]](_modules/verify/types.html#NotType)[¶](#verify.types.NotType "Permalink to this definition")

Asserts that value is a not an instance of comparable.

Aliases:

* `to\_be\_not\_type`

* `is\_not\_type`

New in version 0.5.0.

Changed in version 0.6.0: Renamed from `NotInstanceOf` to `NotType`

`reason` *= '{0} is an instance of {comparable}'*[¶](#verify.types.NotType.reason "Permalink to this definition")

*class* `verify.types.``Boolean`(*value=NotSet*, *\*\*opts*)[[source]](_modules/verify/types.html#Boolean)[¶](#verify.types.Boolean "Permalink to this definition")

Asserts that value is a boolean.

Aliases:

* `to\_be\_boolean`

* `is\_boolean`

New in version 0.1.0.

`reason` *= '{0} is not a boolean'*[¶](#verify.types.Boolean.reason "Permalink to this definition")

*class* `verify.types.``NotBoolean`(*value=NotSet*, *\*\*opts*)[[source]](_modules/verify/types.html#NotBoolean)[¶](#verify.types.NotBoolean "Permalink to this definition")

Asserts that value is a not a boolean.

Aliases:

* `to\_be\_not\_boolean`

* `is\_not\_boolean`

New in version 0.5.0.

`reason` *= '{0} is a boolean'*[¶](#verify.types.NotBoolean.reason "Permalink to this definition")

*class* `verify.types.``String`(*value=NotSet*, *\*\*opts*)[[source]](_modules/verify/types.html#String)[¶](#verify.types.String "Permalink to this definition")

Asserts that value is a string (`str` or `unicode` on Python 2).

Aliases:

* `to\_be\_string`

* `is\_string`

New in version 0.1.0.

`reason` *= '{0} is not a string'*[¶](#verify.types.String.reason "Permalink to this definition")

*class* `verify.types.``NotString`(*value=NotSet*, *\*\*opts*)[[source]](_modules/verify/types.html#NotString)[¶](#verify.types.NotString "Permalink to this definition")

Asserts that value is a not a string.

Aliases:

* `to\_be\_not\_string`

* `is\_not\_string`

New in version 0.5.0.

`reason` *= '{0} is a string'*[¶](#verify.types.NotString.reason "Permalink to this definition")

*class* `verify.types.``Dict`(*value=NotSet*, *\*\*opts*)[[source]](_modules/verify/types.html#Dict)[¶](#verify.types.Dict "Permalink to this definition")

Asserts that value is a dictionary.

Aliases:

* `to\_be\_dict`

* `is\_dict`

New in version 0.1.0.

`reason` *= '{0} is not a dictionary'*[¶](#verify.types.Dict.reason "Permalink to this definition")

*class* `verify.types.``NotDict`(*value=NotSet*, *\*\*opts*)[[source]](_modules/verify/types.html#NotDict)[¶](#verify.types.NotDict "Permalink to this definition")

Asserts that value is a not a dict.

Aliases:

* `to\_be\_not\_dict`

* `is\_dict`

New in version 0.5.0.

`reason` *= '{0} is a dict'*[¶](#verify.types.NotDict.reason "Permalink to this definition")

*class* `verify.types.``List`(*value=NotSet*, *\*\*opts*)[[source]](_modules/verify/types.html#List)[¶](#verify.types.List "Permalink to this definition")

Asserts that value is a list.

Aliases:

* `to\_be\_list`

* `is\_list`

New in version 0.1.0.

`reason` *= '{0} is not a list'*[¶](#verify.types.List.reason "Permalink to this definition")

*class* `verify.types.``NotList`(*value=NotSet*, *\*\*opts*)[[source]](_modules/verify/types.html#NotList)[¶](#verify.types.NotList "Permalink to this definition")

Asserts that value is a not a list.

Aliases:

* `to\_be\_not\_list`

* `is\_not\_list`

New in version 0.5.0.

`reason` *= '{0} is a list'*[¶](#verify.types.NotList.reason "Permalink to this definition")

*class* `verify.types.``Tuple`(*value=NotSet*, *\*\*opts*)[[source]](_modules/verify/types.html#Tuple)[¶](#verify.types.Tuple "Permalink to this definition")

Asserts that value is a tuple.

Aliases:

* `to\_be\_tuple`

* `is\_tuple`

New in version 0.1.0.

`reason` *= '{0} is not a tuple'*[¶](#verify.types.Tuple.reason "Permalink to this definition")

*class* `verify.types.``NotTuple`(*value=NotSet*, *\*\*opts*)[[source]](_modules/verify/types.html#NotTuple)[¶](#verify.types.NotTuple "Permalink to this definition")

Asserts that value is a not a tuple.

Aliases:

* `to\_be\_not\_tuple`

* `is\_not\_tuple`

New in version 0.5.0.

`reason` *= '{0} is a tuple'*[¶](#verify.types.NotTuple.reason "Permalink to this definition")

*class* `verify.types.``Date`(*value=NotSet*, *\*\*opts*)[[source]](_modules/verify/types.html#Date)[¶](#verify.types.Date "Permalink to this definition")

Asserts that value is an instance of `datetime.date` or

`datetime.datetime`.

Aliases:

* `to\_be\_date`

* `is\_date`

New in version 0.3.0.

`reason` *= '{0} is not a date or datetime object'*[¶](#verify.types.Date.reason "Permalink to this definition")

*class* `verify.types.``NotDate`(*value=NotSet*, *\*\*opts*)[[source]](_modules/verify/types.html#NotDate)[¶](#verify.types.NotDate "Permalink to this definition")

Asserts that value is a not a date or datetime object.

Aliases:

* `to\_be\_not\_date`

* `is\_not\_date`

New in version 0.5.0.

`reason` *= '{0} is a date or datetime object'*[¶](#verify.types.NotDate.reason "Permalink to this definition")

*class* `verify.types.``DateString`(*comparable*, *value=NotSet*, *\*\*opts*)[[source]](_modules/verify/types.html#DateString)[¶](#verify.types.DateString "Permalink to this definition")

Asserts that value is matches the datetime format string comparable.

Aliases:

* `to\_be\_date\_string`

* `is\_date\_string`

New in version 0.3.0.

`reason` *= '{0} does not match the datetime format {comparable}'*[¶](#verify.types.DateString.reason "Permalink to this definition")

*class* `verify.types.``NotDateString`(*comparable*, *value=NotSet*, *\*\*opts*)[[source]](_modules/verify/types.html#NotDateString)[¶](#verify.types.NotDateString "Permalink to this definition")

Asserts that value does not match datetime format string comparable.

Aliases:

* `to\_be\_not\_date\_string`

* `is\_not\_date\_string`

New in version 0.5.0.

`reason` *= '{0} matches the datetime format {comparable}'*[¶](#verify.types.NotDateString.reason "Permalink to this definition")

*class* `verify.types.``Int`(*value=NotSet*, *\*\*opts*)[[source]](_modules/verify/types.html#Int)[¶](#verify.types.Int "Permalink to this definition")

Asserts that value is an integer.

Aliases:

* `to\_be\_int`

* `is\_int`

New in version 0.1.0.

`reason` *= '{0} is not an integer'*[¶](#verify.types.Int.reason "Permalink to this definition")

*class* `verify.types.``NotInt`(*value=NotSet*, *\*\*opts*)[[source]](_modules/verify/types.html#NotInt)[¶](#verify.types.NotInt "Permalink to this definition")

Asserts that value is a not an integer.

Aliases:

* `to\_be\_not\_int`

* `is\_not\_int`

New in version 0.5.0.

`reason` *= '{0} is an integer'*[¶](#verify.types.NotInt.reason "Permalink to this definition")

*class* `verify.types.``NotFloat`(*value=NotSet*, *\*\*opts*)[[source]](_modules/verify/types.html#NotFloat)[¶](#verify.types.NotFloat "Permalink to this definition")

Asserts that value is a not a float.

Aliases:

* `to\_be\_not\_float`

* `is\_not\_float`

New in version 0.5.0.

`reason` *= '{0} is a float'*[¶](#verify.types.NotFloat.reason "Permalink to this definition")

*class* `verify.types.``Float`(*value=NotSet*, *\*\*opts*)[[source]](_modules/verify/types.html#Float)[¶](#verify.types.Float "Permalink to this definition")

Asserts that value is a float.

Aliases:

* `to\_be\_float`

* `is\_float`

New in version 0.1.0.

`reason` *= '{0} is not a float'*[¶](#verify.types.Float.reason "Permalink to this definition")

*class* `verify.types.``Number`(*value=NotSet*, *\*\*opts*)[[source]](_modules/verify/types.html#Number)[¶](#verify.types.Number "Permalink to this definition")

Asserts that value is a number.

Objects considered a number are:

* `int`

* `float`

* `decimal.Decimal`

* `long (Python 2)`

Aliases:

* `to\_be\_number`

* `is\_number`

New in version 0.1.0.

`reason` *= '{0} is not a number'*[¶](#verify.types.Number.reason "Permalink to this definition")

*class* `verify.types.``NotNumber`(*value=NotSet*, *\*\*opts*)[[source]](_modules/verify/types.html#NotNumber)[¶](#verify.types.NotNumber "Permalink to this definition")

Asserts that value is a not a number.

Aliases:

* `to\_be\_not\_number`

* `is\_not\_number`

New in version 0.1.0.

Changed in version 0.5.0: Renamed from `NaN` to `NotNumber`.

`reason` *= '{0} is a number'*[¶](#verify.types.NotNumber.reason "Permalink to this definition")

##### Containers[¶](#module-verify.containers "Permalink to this headline")

Assertions related to containers/iterables.

*class* `verify.containers.``In`(*comparable*, *value=NotSet*, *\*\*opts*)[[source]](_modules/verify/containers.html#In)[¶](#verify.containers.In "Permalink to this definition")

Asserts that value is in comparable.

Aliases:

* `to\_be\_in`

* `is\_in`

New in version 0.0.1.

`reason` *= '{0} is not in {comparable}'*[¶](#verify.containers.In.reason "Permalink to this definition")

*class* `verify.containers.``NotIn`(*comparable*, *value=NotSet*, *\*\*opts*)[[source]](_modules/verify/containers.html#NotIn)[¶](#verify.containers.NotIn "Permalink to this definition")

Asserts that value is not in comparable.

Aliases:

* `to\_not\_be\_in`

* `is\_not\_in`

New in version 0.5.0.

`reason` *= '{0} is in {comparable}'*[¶](#verify.containers.NotIn.reason "Permalink to this definition")

*class* `verify.containers.``Contains`(*comparable*, *value=NotSet*, *\*\*opts*)[[source]](_modules/verify/containers.html#Contains)[¶](#verify.containers.Contains "Permalink to this definition")

Asserts that value is an iterable and contains comparable.

Aliases:

* `to\_contain`

* `contains`

New in version 0.2.0.

`reason` *= '{0} does not contain {comparable}'*[¶](#verify.containers.Contains.reason "Permalink to this definition")

*class* `verify.containers.``NotContains`(*comparable*, *value=NotSet*, *\*\*opts*)[[source]](_modules/verify/containers.html#NotContains)[¶](#verify.containers.NotContains "Permalink to this definition")

Asserts that value does not contain comparable.

Aliases:

* `to\_not\_contain`

* `does\_not\_contain`

New in version 0.5.0.

`reason` *= '{0} contains {comparable}'*[¶](#verify.containers.NotContains.reason "Permalink to this definition")

*class* `verify.containers.``ContainsOnly`(*comparable*, *value=NotSet*, *\*\*opts*)[[source]](_modules/verify/containers.html#ContainsOnly)[¶](#verify.containers.ContainsOnly "Permalink to this definition")

Asserts that value is an iterable and only contains comparable.

Aliases:

* `to\_contain\_only`

* `contains\_only`

New in version 0.2.0.

`reason` *= '{0} does not only contain values in {comparable}'*[¶](#verify.containers.ContainsOnly.reason "Permalink to this definition")

*class* `verify.containers.``NotContainsOnly`(*comparable*, *value=NotSet*, *\*\*opts*)[[source]](_modules/verify/containers.html#NotContainsOnly)[¶](#verify.containers.NotContainsOnly "Permalink to this definition")

Asserts that value does not contain only comparable.

Aliases:

* `to\_not\_contain\_only`

* `does\_not\_contain\_only`

New in version 0.5.0.

`reason` *= '{0} contains only {comparable}'*[¶](#verify.containers.NotContainsOnly.reason "Permalink to this definition")

*class* `verify.containers.``Subset`(*comparable*, *value=NotSet*, *\*\*opts*)[[source]](_modules/verify/containers.html#Subset)[¶](#verify.containers.Subset "Permalink to this definition")

Asserts that value is a subset of comparable. Comparison supports

nested `dict`, `list`, and `tuple` objects.

Aliases:

* `to\_be\_subset`

* `is\_subset`

New in version 0.3.0.

`reason` *= '{0} is not a subset of {comparable}'*[¶](#verify.containers.Subset.reason "Permalink to this definition")

*class* `verify.containers.``NotSubset`(*comparable*, *value=NotSet*, *\*\*opts*)[[source]](_modules/verify/containers.html#NotSubset)[¶](#verify.containers.NotSubset "Permalink to this definition")

Asserts that value is a not a subset of comparable.

Aliases:

* `to\_not\_be\_subset`

* `is\_not\_subset`

New in version 0.5.0.

`reason` *= '{0} is a subset of {comparable}'*[¶](#verify.containers.NotSubset.reason "Permalink to this definition")

*class* `verify.containers.``Superset`(*comparable*, *value=NotSet*, *\*\*opts*)[[source]](_modules/verify/containers.html#Superset)[¶](#verify.containers.Superset "Permalink to this definition")

Asserts that value is a superset of comparable. Comparison supports

nested `dict`, `list`, and `tuple` objects.

Aliases:

* `to\_be\_superset`

* `is\_superset`

New in version 0.3.0.

`reason` *= '{0} is not a supserset of {comparable}'*[¶](#verify.containers.Superset.reason "Permalink to this definition")

*class* `verify.containers.``NotSuperset`(*comparable*, *value=NotSet*, *\*\*opts*)[[source]](_modules/verify/containers.html#NotSuperset)[¶](#verify.containers.NotSuperset "Permalink to this definition")

Asserts that value is a not a superset of comparable.

Aliases:

* `to\_not\_be\_superset`

* `is\_not\_superset`

New in version 0.5.0.

`reason` *= '{0} is a superset of {comparable}'*[¶](#verify.containers.NotSuperset.reason "Permalink to this definition")

*class* `verify.containers.``Unique`(*value=NotSet*, *\*\*opts*)[[source]](_modules/verify/containers.html#Unique)[¶](#verify.containers.Unique "Permalink to this definition")

Asserts that value contains only unique values. If value is a

`dict`, then its `values()` will be compared.

Aliases:

* `to\_be\_unique`

* `is\_unique`

New in version 0.3.0.

`reason` *= '{0} contains duplicate items'*[¶](#verify.containers.Unique.reason "Permalink to this definition")

*class* `verify.containers.``NotUnique`(*value=NotSet*, *\*\*opts*)[[source]](_modules/verify/containers.html#NotUnique)[¶](#verify.containers.NotUnique "Permalink to this definition")

Asserts that value is a not a unique.

Aliases:

* `to\_not\_be\_unique`

* `is\_not\_unique`

New in version 0.5.0.

`reason` *= '{0} is unique'*[¶](#verify.containers.NotUnique.reason "Permalink to this definition")

*class* `verify.containers.``Length`(*value=NotSet*, *\*\*opts*)[[source]](_modules/verify/containers.html#Length)[¶](#verify.containers.Length "Permalink to this definition")

Asserts that value is an iterable with length between min and max

inclusively.

Examples

These will pass:

```

>>> assert Length([1, 2, 3], min=3, max=3)  # 3 <= len(a) <= 3

>>> assert Length([1, 2, 3, 4, 5], min=5, max=6)  # 5 <= len(a) <= 6

>>> assert Length([1, 2, 3], max=6)  # len(a) <= 6

>>> assert Length([1, 2, 3, 4], min=4)  # len(a) >= 4

```

This will fail:

```

>>> Length([1, 2, 4], max=2)  # len(a) <= 2

Traceback (most recent call last):

...

AssertionError...

```

| Parameters: | **value** (*mixed, optional*) – Value to compare. |

| Keyword Arguments: |

|  | * **min** (*int, optional*) –

Minimum value that value must be greater than or

equal to.

* **max** (*int, optional*) –

Maximum value that value must be less than or

equal to.

 |

Aliases:

* `to\_have\_length`

* `has\_length`

New in version 0.2.0.

Changed in version 0.4.0: * Change comparison to function like `Between` meaning length is

compared to min and max values.

* Allow keyword arguments `min` and `max` to be used in place of

positional tuple

Changed in version 1.0.0: Removed positional tuple argument and only support `min` and `max`

keyword arguments.

`reason` *= '{0} does not have length between {min} and {max}'*[¶](#verify.containers.Length.reason "Permalink to this definition")

*class* `verify.containers.``NotLength`(*value=NotSet*, *\*\*opts*)[[source]](_modules/verify/containers.html#NotLength)[¶](#verify.containers.NotLength "Permalink to this definition")

Asserts that value is an iterable with length not between min and

max inclusively.

Aliases:

* `to\_not\_have\_length`

* `does\_not\_have\_length`

New in version 1.0.0.

`reason` *= '{0} has length between {min} and {max}'*[¶](#verify.containers.NotLength.reason "Permalink to this definition")

##### Numbers[¶](#module-verify.numbers "Permalink to this headline")

Assertions related to numbers.

*class* `verify.numbers.``Greater`(*comparable*, *value=NotSet*, *\*\*opts*)[[source]](_modules/verify/numbers.html#Greater)[¶](#verify.numbers.Greater "Permalink to this definition")

Asserts that value is greater than comparable.

Aliases:

* `GreaterThan`

* `to\_be\_greater`

* `to\_be\_greater\_than`

* `is\_greater`

* `is\_greater\_than`

New in version 0.0.1.

`reason` *= '{0} is not greater than {comparable}'*[¶](#verify.numbers.Greater.reason "Permalink to this definition")

`verify.numbers.``GreaterThan`[¶](#verify.numbers.GreaterThan "Permalink to this definition")

alias of [`Greater`](#verify.numbers.Greater "verify.numbers.Greater")

*class* `verify.numbers.``GreaterEqual`(*comparable*, *value=NotSet*, *\*\*opts*)[[source]](_modules/verify/numbers.html#GreaterEqual)[¶](#verify.numbers.GreaterEqual "Permalink to this definition")

Asserts that value is greater than or equal to comparable.

Aliases:

* `GreaterThanEqual`

* `to\_be\_greater\_equal`

* `to\_be\_greater\_or\_equal`

* `is\_greater\_equal`

* `is\_greater\_or\_equal`

New in version 0.0.1.

`reason` *= '{0} is not greater than or equal to {comparable}'*[¶](#verify.numbers.GreaterEqual.reason "Permalink to this definition")

`verify.numbers.``GreaterOrEqual`[¶](#verify.numbers.GreaterOrEqual "Permalink to this definition")

alias of [`GreaterEqual`](#verify.numbers.GreaterEqual "verify.numbers.GreaterEqual")

*class* `verify.numbers.``Less`(*comparable*, *value=NotSet*, *\*\*opts*)[[source]](_modules/verify/numbers.html#Less)[¶](#verify.numbers.Less "Permalink to this definition")

Asserts that value is less than comparable.

Aliases:

* `LessThan`

* `to\_be\_less`

* `to\_be\_less\_than`

* `is\_less`

* `is\_less\_than`

New in version 0.0.1.

`reason` *= '{0} is not less than {comparable}'*[¶](#verify.numbers.Less.reason "Permalink to this definition")

`verify.numbers.``LessThan`[¶](#verify.numbers.LessThan "Permalink to this definition")

alias of [`Less`](#verify.numbers.Less "verify.numbers.Less")

*class* `verify.numbers.``LessEqual`(*comparable*, *value=NotSet*, *\*\*opts*)[[source]](_modules/verify/numbers.html#LessEqual)[¶](#verify.numbers.LessEqual "Permalink to this definition")

Asserts that value is less than or equal to comparable.

Aliases:

* `LessThanEqual`

* `to\_be\_less\_equal`

* `to\_be\_less\_or\_equal`

* `is\_less\_equal`

* `is\_less\_or\_equal`

New in version 0.0.1.

`reason` *= '{0} is not less than or equal to {comparable}'*[¶](#verify.numbers.LessEqual.reason "Permalink to this definition")

`verify.numbers.``LessOrEqual`[¶](#verify.numbers.LessOrEqual "Permalink to this definition")

alias of [`LessEqual`](#verify.numbers.LessEqual "verify.numbers.LessEqual")

*class* `verify.numbers.``Between`(*value=NotSet*, *\*\*opts*)[[source]](_modules/verify/numbers.html#Between)[¶](#verify.numbers.Between "Permalink to this definition")

Asserts that value is between min and max inclusively.

Examples

These will pass:

```

>>> assert Between(5, min=4, max=6)  # 4 <= 5 <= 6

>>> assert Between(5, min=5, max=6)  # 5 <= 5 <= 6

>>> assert Between(5, max=6)  # 5 <= 6

>>> assert Between(5, min=4)  # 5 >= 4

```

This will fail:

```

>>> Between(5, max=4)  # 5 <= 4

Traceback (most recent call last):

...

AssertionError...

```

| Parameters: | **value** (*mixed, optional*) – Value to compare. |

| Keyword Arguments: |

|  | * **min** (*int, optional*) –

Minimum value that value must be greater than or

equal to.

* **max** (*int, optional*) –

Maximum value that value must be less than or

equal to.

 |

Aliases:

* `to\_be\_between`

* `is\_between`

New in version 0.2.0.

Changed in version 0.4.0: Allow keyword arguments `min` and `max` to be used in place of

positional tuple.

Changed in version 1.0.0: Removed positional tuple argument and only support `min` and `max`

keyword arguments.

`reason` *= '{0} is not between {min} and {max}'*[¶](#verify.numbers.Between.reason "Permalink to this definition")

*class* `verify.numbers.``NotBetween`(*value=NotSet*, *\*\*opts*)[[source]](_modules/verify/numbers.html#NotBetween)[¶](#verify.numbers.NotBetween "Permalink to this definition")

Asserts that value is not between min and max inclusively.

Aliases:

* `to\_not\_be\_between`

* `is\_not\_between`

New in version 0.5.0.

`reason` *= '{0} is between {min} and {max}'*[¶](#verify.numbers.NotBetween.reason "Permalink to this definition")

*class* `verify.numbers.``Positive`(*value=NotSet*, *\*\*opts*)[[source]](_modules/verify/numbers.html#Positive)[¶](#verify.numbers.Positive "Permalink to this definition")

Asserts that value is a positive number.

Aliases:

* `to\_be\_positive`

* `is\_positive`

New in version 0.3.0.

`reason` *= '{0} is not a positive number'*[¶](#verify.numbers.Positive.reason "Permalink to this definition")

*class* `verify.numbers.``Negative`(*value=NotSet*, *\*\*opts*)[[source]](_modules/verify/numbers.html#Negative)[¶](#verify.numbers.Negative "Permalink to this definition")

Asserts that value is a negative number.

Aliases:

* `to\_be\_negative`

* `is\_negative`

New in version 0.3.0.

`reason` *= '{0} is not a negative number'*[¶](#verify.numbers.Negative.reason "Permalink to this definition")

*class* `verify.numbers.``Even`(*value=NotSet*, *\*\*opts*)[[source]](_modules/verify/numbers.html#Even)[¶](#verify.numbers.Even "Permalink to this definition")

Asserts that value is an even number.

Aliases:

* `to\_be\_even`

* `is\_even`

New in version 0.3.0.

`reason` *= '{0} is not an even number'*[¶](#verify.numbers.Even.reason "Permalink to this definition")

*class* `verify.numbers.``Odd`(*value=NotSet*, *\*\*opts*)[[source]](_modules/verify/numbers.html#Odd)[¶](#verify.numbers.Odd "Permalink to this definition")

Asserts that value is an odd number.

Aliases:

* `to\_be\_odd`

* `is\_odd`

New in version 0.3.0.

`reason` *= '{0} is not an odd number'*[¶](#verify.numbers.Odd.reason "Permalink to this definition")

*class* `verify.numbers.``Monotone`(*comparable*, *value=NotSet*, *\*\*opts*)[[source]](_modules/verify/numbers.html#Monotone)[¶](#verify.numbers.Monotone "Permalink to this definition")

Asserts that value is a monotonic with respect to comparable.

Aliases:

* `to\_be\_monotone`

* `is\_monotone`

New in version 0.3.0.

`reason` *= '{0} is not monotonic as evaluated by {comparable}'*[¶](#verify.numbers.Monotone.reason "Permalink to this definition")

*class* `verify.numbers.``Increasing`(*value=NotSet*, *\*\*opts*)[[source]](_modules/verify/numbers.html#Increasing)[¶](#verify.numbers.Increasing "Permalink to this definition")

Asserts that value is monotonically increasing.

Aliases:

* `to\_be\_increasing`

* `is\_increasing`

New in version 0.3.0.

`reason` *= '{0} is not monotonically increasing'*[¶](#verify.numbers.Increasing.reason "Permalink to this definition")

*class* `verify.numbers.``StrictlyIncreasing`(*value=NotSet*, *\*\*opts*)[[source]](_modules/verify/numbers.html#StrictlyIncreasing)[¶](#verify.numbers.StrictlyIncreasing "Permalink to this definition")

Asserts that value is strictly increasing.

Aliases:

* `to\_be\_strictly\_increasing`

* `is\_strictly\_increasing`

New in version 0.3.0.

`reason` *= '{0} is not strictly increasing'*[¶](#verify.numbers.StrictlyIncreasing.reason "Permalink to this definition")

*class* `verify.numbers.``Decreasing`(*value=NotSet*, *\*\*opts*)[[source]](_modules/verify/numbers.html#Decreasing)[¶](#verify.numbers.Decreasing "Permalink to this definition")

Asserts that value is monotonically decreasing.

Aliases:

* `to\_be\_decreasing`

* `is\_decreasing`

New in version 0.3.0.

`reason` *= '{0} is not monotonically decreasing'*[¶](#verify.numbers.Decreasing.reason "Permalink to this definition")

*class* `verify.numbers.``StrictlyDecreasing`(*value=NotSet*, *\*\*opts*)[[source]](_modules/verify/numbers.html#StrictlyDecreasing)[¶](#verify.numbers.StrictlyDecreasing "Permalink to this definition")

Asserts that value is strictly decreasing.

Aliases:

* `to\_be\_strictly\_decreasing`

* `is\_strictly\_decreasing`

New in version 0.3.0.

`reason` *= '{0} is not strictly decreasing'*[¶](#verify.numbers.StrictlyDecreasing.reason "Permalink to this definition")

Project Info[¶](#project-info "Permalink to this headline")

-----------------------------------------------------------

### License[¶](#license "Permalink to this headline")

The MIT License (MIT)

Copyright (c) 2015 Derrick Gilland

Permission is hereby granted, free of charge, to any person obtaining a copy

of this software and associated documentation files (the “Software”), to deal

in the Software without restriction, including without limitation the rights

to use, copy, modify, merge, publish, distribute, sublicense, and/or sell

copies of the Software, and to permit persons to whom the Software is

furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all

copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR

IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,

FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE

AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER

LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,

OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE

SOFTWARE.

### Versioning[¶](#versioning "Permalink to this headline")

This project follows [Semantic Versioning](http://semver.org/) with the following caveats:

* Only the public API (i.e. the objects imported into the `verify` module) will maintain backwards compatibility between MINOR version bumps.

* Objects within any other parts of the library are not guaranteed to not break between MINOR version bumps.

With that in mind, it is recommended to only use or import objects from the main module, `verify`.

### Changelog[¶](#changelog "Permalink to this headline")

#### v1.1.1 (2017-05-09)[¶](#v1-1-1-2017-05-09 "Permalink to this headline")

* Fix compatibility with pydash v4.

#### v1.1.0 (2015-07-23)[¶](#v1-1-0-2015-07-23 "Permalink to this headline")

* Add `ensure` as alias of `expect`.

* Add `to\_be\_\*` and `is\_\*` aliases for all assertions.

#### v1.0.0 (2015-05-15)[¶](#v1-0-0-2015-05-15 "Permalink to this headline")

* Add `NotLength`.

* Make assertions accept an optional argument, `msg`, that overrides the default assert message on a per call basis.

* Make `Between` and `Length` only accept keyword arguments `min` and `max`. (**breaking change**)

#### v0.6.0 (2015-05-14)[¶](#v0-6-0-2015-05-14 "Permalink to this headline")

* Make `expect` into a class and support method chaining of assertions. Original usage is still supported.

* Make `expect` wrap external predicate functions with `Predicate` for evaluation. (**breaking change**)

* Make `Predicate` catch `AssertionError` thrown by comparable and return `False`. (**breaking change**)

* Make `Predicate` treat a comparable that returns `None` as passing. (**breaking change**)

* Rename `InstanceOf` and `NotInstanceOf` to `Type` and `NotType`. (**breaking change**)

#### v0.5.0 (2015-05-12)[¶](#v0-5-0-2015-05-12 "Permalink to this headline")

* Add `NotEqual`.

* Add `NotMatch`.

* Add `NotBetween`.

* Add `IsNot`.

* Add `IsNotTrue`.

* Add `IsNotFalse`.

* Add `IsNotNone`.

* Add `NotAll`.

* Add `NotAny`.

* Add `NotIn`.

* Add `NotContains`.

* Add `NotContainsOnly`.

* Add `NotSubset`.

* Add `NotSuperset`.

* Add `NotUnique`.

* Add `NotInstanceOf`.

* Add `NotBoolean`.

* Add `NotString`.

* Add `NotDict`.

* Add `NotList`.

* Add `NotTuple`.

* Add `NotDate`.

* Add `NotDateString`.

* Add `NotInt`.

* Add `NotFloat`.

* Rename `NaN` to `NotNumber`. (**breaking change**)

#### v0.4.0 (2015-05-12)[¶](#v0-4-0-2015-05-12 "Permalink to this headline")

* Make `Between` accept keyword arguments for `min` and `max`.

* Make `Length` function like `Between` and allow comparison over range of lengths. If a single comparable value is passed in, then comparison uses the value as a max length. Previously, a single comparable value performed an equality check for length. (**breaking change**)

* Make `Match` accept keyword argument `flags` for use with string based regular expression.

#### v0.3.0 (2015-05-11)[¶](#v0-3-0-2015-05-11 "Permalink to this headline")

* Add `Match`.

* Add `Subset`.

* Add `Superset`.

* Add `Unique`.

* Add `Date`.

* Add `DateString`.

* Add `Positive`.

* Add `Negative`.

* Add `Even`.

* Add `Odd`.

* Add `Monotone`.

* Add `Increasing`.

* Add `StrictlyIncreasing`.

* Add `Decreasing`.

* Add `StrictlyDecreasing`.

#### v0.2.0 (2015-05-11)[¶](#v0-2-0-2015-05-11 "Permalink to this headline")

* Add `All`.

* Add `Any`.

* Add `Between`.

* Add `Contains`.

* Add `ContainsOnly`.

* Add `Length`.

* Make `Not` compatible with bare predicate functions by return the evaluation of the comparable.

#### v0.1.1 (2015-05-08)[¶](#v0-1-1-2015-05-08 "Permalink to this headline")

* Make `expect` include an assertion message on failure. Without it, a cryptic `NameError` is thrown when a plain predicate function fails due to a generator being used in the `all()` call.

#### v0.1.0 (2015-05-08)[¶](#v0-1-0-2015-05-08 "Permalink to this headline")

* Add `Boolean`.

* Add `Dict`.

* Add `Float`.

* Add `Int`.

* Add `IsTrue`.

* Add `IsFalse`.

* Add `List`.

* Add `NaN`.

* Add `Number`.

* Add `Predicate`.

* Add `String`.

* Add `Tuple`.

* Rename `Except` to `except`. (**breaking change**)

* Make `except` **not** call value if it’s callable. (**breaking change**)

* Make `except` return `True` if all assertions pass.

#### v0.0.1 (2015-05-07)[¶](#v0-0-1-2015-05-07 "Permalink to this headline")

* First release.

### Authors[¶](#authors "Permalink to this headline")

#### Lead[¶](#lead "Permalink to this headline")

* Derrick Gilland, [dgilland@gmail.com](mailto:dgilland%40gmail.com), [dgilland@github](https://github.com/dgilland)

#### Contributors[¶](#contributors "Permalink to this headline")

* Szczepan Cieślik, [szczepan.cieslik@gmail.com](mailto:szczepan.cieslik%40gmail.com), [beregond@github](https://github.com/beregond)

### How to Contribute[¶](#how-to-contribute "Permalink to this headline")

* [Overview](#overview)

* [Guidelines](#guidelines)

* [Branching](#branching)

* [Continuous Integration](#continuous-integration)

* [Project CLI](#project-cli)

#### Overview[¶](#overview "Permalink to this headline")

1. Fork the repo.

2. Build development environment run tests to ensure a clean, working slate.

3. Improve/fix the code.

4. Add test cases if new functionality introduced or bug fixed (100% test coverage).

5. Ensure tests pass.

6. Add yourself to `AUTHORS.rst`.

7. Push to your fork and submit a pull request to the `develop` branch.

#### Guidelines[¶](#guidelines "Permalink to this headline")

Some simple guidelines to follow when contributing code:

* Adhere to [PEP8](http://legacy.python.org/dev/peps/pep-0008/).

* Clean, well documented code.

* All tests must pass.

* 100% test coverage.

#### Branching[¶](#branching "Permalink to this headline")

There are two main development branches: `master` and `develop`. `master` represents the currently released version while `develop` is the latest development work. When submitting a pull request, be sure to submit to `develop`. The originating branch you submit from can be any name though.

#### Continuous Integration[¶](#continuous-integration "Permalink to this headline")

Integration testing is provided by [Travis-CI](https://travis-ci.org/) at <https://travis-ci.org/dgilland/verify>.

Test coverage reporting is provided by [Coveralls](https://coveralls.io/) at <https://coveralls.io/r/dgilland/verify>.

#### Project CLI[¶](#project-cli "Permalink to this headline")

Some useful CLI commands when working on the project are below. **NOTE:** All commands are run from the root of the project and require `make`.

##### make build[¶](#make-build "Permalink to this headline")

Run the `clean` and `install` commands.

```

make build

```

##### make install[¶](#make-install "Permalink to this headline")

Install Python dependencies into virtualenv located at `env/`.

```

make install

```

##### make clean[¶](#make-clean "Permalink to this headline")

Remove build/test related temporary files like `env/`, `.tox`, `.coverage`, and `\_\_pycache\_\_`.

```

make clean

```

##### make test[¶](#make-test "Permalink to this headline")

Run unittests under the virtualenv’s default Python version. Does not test all support Python versions. To test all supported versions, see [make test-full](#make-test-full).

```

make test

```

##### make test-full[¶](#make-test-full "Permalink to this headline")

Run unittest and linting for all supported Python versions. **NOTE:** This will fail if you do not have all Python versions installed on your system. If you are on an Ubuntu based system, the [Dead Snakes PPA](https://launchpad.net/~fkrull/+archive/deadsnakes) is a good resource for easily installing multiple Python versions. If for whatever reason you’re unable to have all Python versions on your development machine, note that Travis-CI will run full integration tests on all pull requests.

```

make test-full

```

##### make lint[¶](#make-lint "Permalink to this headline")

Run `make pylint` and `make pep8` commands.

```

make lint

```

##### make pylint[¶](#make-pylint "Permalink to this headline")

Run `pylint` compliance check on code base.

```

make pylint

```

##### make pep8[¶](#make-pep8 "Permalink to this headline")

Run [PEP8](http://legacy.python.org/dev/peps/pep-0008/) compliance check on code base.

```

make pep8

```

##### make docs[¶](#make-docs "Permalink to this headline")

Build documentation to `docs/\_build/`.

```

make docs

```

Indices and Tables[¶](#indices-and-tables "Permalink to this headline")

-----------------------------------------------------------------------

* [Index](genindex.html)

* [Module Index](py-modindex.html)

* [Search Page](search.html)

