toil.test.lib.test_conversions

Attributes

logger

Classes

ToilTest

A common base class for Toil tests.

ConversionTest

A common base class for Toil tests.

Functions

convert_units(num, src_unit[, dst_unit])

Returns a float representing the converted input in dst_units.

hms_duration_to_seconds(hms)

Parses a given time string in hours:minutes:seconds,

human2bytes(string)

Given a string representation of some memory (i.e. '1024 Mib'), return the

Module Contents

toil.test.lib.test_conversions.convert_units(num, src_unit, dst_unit='B')[source]

Returns a float representing the converted input in dst_units.

Parameters:
Return type:

float

toil.test.lib.test_conversions.hms_duration_to_seconds(hms)[source]

Parses a given time string in hours:minutes:seconds, returns an equivalent total seconds value

Parameters:

hms (str)

Return type:

float

toil.test.lib.test_conversions.human2bytes(string)[source]

Given a string representation of some memory (i.e. ‘1024 Mib’), return the integer number of bytes.

Parameters:

string (str)

Return type:

int

class toil.test.lib.test_conversions.ToilTest(methodName='runTest')[source]

Bases: unittest.TestCase

A common base class for Toil tests.

Please have every test case directly or indirectly inherit this one.

When running tests you may optionally set the TOIL_TEST_TEMP environment variable to the path of a directory where you want temporary test files be placed. The directory will be created if it doesn’t exist. The path may be relative in which case it will be assumed to be relative to the project root. If TOIL_TEST_TEMP is not defined, temporary files and directories will be created in the system’s default location for such files and any temporary files or directories left over from tests will be removed automatically removed during tear down. Otherwise, left-over files will not be removed.

setup_method(method)[source]
Parameters:

method (Any)

Return type:

None

classmethod setUpClass()[source]

Hook method for setting up class fixture before running tests in the class.

Return type:

None

classmethod tearDownClass()[source]

Hook method for deconstructing the class fixture after running all tests in the class.

Return type:

None

setUp()[source]

Hook method for setting up the test fixture before exercising it.

Return type:

None

tearDown()[source]

Hook method for deconstructing the test fixture after testing it.

Return type:

None

classmethod awsRegion()[source]

Pick an appropriate AWS region.

Use us-west-2 unless running on EC2, in which case use the region in which the instance is located

Return type:

str

toil.test.lib.test_conversions.logger
class toil.test.lib.test_conversions.ConversionTest(methodName='runTest')[source]

Bases: toil.test.ToilTest

A common base class for Toil tests.

Please have every test case directly or indirectly inherit this one.

When running tests you may optionally set the TOIL_TEST_TEMP environment variable to the path of a directory where you want temporary test files be placed. The directory will be created if it doesn’t exist. The path may be relative in which case it will be assumed to be relative to the project root. If TOIL_TEST_TEMP is not defined, temporary files and directories will be created in the system’s default location for such files and any temporary files or directories left over from tests will be removed automatically removed during tear down. Otherwise, left-over files will not be removed.

test_convert()[source]
test_human2bytes()[source]
test_hms_duration_to_seconds()[source]