assertionlib.manager
A module containing the actual AssertionManager
class.
Index
An instance of |
|
|
A class for performing assertions and providing informative exception messages. |
|
Perform the following assertion: |
|
Equivalent to |
|
Add a new custom assertion method to this instance. |
Assertions based on the builtin operator
module.
Perform the following assertion: |
|
Perform the following assertion: |
|
Perform the following assertion: |
|
Perform the following assertion: |
|
Perform the following assertion: |
|
Perform the following assertion: |
|
Perform the following assertion: |
|
Perform the following assertion: |
|
Perform the following assertion: |
|
Perform the following assertion: |
|
Perform the following assertion: |
|
Perform the following assertion: |
|
Perform the following assertion: |
|
Perform the following assertion: |
|
Perform the following assertion: |
|
Perform the following assertion: |
|
Perform the following assertion: |
|
Perform the following assertion: |
|
Perform the following assertion: |
|
Perform the following assertion: |
|
Perform the following assertion: |
|
Perform the following assertion: |
|
Perform the following assertion: |
|
Perform the following assertion: |
|
Perform the following assertion: |
|
Perform the following assertion: |
|
Perform the following assertion: |
|
Perform the following assertion: |
|
Perform the following assertion: |
|
Perform the following assertion: |
|
Perform the following assertion: |
|
Perform the following assertion: |
|
Perform the following assertion: |
|
Perform the following assertion: |
Assertions based on the builtin os.path
module.
Perform the following assertion: |
|
Perform the following assertion: |
|
Perform the following assertion: |
|
Perform the following assertion: |
|
Perform the following assertion: |
Assertions based on the builtin math
module.
Perform the following assertion: |
|
Perform the following assertion: |
|
Perform the following assertion: |
|
Perform the following assertion: |
|
Perform the following assertion: |
Assertions based on the builtin builtins
module.
Perform the following assertion: |
|
Perform the following assertion: |
|
Perform the following assertion: |
|
Perform the following assertion: |
|
Perform the following assertion: |
|
Perform the following assertion: |
|
Perform the following assertion: |
|
Perform the following assertion: |
|
Perform the following assertion: |
|
Perform the following assertion: |
|
Perform the following assertion: |
Miscellaneous assertions.
Perform the following assertion: |
|
Perform the following assertion: |
|
Perform the following assertion: |
|
Perform the following assertion: |
API
- assertionlib.manager.assertion : AssertionManager
An instance of
AssertionManager
.
- class assertionlib.manager.AssertionManager(repr_instance: ~typing.Optional[~reprlib.Repr] = <assertionlib.ndrepr.NDRepr object>)[source]
A class for performing assertions and providing informative exception messages.
A number of usage examples are provided in the the documentation.
- Parameters:
repr_instance (
reprlib.Repr
, optional) – An instance ofreprlib.Repr
for formatting Exception messages. The passed instance should have access to a bound callable by the name ofrepr
, which in turn should produce a string representation of any passed objects. IfNone
, default the builtinrepr()
function. See alsoAssertionManager.repr_instance
.
- repr_instance
An instance of
reprlib.Repr
for formatting Exception messages. The passed instance should have access to a bound callable by the name ofrepr
, which in turn should produce a string representation of passed objects. IfNone
, default the builtinrepr()
function.- Type:
reprlib.Repr
, optional
- repr_fallback
A fallback value in case
AssertionManager.repr_instance
isNone
.- Type:
- maxstring_fallback
A fallback value in case
AssertionManager.repr_instance
isNone
.- Type:
- AssertionManager.assert_(func: Callable[[...], T], *args: Any, invert: bool = False, exception: Optional[Type[Exception]] = None, post_process: Optional[Callable[[T], Any]] = None, message: Optional[str] = None, **kwargs: Any) None [source]
Perform the following assertion:
assert func(*args, **kwargs)
.Examples
For example
assert 5 == 5
is equivalent toAssertionManager().assert_(operator.eq, 5, 5)
.- Parameters:
func (
Callable[..., T]
) – The callable whose output will be evaluated.*args (
Any
) – Positional arguments for func.
- Keyword Arguments:
invert (
bool
, optional) – IfTrue
, invert the output of the assertion:assert not func(*args, **kwargs)
.exception (
type
[Exception
], optional) – Assert that exception is raised during/before the assertion operation. The only dissalowed value isAssertionError
.post_process (
Callable[[T], bool]
, optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example functions would be the likes ofany()
andall()
.message (
str
, optional) – A custom error message to-be passed to theassert
statement.**kwargs (
Any
, optional) – Keyword arguments for func.
- Return type:
See also
AssertionManager.__call__()
Equivalent to
assert value
.
- AssertionManager.__call__(value: T, *, invert: bool = False, post_process: Optional[Callable[[T], Any]] = None, message: Optional[str] = None) None [source]
Equivalent to
assert value
.Examples
>>> from assertionlib import assertion >>> assertion(5 == 5) >>> assertion(5 == 6) Traceback (most recent call last): ... AssertionError: output = (value); assert output exception: AssertionError = 'None' output: bool = False value: bool = False
- Parameters:
value (
T
) – The to-be asserted value.- Keyword Arguments:
invert (
bool
) – IfTrue
, invert the output of the assertion:assert not value
.post_process (
Callable[[T], bool]
, optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example functions would be the likes ofany()
andall()
.message (
str
, optional) – A custom error message to-be passed to theassert
statement.
- Return type:
- AssertionManager.add_to_instance(func: Callable, name: Optional[str] = None, override_attr: bool = False) None [source]
Add a new custom assertion method to this instance.
The new method name is added to
AssertionManager._PRIVATE_ATTR
.- Parameters:
func (
Callable
) – The callable whose output will be asserted in the to-be created method.- Keyword Arguments:
name (
str
, optional) – The name of the new method. IfNone
, use the name of func.override_attr (
bool
) – IfFalse
, raise anAttributeError
if a method with the same name already exists in this instance.
- Return type:
- Raises:
AttributeError – Raised if
override_attr=False
and a method with the same name already exists in this instance.
Assertions based on the builtin operator
module
- AssertionManager.abs(a, /, **kwargs: ~typing.Any) None
Perform the following assertion:
assert abs(a)
.- Parameters:
a – The positional-only argument
a
ofabs()
.- Keyword Arguments:
invert (
bool
) – IfTrue
, invert the output of the assertion:assert not abs(a)
.exception (
type
[Exception
], optional) – Assert that exception is raised during/before the assertion operation.post_process (
Callable[[Any], bool]
, optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example values would be the likes ofany()
andall()
.message (
str
, optional) – A custom error message to-be passed to theassert
statement.
- Return type:
See also
abs()
Same as abs(a).
- AssertionManager.add(a, b, /, **kwargs: ~typing.Any) None
Perform the following assertion:
assert add(a, b)
.- Parameters:
- Keyword Arguments:
invert (
bool
) – IfTrue
, invert the output of the assertion:assert not add(a, b)
.exception (
type
[Exception
], optional) – Assert that exception is raised during/before the assertion operation.post_process (
Callable[[Any], bool]
, optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example values would be the likes ofany()
andall()
.message (
str
, optional) – A custom error message to-be passed to theassert
statement.
- Return type:
See also
add()
Same as a + b.
- AssertionManager.and_(a, b, /, **kwargs: ~typing.Any) None
Perform the following assertion:
assert and_(a, b)
.- Parameters:
- Keyword Arguments:
invert (
bool
) – IfTrue
, invert the output of the assertion:assert not and_(a, b)
.exception (
type
[Exception
], optional) – Assert that exception is raised during/before the assertion operation.post_process (
Callable[[Any], bool]
, optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example values would be the likes ofany()
andall()
.message (
str
, optional) – A custom error message to-be passed to theassert
statement.
- Return type:
See also
and_()
Same as a & b.
- AssertionManager.concat(a, b, /, **kwargs: ~typing.Any) None
Perform the following assertion:
assert concat(a, b)
.- Parameters:
- Keyword Arguments:
invert (
bool
) – IfTrue
, invert the output of the assertion:assert not concat(a, b)
.exception (
type
[Exception
], optional) – Assert that exception is raised during/before the assertion operation.post_process (
Callable[[Any], bool]
, optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example values would be the likes ofany()
andall()
.message (
str
, optional) – A custom error message to-be passed to theassert
statement.
- Return type:
See also
concat()
Same as a + b, for a and b sequences.
- AssertionManager.contains(a, b, /, **kwargs: ~typing.Any) None
Perform the following assertion:
assert contains(a, b)
.- Parameters:
a – The positional-only argument
a
ofcontains()
.b – The positional-only argument
b
ofcontains()
.
- Keyword Arguments:
invert (
bool
) – IfTrue
, invert the output of the assertion:assert not contains(a, b)
.exception (
type
[Exception
], optional) – Assert that exception is raised during/before the assertion operation.post_process (
Callable[[Any], bool]
, optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example values would be the likes ofany()
andall()
.message (
str
, optional) – A custom error message to-be passed to theassert
statement.
- Return type:
See also
contains()
Same as b in a (note reversed operands).
- AssertionManager.countOf(a, b, /, **kwargs: ~typing.Any) None
Perform the following assertion:
assert countOf(a, b)
.- Parameters:
- Keyword Arguments:
invert (
bool
) – IfTrue
, invert the output of the assertion:assert not countOf(a, b)
.exception (
type
[Exception
], optional) – Assert that exception is raised during/before the assertion operation.post_process (
Callable[[Any], bool]
, optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example values would be the likes ofany()
andall()
.message (
str
, optional) – A custom error message to-be passed to theassert
statement.
- Return type:
See also
countOf()
Return the number of times b occurs in a.
- AssertionManager.eq(a, b, /, **kwargs: ~typing.Any) None
Perform the following assertion:
assert eq(a, b)
.- Parameters:
- Keyword Arguments:
invert (
bool
) – IfTrue
, invert the output of the assertion:assert not eq(a, b)
.exception (
type
[Exception
], optional) – Assert that exception is raised during/before the assertion operation.post_process (
Callable[[Any], bool]
, optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example values would be the likes ofany()
andall()
.message (
str
, optional) – A custom error message to-be passed to theassert
statement.
- Return type:
See also
eq()
Same as a == b.
- AssertionManager.floordiv(a, b, /, **kwargs: ~typing.Any) None
Perform the following assertion:
assert floordiv(a, b)
.- Parameters:
a – The positional-only argument
a
offloordiv()
.b – The positional-only argument
b
offloordiv()
.
- Keyword Arguments:
invert (
bool
) – IfTrue
, invert the output of the assertion:assert not floordiv(a, b)
.exception (
type
[Exception
], optional) – Assert that exception is raised during/before the assertion operation.post_process (
Callable[[Any], bool]
, optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example values would be the likes ofany()
andall()
.message (
str
, optional) – A custom error message to-be passed to theassert
statement.
- Return type:
See also
floordiv()
Same as a // b.
- AssertionManager.ge(a, b, /, **kwargs: ~typing.Any) None
Perform the following assertion:
assert ge(a, b)
.- Parameters:
- Keyword Arguments:
invert (
bool
) – IfTrue
, invert the output of the assertion:assert not ge(a, b)
.exception (
type
[Exception
], optional) – Assert that exception is raised during/before the assertion operation.post_process (
Callable[[Any], bool]
, optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example values would be the likes ofany()
andall()
.message (
str
, optional) – A custom error message to-be passed to theassert
statement.
- Return type:
See also
ge()
Same as a >= b.
- AssertionManager.getitem(a, b, /, **kwargs: ~typing.Any) None
Perform the following assertion:
assert getitem(a, b)
.- Parameters:
- Keyword Arguments:
invert (
bool
) – IfTrue
, invert the output of the assertion:assert not getitem(a, b)
.exception (
type
[Exception
], optional) – Assert that exception is raised during/before the assertion operation.post_process (
Callable[[Any], bool]
, optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example values would be the likes ofany()
andall()
.message (
str
, optional) – A custom error message to-be passed to theassert
statement.
- Return type:
See also
getitem()
Same as a[b].
- AssertionManager.gt(a, b, /, **kwargs: ~typing.Any) None
Perform the following assertion:
assert gt(a, b)
.- Parameters:
- Keyword Arguments:
invert (
bool
) – IfTrue
, invert the output of the assertion:assert not gt(a, b)
.exception (
type
[Exception
], optional) – Assert that exception is raised during/before the assertion operation.post_process (
Callable[[Any], bool]
, optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example values would be the likes ofany()
andall()
.message (
str
, optional) – A custom error message to-be passed to theassert
statement.
- Return type:
See also
gt()
Same as a > b.
- AssertionManager.index(a, /, **kwargs: ~typing.Any) None
Perform the following assertion:
assert index(a)
.- Parameters:
a – The positional-only argument
a
ofindex()
.- Keyword Arguments:
invert (
bool
) – IfTrue
, invert the output of the assertion:assert not index(a)
.exception (
type
[Exception
], optional) – Assert that exception is raised during/before the assertion operation.post_process (
Callable[[Any], bool]
, optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example values would be the likes ofany()
andall()
.message (
str
, optional) – A custom error message to-be passed to theassert
statement.
- Return type:
See also
index()
Same as a.__index__()
- AssertionManager.indexOf(a, b, /, **kwargs: ~typing.Any) None
Perform the following assertion:
assert indexOf(a, b)
.- Parameters:
- Keyword Arguments:
invert (
bool
) – IfTrue
, invert the output of the assertion:assert not indexOf(a, b)
.exception (
type
[Exception
], optional) – Assert that exception is raised during/before the assertion operation.post_process (
Callable[[Any], bool]
, optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example values would be the likes ofany()
andall()
.message (
str
, optional) – A custom error message to-be passed to theassert
statement.
- Return type:
See also
indexOf()
Return the first index of b in a.
- AssertionManager.inv(a, /, **kwargs: ~typing.Any) None
Perform the following assertion:
assert inv(a)
.- Parameters:
a – The positional-only argument
a
ofinv()
.- Keyword Arguments:
invert (
bool
) – IfTrue
, invert the output of the assertion:assert not inv(a)
.exception (
type
[Exception
], optional) – Assert that exception is raised during/before the assertion operation.post_process (
Callable[[Any], bool]
, optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example values would be the likes ofany()
andall()
.message (
str
, optional) – A custom error message to-be passed to theassert
statement.
- Return type:
See also
inv()
Same as ~a.
- AssertionManager.invert(a, /, **kwargs: ~typing.Any) None
Perform the following assertion:
assert invert(a)
.- Parameters:
a – The positional-only argument
a
ofinvert()
.- Keyword Arguments:
invert (
bool
) – IfTrue
, invert the output of the assertion:assert not invert(a)
.exception (
type
[Exception
], optional) – Assert that exception is raised during/before the assertion operation.post_process (
Callable[[Any], bool]
, optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example values would be the likes ofany()
andall()
.message (
str
, optional) – A custom error message to-be passed to theassert
statement.
- Return type:
See also
invert()
Same as ~a.
- AssertionManager.is_(a, b, /, **kwargs: ~typing.Any) None
Perform the following assertion:
assert is_(a, b)
.- Parameters:
- Keyword Arguments:
invert (
bool
) – IfTrue
, invert the output of the assertion:assert not is_(a, b)
.exception (
type
[Exception
], optional) – Assert that exception is raised during/before the assertion operation.post_process (
Callable[[Any], bool]
, optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example values would be the likes ofany()
andall()
.message (
str
, optional) – A custom error message to-be passed to theassert
statement.
- Return type:
See also
is_()
Same as a is b.
- AssertionManager.is_not(a, b, /, **kwargs: ~typing.Any) None
Perform the following assertion:
assert is_not(a, b)
.- Parameters:
- Keyword Arguments:
invert (
bool
) – IfTrue
, invert the output of the assertion:assert not is_not(a, b)
.exception (
type
[Exception
], optional) – Assert that exception is raised during/before the assertion operation.post_process (
Callable[[Any], bool]
, optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example values would be the likes ofany()
andall()
.message (
str
, optional) – A custom error message to-be passed to theassert
statement.
- Return type:
See also
is_not()
Same as a is not b.
- AssertionManager.le(a, b, /, **kwargs: ~typing.Any) None
Perform the following assertion:
assert le(a, b)
.- Parameters:
- Keyword Arguments:
invert (
bool
) – IfTrue
, invert the output of the assertion:assert not le(a, b)
.exception (
type
[Exception
], optional) – Assert that exception is raised during/before the assertion operation.post_process (
Callable[[Any], bool]
, optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example values would be the likes ofany()
andall()
.message (
str
, optional) – A custom error message to-be passed to theassert
statement.
- Return type:
See also
le()
Same as a <= b.
- AssertionManager.lshift(a, b, /, **kwargs: ~typing.Any) None
Perform the following assertion:
assert lshift(a, b)
.- Parameters:
- Keyword Arguments:
invert (
bool
) – IfTrue
, invert the output of the assertion:assert not lshift(a, b)
.exception (
type
[Exception
], optional) – Assert that exception is raised during/before the assertion operation.post_process (
Callable[[Any], bool]
, optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example values would be the likes ofany()
andall()
.message (
str
, optional) – A custom error message to-be passed to theassert
statement.
- Return type:
See also
lshift()
Same as a << b.
- AssertionManager.lt(a, b, /, **kwargs: ~typing.Any) None
Perform the following assertion:
assert lt(a, b)
.- Parameters:
- Keyword Arguments:
invert (
bool
) – IfTrue
, invert the output of the assertion:assert not lt(a, b)
.exception (
type
[Exception
], optional) – Assert that exception is raised during/before the assertion operation.post_process (
Callable[[Any], bool]
, optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example values would be the likes ofany()
andall()
.message (
str
, optional) – A custom error message to-be passed to theassert
statement.
- Return type:
See also
lt()
Same as a < b.
- AssertionManager.matmul(a, b, /, **kwargs: ~typing.Any) None
Perform the following assertion:
assert matmul(a, b)
.- Parameters:
- Keyword Arguments:
invert (
bool
) – IfTrue
, invert the output of the assertion:assert not matmul(a, b)
.exception (
type
[Exception
], optional) – Assert that exception is raised during/before the assertion operation.post_process (
Callable[[Any], bool]
, optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example values would be the likes ofany()
andall()
.message (
str
, optional) – A custom error message to-be passed to theassert
statement.
- Return type:
See also
matmul()
Same as a @ b.
- AssertionManager.mod(a, b, /, **kwargs: ~typing.Any) None
Perform the following assertion:
assert mod(a, b)
.- Parameters:
- Keyword Arguments:
invert (
bool
) – IfTrue
, invert the output of the assertion:assert not mod(a, b)
.exception (
type
[Exception
], optional) – Assert that exception is raised during/before the assertion operation.post_process (
Callable[[Any], bool]
, optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example values would be the likes ofany()
andall()
.message (
str
, optional) – A custom error message to-be passed to theassert
statement.
- Return type:
See also
mod()
Same as a % b.
- AssertionManager.mul(a, b, /, **kwargs: ~typing.Any) None
Perform the following assertion:
assert mul(a, b)
.- Parameters:
- Keyword Arguments:
invert (
bool
) – IfTrue
, invert the output of the assertion:assert not mul(a, b)
.exception (
type
[Exception
], optional) – Assert that exception is raised during/before the assertion operation.post_process (
Callable[[Any], bool]
, optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example values would be the likes ofany()
andall()
.message (
str
, optional) – A custom error message to-be passed to theassert
statement.
- Return type:
See also
mul()
Same as a * b.
- AssertionManager.ne(a, b, /, **kwargs: ~typing.Any) None
Perform the following assertion:
assert ne(a, b)
.- Parameters:
- Keyword Arguments:
invert (
bool
) – IfTrue
, invert the output of the assertion:assert not ne(a, b)
.exception (
type
[Exception
], optional) – Assert that exception is raised during/before the assertion operation.post_process (
Callable[[Any], bool]
, optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example values would be the likes ofany()
andall()
.message (
str
, optional) – A custom error message to-be passed to theassert
statement.
- Return type:
See also
ne()
Same as a != b.
- AssertionManager.neg(a, /, **kwargs: ~typing.Any) None
Perform the following assertion:
assert neg(a)
.- Parameters:
a – The positional-only argument
a
ofneg()
.- Keyword Arguments:
invert (
bool
) – IfTrue
, invert the output of the assertion:assert not neg(a)
.exception (
type
[Exception
], optional) – Assert that exception is raised during/before the assertion operation.post_process (
Callable[[Any], bool]
, optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example values would be the likes ofany()
andall()
.message (
str
, optional) – A custom error message to-be passed to theassert
statement.
- Return type:
See also
neg()
Same as -a.
- AssertionManager.not_(a, /, **kwargs: ~typing.Any) None
Perform the following assertion:
assert not_(a)
.- Parameters:
a – The positional-only argument
a
ofnot_()
.- Keyword Arguments:
invert (
bool
) – IfTrue
, invert the output of the assertion:assert not not_(a)
.exception (
type
[Exception
], optional) – Assert that exception is raised during/before the assertion operation.post_process (
Callable[[Any], bool]
, optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example values would be the likes ofany()
andall()
.message (
str
, optional) – A custom error message to-be passed to theassert
statement.
- Return type:
See also
not_()
Same as not a.
- AssertionManager.or_(a, b, /, **kwargs: ~typing.Any) None
Perform the following assertion:
assert or_(a, b)
.- Parameters:
- Keyword Arguments:
invert (
bool
) – IfTrue
, invert the output of the assertion:assert not or_(a, b)
.exception (
type
[Exception
], optional) – Assert that exception is raised during/before the assertion operation.post_process (
Callable[[Any], bool]
, optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example values would be the likes ofany()
andall()
.message (
str
, optional) – A custom error message to-be passed to theassert
statement.
- Return type:
See also
or_()
Same as a | b.
- AssertionManager.pos(a, /, **kwargs: ~typing.Any) None
Perform the following assertion:
assert pos(a)
.- Parameters:
a – The positional-only argument
a
ofpos()
.- Keyword Arguments:
invert (
bool
) – IfTrue
, invert the output of the assertion:assert not pos(a)
.exception (
type
[Exception
], optional) – Assert that exception is raised during/before the assertion operation.post_process (
Callable[[Any], bool]
, optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example values would be the likes ofany()
andall()
.message (
str
, optional) – A custom error message to-be passed to theassert
statement.
- Return type:
See also
pos()
Same as +a.
- AssertionManager.pow(a, b, /, **kwargs: ~typing.Any) None
Perform the following assertion:
assert pow(a, b)
.- Parameters:
- Keyword Arguments:
invert (
bool
) – IfTrue
, invert the output of the assertion:assert not pow(a, b)
.exception (
type
[Exception
], optional) – Assert that exception is raised during/before the assertion operation.post_process (
Callable[[Any], bool]
, optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example values would be the likes ofany()
andall()
.message (
str
, optional) – A custom error message to-be passed to theassert
statement.
- Return type:
See also
pow()
Same as a ** b.
- AssertionManager.rshift(a, b, /, **kwargs: ~typing.Any) None
Perform the following assertion:
assert rshift(a, b)
.- Parameters:
- Keyword Arguments:
invert (
bool
) – IfTrue
, invert the output of the assertion:assert not rshift(a, b)
.exception (
type
[Exception
], optional) – Assert that exception is raised during/before the assertion operation.post_process (
Callable[[Any], bool]
, optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example values would be the likes ofany()
andall()
.message (
str
, optional) – A custom error message to-be passed to theassert
statement.
- Return type:
See also
rshift()
Same as a >> b.
- AssertionManager.sub(a, b, /, **kwargs: ~typing.Any) None
Perform the following assertion:
assert sub(a, b)
.- Parameters:
- Keyword Arguments:
invert (
bool
) – IfTrue
, invert the output of the assertion:assert not sub(a, b)
.exception (
type
[Exception
], optional) – Assert that exception is raised during/before the assertion operation.post_process (
Callable[[Any], bool]
, optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example values would be the likes ofany()
andall()
.message (
str
, optional) – A custom error message to-be passed to theassert
statement.
- Return type:
See also
sub()
Same as a - b.
- AssertionManager.truediv(a, b, /, **kwargs: ~typing.Any) None
Perform the following assertion:
assert truediv(a, b)
.- Parameters:
- Keyword Arguments:
invert (
bool
) – IfTrue
, invert the output of the assertion:assert not truediv(a, b)
.exception (
type
[Exception
], optional) – Assert that exception is raised during/before the assertion operation.post_process (
Callable[[Any], bool]
, optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example values would be the likes ofany()
andall()
.message (
str
, optional) – A custom error message to-be passed to theassert
statement.
- Return type:
See also
truediv()
Same as a / b.
- AssertionManager.truth(a, /, **kwargs: ~typing.Any) None
Perform the following assertion:
assert truth(a)
.- Parameters:
a – The positional-only argument
a
oftruth()
.- Keyword Arguments:
invert (
bool
) – IfTrue
, invert the output of the assertion:assert not truth(a)
.exception (
type
[Exception
], optional) – Assert that exception is raised during/before the assertion operation.post_process (
Callable[[Any], bool]
, optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example values would be the likes ofany()
andall()
.message (
str
, optional) – A custom error message to-be passed to theassert
statement.
- Return type:
See also
truth()
Return True if a is true, False otherwise.
- AssertionManager.length_hint(obj, default=0, /, **kwargs: ~typing.Any) None
Perform the following assertion:
assert length_hint(obj, default=default)
.- Parameters:
obj – The positional-only argument
obj
oflength_hint()
.default – The positional-only argument
default
oflength_hint()
.
- Keyword Arguments:
invert (
bool
) – IfTrue
, invert the output of the assertion:assert not length_hint(obj, default=default)
.exception (
type
[Exception
], optional) – Assert that exception is raised during/before the assertion operation.post_process (
Callable[[Any], bool]
, optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example values would be the likes ofany()
andall()
.message (
str
, optional) – A custom error message to-be passed to theassert
statement.
- Return type:
See also
length_hint()
Return an estimate of the number of items in obj. This is useful for presizing containers when building from an iterable. If the object supports len(), the result will be exact. Otherwise, it may over- or under-estimate by an arbitrary amount. The result will be an integer >= 0.
Assertions based on the builtin os.path
module
- AssertionManager.isabs(s, /, **kwargs: ~typing.Any) None
Perform the following assertion:
assert isabs(s)
.- Parameters:
s – The positional-only argument
s
ofisabs()
.- Keyword Arguments:
invert (
bool
) – IfTrue
, invert the output of the assertion:assert not isabs(s)
.exception (
type
[Exception
], optional) – Assert that exception is raised during/before the assertion operation.post_process (
Callable[[Any], bool]
, optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example values would be the likes ofany()
andall()
.message (
str
, optional) – A custom error message to-be passed to theassert
statement.
- Return type:
See also
isabs()
Test whether a path is absolute
- AssertionManager.isdir(s, /, **kwargs: ~typing.Any) None
Perform the following assertion:
assert isdir(s)
.- Parameters:
s – The positional-only argument
s
ofisdir()
.- Keyword Arguments:
invert (
bool
) – IfTrue
, invert the output of the assertion:assert not isdir(s)
.exception (
type
[Exception
], optional) – Assert that exception is raised during/before the assertion operation.post_process (
Callable[[Any], bool]
, optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example values would be the likes ofany()
andall()
.message (
str
, optional) – A custom error message to-be passed to theassert
statement.
- Return type:
See also
isdir()
Return true if the pathname refers to an existing directory.
- AssertionManager.isfile(path, /, **kwargs: ~typing.Any) None
Perform the following assertion:
assert isfile(path)
.- Parameters:
path – The positional-only argument
path
ofisfile()
.- Keyword Arguments:
invert (
bool
) – IfTrue
, invert the output of the assertion:assert not isfile(path)
.exception (
type
[Exception
], optional) – Assert that exception is raised during/before the assertion operation.post_process (
Callable[[Any], bool]
, optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example values would be the likes ofany()
andall()
.message (
str
, optional) – A custom error message to-be passed to theassert
statement.
- Return type:
See also
isfile()
Test whether a path is a regular file
- AssertionManager.islink(path, /, **kwargs: ~typing.Any) None
Perform the following assertion:
assert islink(path)
.- Parameters:
path – The positional-only argument
path
ofislink()
.- Keyword Arguments:
invert (
bool
) – IfTrue
, invert the output of the assertion:assert not islink(path)
.exception (
type
[Exception
], optional) – Assert that exception is raised during/before the assertion operation.post_process (
Callable[[Any], bool]
, optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example values would be the likes ofany()
andall()
.message (
str
, optional) – A custom error message to-be passed to theassert
statement.
- Return type:
See also
islink()
Test whether a path is a symbolic link
- AssertionManager.ismount(path, /, **kwargs: ~typing.Any) None
Perform the following assertion:
assert ismount(path)
.- Parameters:
path – The positional-only argument
path
ofismount()
.- Keyword Arguments:
invert (
bool
) – IfTrue
, invert the output of the assertion:assert not ismount(path)
.exception (
type
[Exception
], optional) – Assert that exception is raised during/before the assertion operation.post_process (
Callable[[Any], bool]
, optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example values would be the likes ofany()
andall()
.message (
str
, optional) – A custom error message to-be passed to theassert
statement.
- Return type:
See also
ismount()
Test whether a path is a mount point
Assertions based on the builtin math
module
- AssertionManager.allclose(a, b, /, *, rel_tol=1e-09, abs_tol=0.0, **kwargs: ~typing.Any) None
Perform the following assertion:
assert isclose(a, b, rel_tol=rel_tol, abs_tol=abs_tol)
.- Parameters:
- Keyword Arguments:
invert (
bool
) – IfTrue
, invert the output of the assertion:assert not isclose(a, b, rel_tol=rel_tol, abs_tol=abs_tol)
.exception (
type
[Exception
], optional) – Assert that exception is raised during/before the assertion operation.post_process (
Callable[[Any], bool]
, optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example values would be the likes ofany()
andall()
.message (
str
, optional) – A custom error message to-be passed to theassert
statement.
- Return type:
See also
isclose()
Determine whether two floating point numbers are close in value. rel_tol maximum difference for being considered “close”, relative to the magnitude of the input values abs_tol maximum difference for being considered “close”, regardless of the magnitude of the input values Return True if a is close in value to b, and False otherwise. For the values to be considered close, the difference between them must be smaller than at least one of the tolerances. -inf, inf and NaN behave similarly to the IEEE 754 Standard. That is, NaN is not close to anything, even itself. inf and -inf are only close to themselves.
- AssertionManager.isclose(a, b, /, *, rel_tol=1e-09, abs_tol=0.0, **kwargs: ~typing.Any) None
Perform the following assertion:
assert isclose(a, b, rel_tol=rel_tol, abs_tol=abs_tol)
.- Parameters:
- Keyword Arguments:
invert (
bool
) – IfTrue
, invert the output of the assertion:assert not isclose(a, b, rel_tol=rel_tol, abs_tol=abs_tol)
.exception (
type
[Exception
], optional) – Assert that exception is raised during/before the assertion operation.post_process (
Callable[[Any], bool]
, optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example values would be the likes ofany()
andall()
.message (
str
, optional) – A custom error message to-be passed to theassert
statement.
- Return type:
See also
isclose()
Determine whether two floating point numbers are close in value. rel_tol maximum difference for being considered “close”, relative to the magnitude of the input values abs_tol maximum difference for being considered “close”, regardless of the magnitude of the input values Return True if a is close in value to b, and False otherwise. For the values to be considered close, the difference between them must be smaller than at least one of the tolerances. -inf, inf and NaN behave similarly to the IEEE 754 Standard. That is, NaN is not close to anything, even itself. inf and -inf are only close to themselves.
- AssertionManager.isfinite(x, /, **kwargs: ~typing.Any) None
Perform the following assertion:
assert isfinite(x)
.- Parameters:
x – The positional-only argument
x
ofisfinite()
.- Keyword Arguments:
invert (
bool
) – IfTrue
, invert the output of the assertion:assert not isfinite(x)
.exception (
type
[Exception
], optional) – Assert that exception is raised during/before the assertion operation.post_process (
Callable[[Any], bool]
, optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example values would be the likes ofany()
andall()
.message (
str
, optional) – A custom error message to-be passed to theassert
statement.
- Return type:
See also
isfinite()
Return True if x is neither an infinity nor a NaN, and False otherwise.
- AssertionManager.isinf(x, /, **kwargs: ~typing.Any) None
Perform the following assertion:
assert isinf(x)
.- Parameters:
x – The positional-only argument
x
ofisinf()
.- Keyword Arguments:
invert (
bool
) – IfTrue
, invert the output of the assertion:assert not isinf(x)
.exception (
type
[Exception
], optional) – Assert that exception is raised during/before the assertion operation.post_process (
Callable[[Any], bool]
, optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example values would be the likes ofany()
andall()
.message (
str
, optional) – A custom error message to-be passed to theassert
statement.
- Return type:
See also
isinf()
Return True if x is a positive or negative infinity, and False otherwise.
- AssertionManager.isnan(x, /, **kwargs: ~typing.Any) None
Perform the following assertion:
assert isnan(x)
.- Parameters:
x – The positional-only argument
x
ofisnan()
.- Keyword Arguments:
invert (
bool
) – IfTrue
, invert the output of the assertion:assert not isnan(x)
.exception (
type
[Exception
], optional) – Assert that exception is raised during/before the assertion operation.post_process (
Callable[[Any], bool]
, optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example values would be the likes ofany()
andall()
.message (
str
, optional) – A custom error message to-be passed to theassert
statement.
- Return type:
See also
isnan()
Return True if x is a NaN (not a number), and False otherwise.
Assertions based on the builtin builtins
module
- AssertionManager.callable(obj, /, **kwargs: ~typing.Any) None
Perform the following assertion:
assert callable(obj)
.- Parameters:
obj – The positional-only argument
obj
ofcallable()
.- Keyword Arguments:
invert (
bool
) – IfTrue
, invert the output of the assertion:assert not callable(obj)
.exception (
type
[Exception
], optional) – Assert that exception is raised during/before the assertion operation.post_process (
Callable[[Any], bool]
, optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example values would be the likes ofany()
andall()
.message (
str
, optional) – A custom error message to-be passed to theassert
statement.
- Return type:
See also
callable()
Return whether the object is callable (i.e., some kind of function).
Note that classes are callable, as are instances of classes with a __call__() method.
- AssertionManager.hasattr(obj, name, /, **kwargs: ~typing.Any) None
Perform the following assertion:
assert hasattr(obj, name)
.- Parameters:
- Keyword Arguments:
invert (
bool
) – IfTrue
, invert the output of the assertion:assert not hasattr(obj, name)
.exception (
type
[Exception
], optional) – Assert that exception is raised during/before the assertion operation.post_process (
Callable[[Any], bool]
, optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example values would be the likes ofany()
andall()
.message (
str
, optional) – A custom error message to-be passed to theassert
statement.
- Return type:
See also
hasattr()
Return whether the object has an attribute with the given name.
This is done by calling getattr(obj, name) and catching AttributeError.
- AssertionManager.isinstance(obj, class_or_tuple, /, **kwargs: ~typing.Any) None
Perform the following assertion:
assert isinstance(obj, class_or_tuple)
.- Parameters:
obj – The positional-only argument
obj
ofisinstance()
.class_or_tuple – The positional-only argument
class_or_tuple
ofisinstance()
.
- Keyword Arguments:
invert (
bool
) – IfTrue
, invert the output of the assertion:assert not isinstance(obj, class_or_tuple)
.exception (
type
[Exception
], optional) – Assert that exception is raised during/before the assertion operation.post_process (
Callable[[Any], bool]
, optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example values would be the likes ofany()
andall()
.message (
str
, optional) – A custom error message to-be passed to theassert
statement.
- Return type:
See also
isinstance()
Return whether an object is an instance of a class or of a subclass thereof.
A tuple, as in
isinstance(x, (A, B, ...))
, may be given as the target to check against. This is equivalent toisinstance(x, A) or isinstance(x, B) or ...
etc.
- AssertionManager.issubclass(cls, class_or_tuple, /, **kwargs: ~typing.Any) None
Perform the following assertion:
assert issubclass(cls, class_or_tuple)
.- Parameters:
cls – The positional-only argument
cls
ofissubclass()
.class_or_tuple – The positional-only argument
class_or_tuple
ofissubclass()
.
- Keyword Arguments:
invert (
bool
) – IfTrue
, invert the output of the assertion:assert not issubclass(cls, class_or_tuple)
.exception (
type
[Exception
], optional) – Assert that exception is raised during/before the assertion operation.post_process (
Callable[[Any], bool]
, optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example values would be the likes ofany()
andall()
.message (
str
, optional) – A custom error message to-be passed to theassert
statement.
- Return type:
See also
issubclass()
Return whether ‘cls’ is a derived from another class or is the same class.
A tuple, as in
issubclass(x, (A, B, ...))
, may be given as the target to check against. This is equivalent toissubclass(x, A) or issubclass(x, B) or ...
etc.
- AssertionManager.len(obj, /, **kwargs: ~typing.Any) None
Perform the following assertion:
assert len(obj)
.- Parameters:
obj – The positional-only argument
obj
oflen()
.- Keyword Arguments:
invert (
bool
) – IfTrue
, invert the output of the assertion:assert not len(obj)
.exception (
type
[Exception
], optional) – Assert that exception is raised during/before the assertion operation.post_process (
Callable[[Any], bool]
, optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example values would be the likes ofany()
andall()
.message (
str
, optional) – A custom error message to-be passed to theassert
statement.
- Return type:
See also
len()
Return the number of items in a container.
- AssertionManager.any(iterable, /, **kwargs: ~typing.Any) None
Perform the following assertion:
assert any(iterable)
.- Parameters:
iterable – The positional-only argument
iterable
ofany()
.- Keyword Arguments:
invert (
bool
) – IfTrue
, invert the output of the assertion:assert not any(iterable)
.exception (
type
[Exception
], optional) – Assert that exception is raised during/before the assertion operation.post_process (
Callable[[Any], bool]
, optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example values would be the likes ofany()
andall()
.message (
str
, optional) – A custom error message to-be passed to theassert
statement.
- Return type:
See also
any()
Return True if bool(x) is True for any x in the iterable.
If the iterable is empty, return False.
- AssertionManager.all(iterable, /, **kwargs: ~typing.Any) None
Perform the following assertion:
assert all(iterable)
.- Parameters:
iterable – The positional-only argument
iterable
ofall()
.- Keyword Arguments:
invert (
bool
) – IfTrue
, invert the output of the assertion:assert not all(iterable)
.exception (
type
[Exception
], optional) – Assert that exception is raised during/before the assertion operation.post_process (
Callable[[Any], bool]
, optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example values would be the likes ofany()
andall()
.message (
str
, optional) – A custom error message to-be passed to theassert
statement.
- Return type:
See also
all()
Return True if bool(x) is True for all values x in the iterable.
If the iterable is empty, return True.
- AssertionManager.isdisjoint(a: ~typing.Iterable[~typing.Hashable], b: ~typing.Iterable[~typing.Hashable], /, **kwargs: ~typing.Any) None
Perform the following assertion:
assert isdisjoint(a, b)
.- Parameters:
a – The positional-only argument
a
ofisdisjoint()
.b – The positional-only argument
b
ofisdisjoint()
.
- Keyword Arguments:
invert (
bool
) – IfTrue
, invert the output of the assertion:assert not isdisjoint(a, b)
.exception (
type
[Exception
], optional) – Assert that exception is raised during/before the assertion operation.post_process (
Callable[[Any], bool]
, optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example values would be the likes ofany()
andall()
.message (
str
, optional) – A custom error message to-be passed to theassert
statement.
- Return type:
See also
isdisjoint()
Check if a has no elements in b.
- AssertionManager.issuperset(a: ~typing.Iterable[~typing.Hashable], b: ~typing.Iterable[~typing.Hashable], /, **kwargs: ~typing.Any) None
Perform the following assertion:
assert issuperset(a, b)
.- Parameters:
a – The positional-only argument
a
ofissuperset()
.b – The positional-only argument
b
ofissuperset()
.
- Keyword Arguments:
invert (
bool
) – IfTrue
, invert the output of the assertion:assert not issuperset(a, b)
.exception (
type
[Exception
], optional) – Assert that exception is raised during/before the assertion operation.post_process (
Callable[[Any], bool]
, optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example values would be the likes ofany()
andall()
.message (
str
, optional) – A custom error message to-be passed to theassert
statement.
- Return type:
See also
issuperset()
Check if a contains all elements from b.
- AssertionManager.issubset(a: ~typing.Iterable[~typing.Hashable], b: ~typing.Iterable[~typing.Hashable], /, **kwargs: ~typing.Any) None
Perform the following assertion:
assert issubset(a, b)
.- Parameters:
a – The positional-only argument
a
ofissubset()
.b – The positional-only argument
b
ofissubset()
.
- Keyword Arguments:
invert (
bool
) – IfTrue
, invert the output of the assertion:assert not issubset(a, b)
.exception (
type
[Exception
], optional) – Assert that exception is raised during/before the assertion operation.post_process (
Callable[[Any], bool]
, optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example values would be the likes ofany()
andall()
.message (
str
, optional) – A custom error message to-be passed to theassert
statement.
- Return type:
See also
issubset()
Check if b contains all elements in a.
- AssertionManager.round(number, /, *, ndigits=None, **kwargs: ~typing.Any) None
Perform the following assertion:
assert round(number, ndigits=ndigits)
.- Parameters:
- Keyword Arguments:
invert (
bool
) – IfTrue
, invert the output of the assertion:assert not round(number, ndigits=ndigits)
.exception (
type
[Exception
], optional) – Assert that exception is raised during/before the assertion operation.post_process (
Callable[[Any], bool]
, optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example values would be the likes ofany()
andall()
.message (
str
, optional) – A custom error message to-be passed to theassert
statement.
- Return type:
See also
round()
Round a number to a given precision in decimal digits.
The return value is an integer if ndigits is omitted or None. Otherwise the return value has the same type as the number. ndigits may be negative.
Miscellaneous assertions
- AssertionManager.len_eq(a: ~typing.Sized, b: int, /, **kwargs: ~typing.Any) None
Perform the following assertion:
assert len_eq(a, b)
.- Parameters:
- Keyword Arguments:
invert (
bool
) – IfTrue
, invert the output of the assertion:assert not len_eq(a, b)
.exception (
type
[Exception
], optional) – Assert that exception is raised during/before the assertion operation.post_process (
Callable[[Any], bool]
, optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example values would be the likes ofany()
andall()
.message (
str
, optional) – A custom error message to-be passed to theassert
statement.
- Return type:
See also
len_eq()
Check if the length of a is equivalent to b:
len(a) == b
.
- AssertionManager.str_eq(a: ~assertionlib.assertion_functions.T, b: str, /, *, str_converter: ~typing.Callable[[~assertionlib.assertion_functions.T], str] = <built-in function repr>, **kwargs: ~typing.Any) None
Perform the following assertion:
assert str_eq(a, b, str_converter=str_converter)
.- Parameters:
- Keyword Arguments:
invert (
bool
) – IfTrue
, invert the output of the assertion:assert not str_eq(a, b, str_converter=str_converter)
.exception (
type
[Exception
], optional) – Assert that exception is raised during/before the assertion operation.post_process (
Callable[[Any], bool]
, optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example values would be the likes ofany()
andall()
.message (
str
, optional) – A custom error message to-be passed to theassert
statement.
- Return type:
See also
str_eq()
Check if the string-representation of a is equivalent to b:
repr(a) == b
.
- AssertionManager.shape_eq(a: ndarray[Any, Any], b: ~typing.Union[ndarray[Any, Any], ~typing.Tuple[int, ...]], /, **kwargs: ~typing.Any) None
Perform the following assertion:
assert shape_eq(a, b)
.- Parameters:
a – The positional-only argument
a
ofshape_eq()
.b – The positional-only argument
b
ofshape_eq()
.
- Keyword Arguments:
invert (
bool
) – IfTrue
, invert the output of the assertion:assert not shape_eq(a, b)
.exception (
type
[Exception
], optional) – Assert that exception is raised during/before the assertion operation.post_process (
Callable[[Any], bool]
, optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example values would be the likes ofany()
andall()
.message (
str
, optional) – A custom error message to-be passed to theassert
statement.
- Return type:
See also
shape_eq()
Check if the shapes of a and b are equivalent:
a.shape == getattr(b, 'shape', b)
. b should be either an object with theshape
attribute (e.g. a NumPy array) or atuple
representing a valid array shape.
- AssertionManager.function_eq(func1: function, func2: function, /, **kwargs: ~typing.Any) None
Perform the following assertion:
assert function_eq(func1, func2)
.- Parameters:
func1 – The positional-only argument
func1
offunction_eq()
.func2 – The positional-only argument
func2
offunction_eq()
.
- Keyword Arguments:
invert (
bool
) – IfTrue
, invert the output of the assertion:assert not function_eq(func1, func2)
.exception (
type
[Exception
], optional) – Assert that exception is raised during/before the assertion operation.post_process (
Callable[[Any], bool]
, optional) – Apply post-processing to the to-be asserted data before asserting aforementioned data. Example values would be the likes ofany()
andall()
.message (
str
, optional) – A custom error message to-be passed to theassert
statement.
- Return type:
See also
function_eq()
Check if two functions are equivalent by checking if their
__code__
is identical. func1 and func2 should be instances ofFunctionType
or any other object with access to the__code__
attribute.