API Reference¶
TestCase¶
-
class
fluenttest.test_case.
TestCase
[source]¶ Arrange, Act, Assert test case.
Sub-classes implement test cases by arranging the environment in the
arrange()
class method, perform the action in theact()
class method, and implement assertions as test methods. The individual assertion methods have to be written in such a way that the test runner in use finds them.-
allowed_exceptions
¶ The exception or list of exceptions that the test case is interested in capturing. An exception raised from
act()
will be stored inexception
.
-
exception
¶ The exception that was thrown during the action or
None
.
-
allowed_exceptions
= ()¶ Catch this set of exception classes.
-
classmethod
arrange
()[source]¶ Arrange the testing environment.
Concrete test classes will probably override this method and should invoke this implementation via
super()
.
-
classmethod
destroy
()[source]¶ Perform post-test cleanup.
Concrete tests classes may override this method if there are actions that need to be performed after
act()
is called. Subclasses should invoke this implementation viasuper()
.This method is guaranteed to be called after the action under test is invoked and before
teardown_class()
. It will be called after any captured exception has been caught.
-
classmethod
patch
(target, **kwargs)[source]¶ Patch a named class or method.
Parameters: target (str) – the dotted-name to patch Returns: the result of starting the patch. This method calls
mock.patch()
with target and **kwargs, saves the result, and returns the running patch.
-
classmethod
patch_instance
(target, **kwargs)[source]¶ Patch a named class and return the created instance.
Parameters: target (str) – the dotted-name of the class to patch Returns: tuple of (patched class, patched instance) This method calls
patch()
with **kwargs to patch target and returns a tuple containing the patched class as well as thereturn_value
attribute of the patched class. This is useful if you want to patch a class and manipulate the result of the code under test creating an instance of the class.
-
classmethod
setUpClass
()[source]¶ Arrange the environment and perform the action.
This method ensures that
arrange()
andact()
are invoked exactly once before the assertions are fired. If you do find the need to extend this method, you should call this implementation as the last statement in your extension method as it will perform the action under test when it is called.
-