pyworkflow.tests.tests module

class pyworkflow.tests.tests.BaseTest(methodName='runTest')[source]

Bases: TestCase

Create an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.

assertIsNotEmpty(setObject, msg=None)[source]

Check if the pyworkflow object is not None nor is empty

assertSetSize(setObject, size=None, msg=None, diffDelta=None)[source]

Check if a pyworkflow Set is not None nor is empty, or of a determined size or of a determined size with a percentage (base 1) of difference

compareSetProperties(set1: Set, set2: Set, ignore=['_size', '_mapperPath'])[source]

Compares 2 sets’ properties

classmethod compareSets(test, set1, set2)[source]

Iterate the elements of both sets and check that all elements have equal attributes.

classmethod getOutputPath(*filenames)[source]

Return the path to the SCIPION_HOME/tests/output dir joined with filename

classmethod getRelPath(basedir, filename)[source]

Return the path relative to SCIPION_HOME/tests

classmethod launchProtocol(prot, **kwargs)[source]

Launch a given protocol using cls.proj.

  • wait – if True the function will return after the protocol runs. If not specified, then if waitForOutput is passed, wait is false.

  • waitForOutputs – a list of expected outputs, ignored if wait=True

classmethod newProtocol(protocolClass: T, **kwargs) T[source]

Create new protocols instances through the project and return a newly created protocol of the given class

static printLastLogLines(prot)[source]

Prints the last log lines (50 or ‘PROT_LOGS_LAST_LINES’ env variable) from stdout and stderr log files


prot – Protocol to take the logs from

classmethod saveProtocol(prot)[source]

Saves a protocol using cls.proj

classmethod setupTestOutput()[source]
class pyworkflow.tests.tests.DataSet(name, folder, files, url=None)[source]

Bases: object


#filesDict is dict with key, value pairs for each file

classmethod getDataSet(name)[source]

This method is called every time the dataset want to be retrieved

class pyworkflow.tests.tests.GTestResult[source]

Bases: TestResult

Subclass TestResult to output tests results with colors (green for success and red for failure) and write a report on an .xml file.

addError(test, err)[source]

Called when an error has occurred. ‘err’ is a tuple of values as returned by sys.exc_info().

addFailure(test, err)[source]

Called when an error has occurred. ‘err’ is a tuple of values as returned by sys.exc_info().


Called when a test has completed successfully

static getTestName(test)[source]
numberTests = 0
openXmlReport(classname, filename)[source]
reportError(test, err)[source]

Called when the given test is about to be run

testFailed = 0
xml = None
pyworkflow.tests.tests.hasLabel(TestClass, labels)[source]

Create the output folder for a give Test class.

pyworkflow.tests.tests.setupTestProject(cls, writeLocalConfig=False)[source]

Create and setup a Project for a give Test class.