tbplas.TestHelper

class tbplas.TestHelper(tester: TestCase)

Helper class that makes unittest easier.

_tester

testcase upon which tests are performed

Type:

‘unittest.TestCase’ instance

__init__(tester: TestCase) None
Parameters:

tester – testcase upon which tests are performed

Methods

__init__(tester)

param tester:

testcase upon which tests are performed

test_equal_array(array1, array2[, almost, delta])

Checks if two arrays are equal to each other.

test_no_equal_array(array1, array2[, ...])

Checks if two arrays are not equal to each other.

test_no_raise(func, exception)

Tests if expected exception is not raised during an operation.

test_raise(func, exception, message)

Tests if expected exception is raised during an operation.

test_stdout(func, message)

Test if the output contain given message.

__init__(tester: TestCase) None
Parameters:

tester – testcase upon which tests are performed

test_equal_array(array1: ndarray, array2: ndarray, almost: bool = False, delta: float = 1e-07) None

Checks if two arrays are equal to each other.

Parameters:
  • array1 – 1st array to compare

  • array2 – 2nd array to compare

  • almost – whether to compare according to difference

  • delta – threshold for difference

Returns:

None.

test_no_equal_array(array1: ndarray, array2: ndarray, almost: bool = False, delta: float = 1e-07) None

Checks if two arrays are not equal to each other.

Parameters:
  • array1 – 1st array to compare

  • array2 – 2nd array to compare

  • almost – whether to compare according to difference

  • delta – threshold for difference

Returns:

None.

test_no_raise(func: Callable, exception: Any) None

Tests if expected exception is not raised during an operation.

Parameters:
  • func – wrapper function over the operation to test

  • exception – category of exception to test

Returns:

None

test_raise(func: Callable, exception: Any, message: str) None

Tests if expected exception is raised during an operation.

Parameters:
  • func – wrapper function over the operation to test

  • exception – category of exception to test

  • message – expected exception message

Returns:

None

test_stdout(func: Callable, message: List[str]) None

Test if the output contain given message.

Parameters:
  • func – wrapper function over the operation to test

  • message – reference message with which to compare, each regex corresponds to one line of output

Returns:

None

__weakref__

list of weak references to the object (if defined)