Contents
Routines for testing WSGI applications.
Most interesting is the TestApp for testing WSGI applications, and the TestFileEnvironment class for testing the effects of command-line scripts.
Do a DELETE request. Very like the .get() method. params are put in the body of the request.
Returns a response object
Executes the given request (req), with the expected status. Generally .get() and .post() are used instead.
Encodes a set of parameters (typically a name/value list) and a set of files (a list of (name, filename, file_body)) into a typical POST body, returning the (content_type, body).
Get the given url (well, actually a path like '/page.html').
Returns a response object
Do a POST request. Very like the .get() method. params are put in the body of the request.
upload_files is for file uploads. It should be a list of [(fieldname, filename, file_content)]. You can also use just [(fieldname, filename)] and the file content will be read from disk.
Returns a response object
Do a PUT request. Very like the .get() method. params are put in the body of the request.
upload_files is for file uploads. It should be a list of [(fieldname, filename, file_content)]. You can also use just [(fieldname, filename)] and the file content will be read from disk.
Returns a response object
Resets the state of the application; currently just clears saved cookies.
This object represents a form that has been found in a page. This has a couple useful attributes:
Get the named/indexed field object, or default if no field is found.
Like .set(), except also confirms the target is a <select>.
Set the given name, using index to disambiguate.
Submits the form. If name is given, then also select that button (using index to disambiguate)``.
Any extra keyword arguments are passed to the .get() or .post() method.
Returns a response object.
Return a list of [(name, value), ...] for the current state of the form.
Field object.
Like setting a value, except forces it even for, say, hidden fields.
Field representing <select>
Field representing <input type="radio">
Field representing <input type="checkbox">
Field representing <input type="text">
Field representing <textarea>
Field representing <input type="hidden">
Field representing <input type="submit"> and <button>
This represents an environment in which files will be written, and scripts will be run.
Delete all the files in the base directory.
Run the command, with the given arguments. The script argument can have space-separated arguments, or you can use the positional arguments.
Keywords allowed are:
Returns a ProcResponse object.
Write a file to the given path. If content is given then that text is written, otherwise the file in frompath is used. frompath is relative to self.template_path
Represents the results of running a command in TestFileEnvironment.
Attributes to pay particular attention to:
Represents a single file found as the result of a command.
Has attributes:
You may use the in operator with these objects (tested against the contents of the file), and the .mustcontain() method.
Represents a directory created by a command.