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:

discord.ext.test.runner

class VerifyMessage

Builder for message verifications. When done building, should be asserted.

Example: assert testcord.verify().message().content("Hello World!")

__init__() None
contains() discord.ext.test.verify.VerifyMessage

Only check whether content/embed list/etc contain the desired input, not that they necessarily match exactly

Returns

Self for chaining

peek() discord.ext.test.verify.VerifyMessage

Don’t remove the verified message from the queue

Returns

Self for chaining

nothing() discord.ext.test.verify.VerifyMessage

Check that no message was sent

Returns

Self for chaining

content(content: Optional[str]) discord.ext.test.verify.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: Optional[discord.Embed]) discord.ext.test.verify.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: Optional[Union[str, pathlib.Path]]) discord.ext.test.verify.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 testcord.verify().activity().name("Foobar")

__init__() None
matches(activity) discord.ext.test.verify.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) discord.ext.test.verify.VerifyActivity

Check that the activity name matches the input

Parameters

name – Name to match against

Returns

Self for chaining

url(url: str) discord.ext.test.verify.VerifyActivity

Check the the activity url matches the input

Parameters

url – Url to match against

Returns

Self for chaining

type(type: discord.ActivityType) discord.ext.test.verify.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() discord.ext.test.verify.VerifyMessage

Verify a message

Returns

Message verification builder

activity() discord.ext.test.verify.VerifyActivity

Verify the bot’s activity

Returns

Activity verification builder

verify() discord.ext.test.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