Skip to content

Supybot Website

Sections
Personal tools
You are here: Home » Documentation » Supybot Help Center » Tutorials » Advanced Plugin Testing » Plugin Test Methods

Plugin Test Methods

Document Actions
The full list of test methods and how to use them.

Strike

The complete guide to writing tests for your plugins.
Page 3 of 4.

Introduction

You know how to make plugin test case classes and you know how to do just about everything with them except to actually test stuff. Well, listed below are all of the assertions used in tests. If you're unfamiliar with what an assertion is in code testing, it is basically a requirement of something that must be true in order for that test to pass. It's a necessary condition. If any assertion within a test method fails the entire test method fails and it goes on to the next one.

Assertions

All of these are methods of the plugin test classes themselves and hence are accessed by using self.assertWhatever in your test methods. These are sorted in order of relative usefulness.

  • assertResponse(query, expectedResponse) - Feeds query to the bot as a message and checks to make sure the response is expectedResponse. The test fails if they do not match (note that prefixed nicks in the response do not need to be included in the expectedResponse).
  • assertError(query) - Feeds query to the bot and expects an error in return. Fails if the bot doesn't return an error.
  • assertNotError(query) - The opposite of assertError. It doesn't matter what the response to query is, as long as it isn't an error. If it is not an error, this test passes, otherwise it fails.
  • assertRegexp(query, regexp, flags=re.I) - Feeds query to the bot and expects something matching the regexp (no m// required) in regexp with the supplied flags. Fails if the regexp does not match the bot's response.
  • assertNotRegexp(query, regexp, flags=re.I) - The opposite of assertRegexp. Fails if the bot's output matches regexp with the supplied flags.
  • assertHelp(query) - Expects query to return the help for that command. Fails if the command help is not triggered.
  • assertAction(query, expectedResponse=None) - Feeds query to the bot and expects an action in response, specifically expectedResponse if it is supplied. Otherwise, the test passes for any action response.
  • assertActionRegexp(query, regexp, flags=re.I) - Basically like assertRegexp but carries the extra requirement that the response must be an action or the test will fail.

Utilities

  • feedMsg(query, to=None, frm=None) - Simply feeds query to whoever is specified in to or to the bot itself if no one is specified. Can also optionally specify the hostmask of the sender with the frm keyword. Does not actually perform any assertions.
  • getMsg(query) - Feeds query to the bot and gets the response.
Created by Strike
Contributors : Strike
Last modified 02:04 December 06, 2005
 

Powered by Plone

This site conforms to the following standards: