Classes | Functions | Variables
rspy.test Namespace Reference

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 = {}
 

Function Documentation

def rspy.test.abort ( )

Definition at line 132 of file test.py.

def rspy.test.check (   exp,
  abort_if_failed = False 
)
Basic function for asserting expressions.
:param exp: An expression to be asserted, if false the assertion failed
:param abort_if_failed: If True and assertion failed the test will be aborted
:return: True if assertion passed, False otherwise

Definition at line 137 of file test.py.

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

Definition at line 157 of file test.py.

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

Definition at line 203 of file test.py.

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

Definition at line 238 of file test.py.

def rspy.test.check_failed ( )
Function for when a check fails

Definition at line 122 of file test.py.

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

Definition at line 263 of file test.py.

def rspy.test.check_test_in_progress (   in_progress = True)

Definition at line 350 of file test.py.

def rspy.test.fail ( )
Function for manually failing a test in case you want a specific test that does not fit any check function

Definition at line 340 of file test.py.

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

Definition at line 81 of file test.py.

def rspy.test.find_first_device_or_exit ( )
:return: the first device 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

Definition at line 66 of file test.py.

def rspy.test.finish ( )
Used at the end of each test to check if it passed and print the answer

Definition at line 373 of file test.py.

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)

Definition at line 301 of file test.py.

def rspy.test.print_info ( )

Definition at line 330 of file test.py.

def rspy.test.print_results_and_exit ( )
Used to print the results of the tests in the file. The format has to agree with the expected format in check_log()
in run-unit-tests and with the C++ format using Catch

Definition at line 399 of file test.py.

def rspy.test.print_separator ( )
For use only in-between test-cases, this will separate them in some visual way so as
to be easier to differentiate.

Definition at line 387 of file test.py.

def rspy.test.print_stack ( )
Function for printing the current call stack. Used when an assertion fails

Definition at line 98 of file test.py.

def rspy.test.reset_info (   persistent = False)
erases the stored information
:param persistent: If this parameter is True, even the persistent information will be erased

Definition at line 316 of file test.py.

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)

Definition at line 30 of file test.py.

def rspy.test.start (   test_name)
Used at the beginning of each test to reset the global variables
:param test_name: Any number of arguments that combined give the name of this test

Definition at line 359 of file test.py.

def rspy.test.unexpected_exception ( )
Used to assert that an except block is not reached. It's different from unreachable because it expects
to be in an except block and prints the stack of the error and not the call-stack for this function

Definition at line 192 of file test.py.

def rspy.test.unreachable (   abort_if_failed = False)
Used to assert that a certain section of code (exp: an if block) is not reached
:param abort_if_failed: If True and this function is reached the test will be aborted

Definition at line 184 of file test.py.

Variable Documentation

int rspy.test.n_assertions = 0

Definition at line 21 of file test.py.

int rspy.test.n_failed_assertions = 0

Definition at line 22 of file test.py.

int rspy.test.n_failed_tests = 0

Definition at line 24 of file test.py.

int rspy.test.n_tests = 0

Definition at line 23 of file test.py.

bool rspy.test.test_failed = False

Definition at line 25 of file test.py.

bool rspy.test.test_in_progress = False

Definition at line 26 of file test.py.

dictionary rspy.test.test_info = {}

Definition at line 27 of file test.py.



librealsense2
Author(s): Sergey Dorodnicov , Doron Hirshberg , Mark Horn , Reagan Lopez , Itay Carpis
autogenerated on Mon May 3 2021 02:50:43