algebraixlib.util.test module

Test utilities.

algebraixlib.util.test.create_test_object(obj: object, msg: str, val: object = None) → object[source]

Add the content of msg and optionally val as properties to obj.

Parameters:
  • obj – The object to be ‘decorated’.
  • msg – Added as property ‘_test_msg’ to obj.
  • val – If present, added as property ‘_test_val’ to obj.
Returns:

The ‘decorated’ obj.

algebraixlib.util.test.assert_mathobjects(mo: algebraixlib.mathobjects.mathobject.MathObject) → bool[source]

Return True if and only if all elements in mo are instances of MathObject.

algebraixlib.util.test.get_test_file_name(test_module: str, file_id: str) → str[source]

Return the file name of a test file.

Test file names are composed of the test test_module file’s base name with an appended dash (‘-‘) and an identifying file_id. file_id should end with the desired file extension.

Parameters:
  • test_module – The name of the test to which the test file belongs. Typically this will be passed as __file__.
  • file_id – The identification of the file (final part of the name, including extension). This function guarantees that there are no conflicts with outher test modules.
algebraixlib.util.test.get_test_file_path(test_module: str, file_id: str) → str[source]

Return the (absolute) file path of a test file.

The file name is generated with get_test_file_name.

Parameters:
  • test_module – The name of the test to which the test file belongs. Typically this will be passed as __file__.
  • file_id – The identification of the file (final part of the name, including extension).