sourcefinder.testutil.decorators#

Functions#

duration(test_duration)

Decorator to skip a test if its duration exceeds the maximum

high_ram_requirements()

Decorator to disable tests that break Travis due to

requires_data(*args)

Decorator to skip a test if required data files are not

requires_database()

Decorator to skip a test if database functionality is

requires_module(module_name)

Decorator to skip a test if a required module is not

requires_test_db_managed()

Decorator to disable tests that perform potentially low-level

Module Contents#

sourcefinder.testutil.decorators.duration(test_duration)[source]#

Decorator to skip a test if its duration exceeds the maximum allowed duration.

This function checks the environment variable TKP_MAXTESTDURATION to determine the maximum allowed test duration. If the test’s duration exceeds this value, the test is skipped with an appropriate message.

Parameters:
test_durationfloat

The duration of the test in seconds.

Returns:
function

A decorator that either skips the test or allows it to run.

sourcefinder.testutil.decorators.high_ram_requirements()[source]#

Decorator to disable tests that break Travis due to out-of-memory issues.

This function checks the TRAVIS environment variable to determine if the tests are running in a Travis CI environment. If so, tests with high RAM requirements are skipped with an appropriate message.

Returns:
function

A decorator that either skips the test or allows it to run.

sourcefinder.testutil.decorators.requires_data(*args)[source]#

Decorator to skip a test if required data files are not available.

This function checks for the existence of the specified data files. If any of the files do not exist, the test is skipped with an appropriate message.

Parameters:
*argsstr

Variable-length argument list of file paths to check.

Returns:
function

A decorator that either skips the test or allows it to run.

sourcefinder.testutil.decorators.requires_database()[source]#

Decorator to skip a test if database functionality is disabled.

This function checks the environment variable TKP_DISABLEDB. If it is set to a truthy value, the test is skipped with an appropriate message.

Returns:
function

A decorator that either skips the test or allows it to run.

sourcefinder.testutil.decorators.requires_module(module_name)[source]#

Decorator to skip a test if a required module is not available.

This function attempts to import the specified module. If the module cannot be imported, the test is skipped with an appropriate message.

Parameters:
module_namestr

The name of the module to check for availability.

Returns:
function

A decorator that either skips the test or allows it to run.

sourcefinder.testutil.decorators.requires_test_db_managed()[source]#

Decorator to disable tests that perform potentially low-level database management operations, such as destroying and creating databases.

This decorator checks the environment variables to determine whether such tests should be enabled or skipped:

  • If the TKP_DBENGINE environment variable is set to ‘monetdb’, the test is skipped because database management tests are not supported for MonetDB and must be tested manually.

  • If the TKP_TESTDBMANAGEMENT environment variable is set, the test is allowed to run.

  • Otherwise, the test is skipped with an appropriate message.

Returns:
function

A decorator that either skips the test or allows it to run.