class
StepTestCase
cauldron.steptest.StepTestCase

The base class to use for step "unit" testing. This class overrides the default setup and tearDown methods from the unittest.TestCase to add functionality for loading and unloading the Cauldron notebook settings needed to run and test steps. If you override either of these methods make sure that you call their super methods as well or the functionality will be lost.

info_outline
The StepTestCase class inherits from Python's TestCase class. All standard testing functionality available within this class is available for step testing.
warning
Test files that use the StepTestCase class must be located somewhere within the root directory of the Cauldron notebook for which the tests are written.
Methods
def
run_step

Runs the specified step by name its complete filename including extension

Arguments
Required
Optional
step_name

str

The full filename of the step to be run including its extension.

allow_failure

bool

Whether or not to allow a failed result to be returned. If False, a failed attempt to run a step will cause the current test to fail immediately before returning a value from this function call. Override this with a True value to have the step failure data passed back for inspection.

Default Value: 

False

Returns

StepTestRunResult

A StepTestRunResult instance containing information about the execution of the step.

Basic Usage
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
import cauldron as cd import pandas as pd from cauldron.steptest import StepTestCase class TestSecondStep(StepTestCase): """ Class for testing the second step in the notebook """ def test_missing_column(self): """ should not fail if the data frame is missing the "b" column """ # Create a test data frame that has an "a" column but no "b" column cd.shared.df = pd.DataFrame(dict(a=[12, 24, 36])) # Run the step result = self.run_step("S02-Merge-Columns.py") # Validate that the step ran successfully self.assertTrue(result.success)
Examples