Cement testing utilities.

class cement.utils.test.CementTestCase(*args, **kw)

Bases: unittest.case.TestCase

A sub-class of unittest.TestCase.


The test class that is used by self.make_app to create an app.

alias of TestApp

eq(a, b, msg=None)

Shorthand for ‘assert a == b, “%r != %r” % (a, b)’.

make_app(*args, **kw)

Create a generic app using TestApp. Arguments and Keyword Arguments are passed to the app.

ok(expr, msg=None)

Shorthand for assert.


Remove all registered hooks and handlers from the backend.


Sets up self.app with a generic TestApp(). Also resets the backend hooks and handlers so that everytime an app is created it is setup clean each time.

class cement.utils.test.TestApp(label=None, **kw)

Bases: cement.core.foundation.CementApp

Basic CementApp for generic testing.

class Meta
argv = []
config_files = []
label = 'test'
class cement.utils.test.raises

Test must raise one of expected exceptions to pass.

Example use:

@raises(TypeError, ValueError)
def test_raises_type_error():
    raise TypeError("This test passes")

def test_that_fails_by_passing():

If you want to test many assertions about exceptions in a single test, you may want to use assert_raises instead.

cement.utils.test.ok(expr, msg=None)

Shorthand for assert. Saves 3 whole characters!

cement.utils.test.eq(a, b, msg=None)

Shorthand for ‘assert a == b, “%r != %r” % (a, b)

Previous topic


Next topic


This Page