Numeric matchers
These matchers allow you to assert on specific numeric types, such as int
s or float
s
They are often combined with operator matchers to formulate constaints on numeric arguments of mocks:
from callee import Integer, GreaterThan
mock_foo.assert_called_with(Integer() & GreaterThan(42))
Integers
-
class
callee.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
callee.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
callee.numbers.
Integral
[source]
Matches any integer.
This ignores the length of integer’s internal representation on Python 2.
Rational numbers
-
class
callee.numbers.
Fraction
[source]
Matches a fraction object.
-
class
callee.numbers.
Rational
[source]
Matches a rational number.
This includes all integer numbers as well.
Floating point numbers
-
class
callee.numbers.
Float
[source]
Matches a floating point number.
-
class
callee.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
callee.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
callee.numbers.
Number
[source]
Matches any number
(integer, float, complex, custom number types, etc.).