Factories#
Test factories: they create objects for testing purposes.
New in version 7.0.
- class sopel.tests.factories.BotFactory#
 Factory to create bot.
See also
The
botfactory()fixture can be used to instantiate this factory.- preloaded(
 - settings: config.Config,
 - preloads: Iterable[str] | None = None,
 Create a bot and preload its plugins.
- Parameters:
 settings (
sopel.config.Config) – Sopel’s configuration for testing purposespreloads (list) – list of plugins to preload, setup, and register
- Returns:
 a test instance of the bot
- Return type:
 
This will instantiate a
Sopelobject, replace its backend with aMockIRCBackend, and then preload plugins. This will automatically load thecoretasksplugin, and every other plugin frompreloads:factory = BotFactory() bot = factory.preloaded(settings, ['emoticons', 'remind'])
Note
This will automatically setup plugins: be careful with plugins that require access to external services on setup.
You may also need to manually call shutdown routines for the loaded plugins.
- class sopel.tests.factories.ConfigFactory(tmpdir)#
 Factory to create settings.
See also
The
configfactory()fixture can be used to instantiate this factory.
- class sopel.tests.factories.IRCFactory#
 Factory to create mock IRC server.
See also
The
ircfactory()fixture can be used to create this factory.
- class sopel.tests.factories.TriggerFactory#
 Factory to create trigger.
See also
The
triggerfactory()fixture can be used to instantiate this factory.
- class sopel.tests.factories.UserFactory#
 Factory to create mock user.
See also
The
userfactory()fixture can be used to create this factory.