taucmdr.tests package

Module contents

Unit test initializations and utility functions.

class taucmdr.tests.TestCase(methodName='runTest')[source]

Bases: unittest.case.TestCase

Base class for unit tests.

Performs tests in a temporary directory and reconfigures taucmdr.logger module to work with unittest.

assertCommandReturnValue(return_value, cmd, argv)[source]
assertCompiler(role, target_name='targ1')[source]
assertInLastTrialData(value, data_type='tau')[source]
assertManagedBuild(return_value, compiler_role, compiler_args, src)[source]
assertNotCommandReturnValue(return_value, cmd, argv)[source]
copy_testfile(src, dst=None)[source]
destroy_project_storage()[source]

Delete project storage.

Effectively the same as:

> rm -rf .tau
exec_command(cmd, argv)[source]

Execute a tau command’s main() routine and return the exit code, stdout, and stderr data.

Parameters:
  • cmd (type) – A command instance that has a main callable attribute.
  • argv (list) – Arguments to pass to cmd.main()
Returns:

(retval, stdout, stderr) results of running the command.

Return type:

tuple

getCompiler(role, target_name='targ1')[source]
reset_project_storage(init_args=None)[source]

Delete and recreate project storage.

Effectively the same as:

> rm -rf .tau
> tau initialize [init_args]
Parameters:init_args (list) – Command line arguments to tau initialize.
run(result=None)[source]
setUp() → None[source]
classmethod setUpClass()[source]
tearDown() → None[source]
classmethod tearDownClass()[source]
class taucmdr.tests.TestRunner(*args, **kwargs)[source]

Bases: unittest.runner.TextTestRunner

Test suite runner.

run(test)[source]
taucmdr.tests.cleanup()[source]

Checks that any files or directories created during testing have been removed.

taucmdr.tests.get_test_workdir()[source]

Return the current unit test’s working directory.

taucmdr.tests.not_implemented(cls)[source]

Decorator for TestCase classes to indicate that the tests have not been written (yet).

taucmdr.tests.pop_test_workdir()[source]

Recursively deletes the most recently created unit test working directory.

Restores the current working directory and tempfile.tempdir to their values before push_test_workdir was called.

taucmdr.tests.push_test_workdir()[source]

Create a new working directory for a unit test.

Sets the current working directory and tempfile.tempdir to the newly created test directory.

Directories created via this method are tracked. If any of them exist when the program exits then an error message is shown for each.

taucmdr.tests.skipUnlessHaveCompiler(role)[source]

Decorator to skip test functions when no compiler fills the given role.

If no installed compiler can fill this role then skip the test and report “<role> compiler not found”.

Parameters:role (_CompilerRole) – A compiler role.