Verify¶
Main module for supporting predicate-style assertions. Handles checking various state matches the desired outcome.
All verify types should be re-exported at discord.ext.test
, this is the primary
entry point for assertions in the library
- See also:
- class VerifyMessage¶
Builder for message verifications. When done building, should be asserted.
Example:
assert dpytest.verify().message().content("Hello World!")
- contains() VerifyMessage ¶
Only check whether content/embed list/etc contain the desired input, not that they necessarily match exactly
- Returns:
Self for chaining
- peek() VerifyMessage ¶
Don’t remove the verified message from the queue
- Returns:
Self for chaining
- nothing() VerifyMessage ¶
Check that no message was sent
- Returns:
Self for chaining
- content(content: str | None) VerifyMessage ¶
Check that the message content matches the input
- Parameters:
content – Content to match against, or None to ensure no content
- Returns:
Self for chaining
- embed(embed: Embed | None) VerifyMessage ¶
Check that the message embed matches the input
- Parameters:
embed – Embed to match against, or None to ensure no embed
- Returns:
Self for chaining
- attachment(attach: str | Path | None) VerifyMessage ¶
Check that the message attachment matches the input
- Parameters:
attach – Attachment path to match against, or None to ensure no attachment
- Returns:
Self for chaining
- class VerifyActivity¶
Builder for activity verifications. When done building, should be asserted
Example:
assert not dpytest.verify().activity().name("Foobar")
- matches(activity) VerifyActivity ¶
Ensure that the bot activity exactly matches the passed activity. Most restrictive possible check.
- Parameters:
activity – Activity to compare against
- Returns:
Self for chaining
- name(name: str) VerifyActivity ¶
Check that the activity name matches the input
- Parameters:
name – Name to match against
- Returns:
Self for chaining
- url(url: str) VerifyActivity ¶
Check the the activity url matches the input
- Parameters:
url – Url to match against
- Returns:
Self for chaining
-
type(type:
discord.ActivityType
) VerifyActivity ¶ Check the activity type matches the input
- Parameters:
type – Type to match against
- Returns:
Self for chaining
- class Verify¶
Base for all kinds of verification builders. Used as an intermediate step for the return of verify().
- __init__()¶
- message() VerifyMessage ¶
Verify a message
- Returns:
Message verification builder
- activity() VerifyActivity ¶
Verify the bot’s activity
- Returns:
Activity verification builder
- verify() Verify ¶
Verification entry point. Call to begin building a verification.
Warning: All verification builders do nothing until asserted, used in an if statement, or otherwise converted into a bool. They will raise RuntimeWarning if this isn’t done to help catch possible errors.
- Returns:
Verification builder