nti.schema.testing¶
nti.schema.testing has moved to nti.testing.matchers.
-
has_length
(match)[source]¶ Matches if
len(item)
satisfies a given matcher.Parameters: match – The matcher to satisfy, or an expected value for equal_to()
matching.This matcher invokes the
len()
function on the evaluated object to get its length, passing the result to a given matcher for evaluation.If the
match
argument is not a matcher, it is implicitly wrapped in anequal_to()
matcher to check for :equality.Examples:
has_length(greater_than(6)) has_length(5)
-
has_attr
(name, match=None)¶ Matches if object has a property with a given name whose value satisfies a given matcher.
Parameters: - name – The name of the property.
- match – Optional matcher to satisfy.
This matcher determines if the evaluated object has a property with a given name. If no such property is found,
has_property
is not satisfied.If the property is found, its value is passed to a given matcher for evaluation. If the
match
argument is not a matcher, it is implicitly wrapped in anequal_to()
matcher to check for equality.If the
match
argument is not provided, theanything()
matcher is used so thathas_property
is satisfied if a matching property is found.Examples:
has_property('name', starts_with('J')) has_property('name', 'Jon') has_property('name')
-
verifiably_provides
(*ifaces)[source]¶ Matches if the object verifiably provides the correct interface(s), as defined by
zope.interface.verify.verifyObject()
. This means having the right attributes and methods with the right signatures.Note
This does not test schema compliance. For that (stricter) test, see
validly_provides()
.
-
validly_provides
(*ifaces)[source]¶ Matches if the object verifiably and validly provides the given schema (interface(s)).
Verification is done with
zope.interface
andverifiably_provides()
, while validation is done withzope.schema.getValidationErrors()
.
-
implements
(iface)[source]¶ Matches if the object implements (is a factory for) the given interface.
See also
zope.interface.interfaces.ISpecification.implementedBy()
-
validated_by
(field, invalid=<class 'zope.interface.exceptions.Invalid'>)[source]¶ Matches if the data is validated by the given
IField
.Parameters: invalid (exception) – The types of exceptions that are considered invalid. Anything other than this is allowed to be raised. Changed in version 2.0.1: Add
invalid
and change it fromException
tozope.interface.interfaces.Invalid
-
not_validated_by
(field, invalid=<class 'zope.interface.exceptions.Invalid'>)[source]¶ Matches if the data is NOT validated by the given IField.
Parameters: invalid (exception) – The types of exceptions that are considered invalid. Anything other than this is allowed to be raised. Changed in version 2.0.1: Add
invalid
and change it fromException
tozope.interface.interfaces.Invalid