Numeric matchers

These matchers allow you to assert on specific numeric types, such as ints or floats They are often combined with operator matchers to formulate constaints on numeric arguments of mocks:

from argmatch import Integer, GreaterThan
mock_foo.assert_called_with(Integer() & GreaterThan(42))

Integers

class argmatch.numbers.Integer[source]

Matches a regular integer.

On Python 3, there is no distinction between regular and long integer, making this matcher and Long equivalent.

On Python 2, this matches the int integers exclusively.

class argmatch.numbers.Long[source]

Matches a long integer.

On Python 3, this is the same as regular integer, making this matcher and Integer equivalent.

On Python 2, this matches the long integers exclusively.

class argmatch.numbers.Integral[source]

Matches any integer. This ignores the length of integer’s internal representation on Python 2.

Rational numbers

class argmatch.numbers.Fraction[source]

Matches a fraction object.

class argmatch.numbers.Rational[source]

Matches a rational number. This includes all integer numbers as well.

Floating point numbers

class argmatch.numbers.Float[source]

Matches a floating point number.

class argmatch.numbers.Real[source]

Matches any real number.

This includes all rational and integer numbers as well, which in Python translates to fractions, and integers.

Complex numbers

class argmatch.numbers.Complex[source]

Matches any complex number.

This includes all real, rational, and integer numbers as well, which in Python translates to floats, fractions, and integers.

All numbers

class argmatch.numbers.Number[source]

Matches any number (integer, float, complex, custom number types, etc.).