Classes | |
class | Information |
Functions | |
def | abort () |
def | check (exp, abort_if_failed=False) |
def | check_equal (result, expected, abort_if_failed=False) |
def | check_equal_lists (result, expected, abort_if_failed=False) |
def | check_exception (exception, expected_type, expected_msg=None, abort_if_failed=False) |
def | check_failed () |
def | check_frame_drops (frame, previous_frame_number, allowed_drops=1) |
def | check_test_in_progress (in_progress=True) |
def | fail () |
def | find_devices_by_product_line_or_exit (product_line) |
def | find_first_device_or_exit () |
def | finish () |
def | info (name, value, persistent=False) |
def | print_info () |
def | print_results_and_exit () |
def | print_separator () |
def | print_stack () |
def | reset_info (persistent=False) |
def | set_env_vars (env_vars) |
def | start (test_name) |
def | unexpected_exception () |
def | unreachable (abort_if_failed=False) |
Variables | |
int | n_assertions = 0 |
int | n_failed_assertions = 0 |
int | n_failed_tests = 0 |
int | n_tests = 0 |
bool | test_failed = False |
bool | test_in_progress = False |
dictionary | test_info = {} |
def rspy.test.check | ( | exp, | |
abort_if_failed = False |
|||
) |
def rspy.test.check_equal | ( | result, | |
expected, | |||
abort_if_failed = False |
|||
) |
Used for asserting a variable has the expected value :param result: The actual value of a variable :param expected: The expected value of the variable :param abort_if_failed: If True and assertion failed the test will be aborted :return: True if assertion passed, False otherwise
def rspy.test.check_equal_lists | ( | result, | |
expected, | |||
abort_if_failed = False |
|||
) |
Used to assert that 2 lists are identical. python "equality" (using ==) requires same length & elements but not necessarily same ordering. Here we require exactly the same, including ordering. :param result: The actual list :param expected: The expected list :param abort_if_failed: If True and assertion failed the test will be aborted :return: True if assertion passed, False otherwise
def rspy.test.check_exception | ( | exception, | |
expected_type, | |||
expected_msg = None , |
|||
abort_if_failed = False |
|||
) |
Used to assert a certain type of exception was raised, placed in the except block :param exception: The exception that was raised :param expected_type: The expected type of exception :param expected_msg: The expected message in the exception :param abort_if_failed: If True and assertion failed the test will be aborted :return: True if assertion passed, False otherwise
def rspy.test.check_failed | ( | ) |
def rspy.test.check_frame_drops | ( | frame, | |
previous_frame_number, | |||
allowed_drops = 1 |
|||
) |
Used for checking frame drops while streaming :param frame: Current frame being checked :param previous_frame_number: Number of the previous frame :param allowed_drops: Maximum number of frame drops we accept :return: False if dropped too many frames or frames were out of order, True otherwise
def rspy.test.fail | ( | ) |
def rspy.test.find_devices_by_product_line_or_exit | ( | product_line | ) |
:param product_line: The product line of the wanted devices :return: A list of devices of specific product line that was found, if no device is found the test is skipped. That way we can still run the unit-tests when no device is connected and not fail the tests that check a connected device
def rspy.test.find_first_device_or_exit | ( | ) |
def rspy.test.finish | ( | ) |
def rspy.test.info | ( | name, | |
value, | |||
persistent = False |
|||
) |
This function is used to store additional information to print in case of a failed test. This information is erased after the next check. The information is stored in the dictionary test_info, Keys are names (strings) and the items are of Information class If information with the given name is already stored it will be replaced :param name: The name of the variable :param value: The value this variable stores :param persistent: If this parameter is True, the information stored will be kept after the following check and will only be erased at the end of the test ( or when reset_info is called with True)
def rspy.test.print_results_and_exit | ( | ) |
def rspy.test.print_separator | ( | ) |
def rspy.test.print_stack | ( | ) |
def rspy.test.reset_info | ( | persistent = False | ) |
def rspy.test.set_env_vars | ( | env_vars | ) |
We want certain environment variables set when we get here. We assume they're not set. However, it is impossible to change the current running environment to see them. Instead, we rerun ourselves in a child process that inherits the environment we set. To do this, we depend on a specific argument in sys.argv that tells us this is the rerun (meaning child process). When we see it, we assume the variables are set and don't do anything else. For this to work well, the environment variable requirement (set_env_vars call) should appear as one of the first lines of the test. :param env_vars: A dictionary where the keys are the name of the environment variable and the values are the wanted values in string form (environment variables must be strings)
def rspy.test.start | ( | test_name | ) |
def rspy.test.unexpected_exception | ( | ) |
def rspy.test.unreachable | ( | abort_if_failed = False | ) |