wuttjamaican.testing

WuttJamaican - test utilities

class wuttjamaican.testing.ConfigTestCase(methodName='runTest')[source]

Base class for test suites requiring a config object.

It inherits from FileTestCase so also has the file-related methods.

The running test has these attributes:

config

Reference to the config object.

app

Reference to the app handler.

Note

If you subclass this directly and need to override setup/teardown, please be sure to call the corresponding methods for this class.

setup_config()[source]

Perform config setup operations for the test.

teardown_config()[source]

Perform config teardown operations for the test.

class wuttjamaican.testing.DataTestCase(methodName='runTest')[source]

Base class for test suites requiring a full (typical) database.

It inherits from FileTestCase so also has the file-related methods.

This uses a SQLite in-memory database and creates all tables for the app model. The running test has these attributes:

config

Reference to the config object.

app

Reference to the app handler.

session

Open session for the test DB.

Note

If you subclass this and need to override setup/teardown, please be sure to call the corresponding methods for this class.

However you do not need to call the file-related setup or teardown methods, as this class handles that automatically.

setup_db()[source]

Perform config/app/db setup operations for the test.

teardown_db()[source]

Perform config/app/db teardown operations for the test.

wuttjamaican.testing.FileConfigTestCase

alias of FileTestCase

class wuttjamaican.testing.FileTestCase(methodName='runTest')[source]

Base class for test suites which (may) write temporary files, for sake of testing the config constructor etc. It inherits from unittest.TestCase.

This class creates a temporary folder on setup, and removes it on teardown. See below for features exposed to work with the folder.

tempdir

Path to the temporary folder created during setup.

Note

If you subclass this and need to override setup/teardown, please be sure to call the corresponding methods for this class.

mkdir(dirname)[source]

Make a new temporary folder and return its path.

Note that this will be created underneath tempdir.

setup_files()[source]

This creates the temporary folder.

teardown_files()[source]

This removes the temporary folder.

write_file(filename, content)[source]

Write a new file (in temporary folder) with the given filename and content, and return its full path. For instance:

myconf = self.write_file('my.conf', '<file contents>')