colorful_test.testcase.TestCase#

class colorful_test.testcase.TestCase#

Base class that implements the interface needed by the runner to allow it do drive the tests, and methods that the test code can use to check for and report various kinds of failures.

__init__()#

Methods

__init__()

add_cleanup(function, *args, **kwargs)

Add a function to be called after tear_down() to clean up resources used during the test.

assert_almost_equal(first, second[, places])

Test that first and second are approximately equal by computing the difference, rounding to the given number of decimal places (default 7), and comparing to zero.

assert_count_equal(first, second)

Test that sequence first contains the same elements as second, regardless of their order.

assert_dict_equal(first, second)

Test that two dictionaries are equal.

assert_does_not_raises(exception, callable, ...)

Test that an exception (specific) is not raised when callable is called with any positional or keyword arguments.

assert_equal(first, second)

Test that first and second are equal.

assert_false(expr)

Test that expr is False.

assert_greater(first, second)

Test that first is > than the second.

assert_greater_equal(first, second)

Test that first is >= than the second.

assert_in(first, second)

Test that first is in second.

assert_is(first, second)

Test that first and second evaluate to the same object.

assert_is_instance(obj, cls)

Test that obj is an instance of cls.

assert_is_none(expr)

Test that expr is None.

assert_is_not(first, second)

Test that first and second does not evaluate to the same object.

assert_is_not_none(expr)

Test that expr is not None.

assert_less(first, second)

Test that first is < than the second.

assert_less_equal(first, second)

Test that first is <= than the second.

assert_list_equal(first, second)

Test that two lists are equal.

assert_not_almost_equal(first, second[, places])

Test that first and second are not approximately equal by computing the difference, rounding to the given number of decimal places (default 7), and comparing to zero.

assert_not_equal(first, second)

Test that first and second are not equal.

assert_not_in(first, second)

Test that first is not in second.

assert_not_is_instance(obj, cls)

Test that obj is not an instance of cls.

assert_not_regex(text, regex)

Test that a regex search does not math the text.

assert_raises(exception, callable, *args, ...)

Test that an exception (specific) is raised when callable is called with any positional or keyword arguments.

assert_raises_regex(exception, regex, ...)

Like assert_raises() but also tests that regex matches on the string representation of the raised exception.

assert_regex(text, regex)

Test that a regex search matches the text.

assert_sequence_equal(first, second[, seq_type])

Test that two sequences are equal.

assert_set_equal(first, second)

Test that two sets are equal.

assert_true(expr)

Test that expr is True.

assert_tuple_equal(first, second)

Test that two tuples are equal.

do_cleanups()

The method is called unconditionally after tear_down(), or after set_up() if set_up() raises an exception.

final_message()

This method is called after tests in an individual class run.

run([fail_fast])

Run the tests, collecting the results into TestResult object.

run_and_output_results([fail_fast, show_grade])

set_up()

This method is called immediately before calling a test method; other than AssertionError or SkipTest, any exception raised by this method will be considered an error rather than a test failure.

set_up_class()

This method is called before tests in an individual class run.

tear_down()

This method is called immediately after calling a test method; other than AssertionError or SkipTest, any exception raised by this method will be considered an error rather than a test failure.

tear_down_class()

This method is called after tests in an individual class run.