RepoBee Module Reference

This is the public API of the repobee module, which is primarily intended for testing of plugins, but could also be used to execute RepoBee from a Python script. For the internal API of the _repobee package, please see the msource code.

repobee

repobee.run(cmd, config_file='', plugins=None, workdir='.')[source]

Run RepoBee with the provided options. This function is mostly intended to be used for testing plugins.

Important

This function will always unregister all plugins after execution, including anly plugins that may have been registered prior to running this function.

Running this function is almost equivalent to running RepoBee from the CLI, with the following exceptions:

  1. Preparser options must be passed as arguments to this function (i.e. cannot be given as part of cmd).

  2. There is no error handling at the top level, so exceptions are raised instead of just logged.

As an example, the following CLI call:

$ repobee --plug ext.py --config-file config.ini config show

Can be executed as follows:

import ext
from repobee import run

run(["config", "show"], config_file="config.ini", plugins=[ext])
Parameters
  • cmd (List[str]) – The command to run.

  • config_file (Union[str, Path]) – Path to the configuration file.

  • plugins (Optional[List[Union[module, Plugin]]]) – A list of plugin modules and/or plugin classes.

  • workdir (Union[str, Path]) – The working directory to run RepoBee in.

Return type

Mapping[str, List[Result]]

Returns

A mapping (plugin_name -> plugin_results).

repobee.try_register_plugin(plugin_module, *plugin_classes)[source]

Attempt to register a plugin module and then immediately unregister it.

Important

This is a convenience method for sanity checking plugins, and should only be called in test suites. It’s not for production use.

This convenience method can be used to sanity check plugins by registering them with RepoBee. If they have incorrectly defined hooks, this will be discovered only when registering.

As an example, assume that we have a plugin module with a single (useless) plugin class in it, like this:

useless.py
import repobee_plug as plug

class Useless(plug.Plugin):
    """This plugin does nothing!"""

We want to make sure that both the useless module and the Useless plugin class are registered correctly, and for that we can write some simple code like this.

Example test case to check registering
import repobee
# assuming that useless is defined in the external plugin
# repobee_useless
from repobee_useless import useless

def test_register_useless_plugin():
    repobee.try_register_plugin(useless, useless.Useless)
Parameters
  • plugin_module (module) – A plugin module.

  • plugin_classes (List[type]) – If the plugin contains any plugin classes (i.e. classes that extend repobee_plug.Plugin), then these must be provided here. Otherwise, this option should not be provided.

Raises
  • repobee_plug.PlugError

  • or if the contained plugin classes does not match

  • plugin_classes.

Return type

None

repobee.unregister_all_plugins()[source]

Unregister all currently registered plugins.

Return type

None