symforce.test_util.test_case_mixin module¶
- class SymforceTestCaseMixin(methodName='runTest')[source]¶
Bases:
TestCase
Mixin for SymForce tests, adds useful helpers for code generation
- Parameters:
methodName (str) –
- KEEP_PATHS = ['.*/__pycache__/.*', '.*\\.pyc']¶
- static assertStorageNear(actual, desired, *, places=7, msg='', verbose=True)[source]¶
Check that two elements are close. Handles sequences, scalars, and geometry types using StorageOps.
- static assertLieGroupNear(actual, desired, *, places=7, msg='', verbose=True)[source]¶
Check that two LieGroup elements are close.
- static assertArrayEqual(actual, desired, msg='')[source]¶
Called by unittest base class when comparing ndarrays when “assertEqual” is called. By default, “assertEqual” uses the “==” operator, which is not implemented for ndarrays.
- assertNotEqual(first, second, msg='')[source]¶
Overrides unittest.assertNotEqual to handle ndarrays separately. “assertNotEqual” uses the “!=” operator, but this is not implemented for ndarrays. Instead, we check that np.testing.assert_array_equal raises an assertion error, as numpy testing does not provide a assert_array_not_equal function.
Note that assertNotEqual does not work like assertEqual in unittest. Rather than allowing you to register a custom equality evaluator (e.g. with
addTypeEqualityFunc()
), assertNotEqual assumes the “!=” can be used with the arguments regardless of type.
- make_output_dir(prefix=None, directory=PosixPath('/tmp'))[source]¶
Create a temporary output directory, which will be automatically removed (regardless of exceptions) on shutdown, unless logger.level is DEBUG
- Parameters:
- Returns:
str – The absolute path to the created output directory
- Return type:
- setUp()[source]¶
Creates list of temporary directories that will be removed before shutdown (unless debug mode is on)
- Return type:
None
- tearDown()[source]¶
Removes temporary output directories (unless debug mode is on)
- Return type:
None
- compare_or_update(path, data)[source]¶
Compare the given data to what is saved in path, OR update the saved data if the
--update
flag was passed to the test.