AsyncTestCase#
- class omni.kit.test.AsyncTestCase(methodName='runTest')#
Bases:
TestCaseBase class for all async test cases.
Derive from it to make your tests auto-discoverable. Test methods must start with the `test_` prefix.
Test cases allow for generation and/or adaptation of tests at runtime. See testing_exts_python.md for more details.
Methods
assertEqualWithRetry(operation, expected[, ...])Like assertEqual except it retries operation until it returns a value equal to expected or the retry limit is reached.
assertEquals(*args, **kwargs)Deprecated stub for deprecated method on base unittest.TestCase class.
assertTrueWithRetry(operation[, ...])Like assertTrue except it retries operation until it returns a truthy value or the retry limit is reached.
copyFile(src, dst[, permissions])Copy file utility function for test cases that accounts for any special handling needed in test environments.
copyTree(src, dst[, permissions])Copy file utility function for test cases that accounts for any special handling needed in test environments.
retry_until_success(operation[, ...])Retry the operation until it returns a truthy value or exceeds the maximum retries.
run([result])Run the given test case asynchronously, including setUp, test method execution, teardown, and cleanup procedures.
wait_n_updates([n_frames])Wait for a specific number of frame updates asynchronously.
Attributes
fail_on_log_error- __init__(methodName='runTest')#
Create an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.
- async assertEqualWithRetry(
- operation: Callable[[], Any],
- expected: Any,
- wait_frames: int = 2,
- max_retries: int = 50,
Like assertEqual except it retries operation until it returns a value equal to expected or the retry limit is reached.
- Parameters:
operation (Callable[[], Any]) – A function that returns a value.
expected (Any) – The expected value.
wait_frames (int) – Frames to wait after a mismatch.
max_retries (int) – Maximum number of retries.
The function repeatedly calls operation until the returned value equals the expected value. If the maximum number of retries is reached, a failed assertion shows the last returned and expected values.
Please use this function to wrap your operation and minimize waiting time instead of using wait_n_updates directly.
- assertEquals(*args, **kwargs)#
Deprecated stub for deprecated method on base unittest.TestCase class. Python 3.12 removed assertEquals (which was already deprecated). This stub is present to provide a warning to consumers and will ultimately be removed.
- async assertTrueWithRetry(
- operation: Callable[[], Any],
- wait_frames: int = 2,
- max_retries: int = 50,
Like assertTrue except it retries operation until it returns a truthy value or the retry limit is reached.
- Parameters:
operation (Callable[[], Any]) – A function that returns a value.
wait_frames (int) – Frames to wait after a failed call.
max_retries (int) – Maximum number of retries.
The function repeatedly calls operation until it returns a truthy value (e.g., True, non-empty collection, non-zero number). If the maximum number of retries is reached, a failed assertion stops the test.
Please use this function to wrap your operation and minimize waiting time instead of using wait_n_updates directly.
- static copyFile(
- src: str,
- dst: str,
- permissions: int = 420,
Copy file utility function for test cases that accounts for any special handling needed in test environments. (DGXC)
- Parameters:
src – Source file path to copy from.
dst – Destination file path or directory. If a directory, the file is copied into it.
permissions – File permissions to set on the copied file (default: 0o644).
- Returns:
The path to the copied file.
- static copyTree(src: str, dst: str, permissions: int = 420)#
Copy file utility function for test cases that accounts for any special handling needed in test environments. (DGXC)
- Parameters:
src – Source directory path to copy from.
dst – Destination directory to copy to.
permissions – File permissions to set on the copied directory and files (default: 0o644).
- Returns:
The path to the copied file.
- async retry_until_success(
- operation: Callable[[], Any],
- wait_frames: int = 2,
- max_retries: int = 50,
Retry the operation until it returns a truthy value or exceeds the maximum retries.
- Parameters:
operation (Callable[[], Any]) – A function that returns a value.
wait_frames (int) – Frames to wait after a failed call of operation.
max_retries (int) – Maximum number of retries.
- Returns:
The first truthy value returned by operation.
- Return type:
Any
The function keeps calling operation until it returns a truthy value (e.g., True, non-empty collection, non-zero number). If the maximum number of retries is reached, a failed assertion stops the test.
Please use this function to wrap your operation and minimize waiting time instead of using wait_n_updates directly.
- async run(result=None)#
Run the given test case asynchronously, including setUp, test method execution, teardown, and cleanup procedures.
- Parameters:
result (Any) – Optional test result; uses defaultTestResult if None.
- Returns:
The test result object after executing the test.
- Return type:
Any
- async wait_n_updates(n_frames: int = 3)#
Wait for a specific number of frame updates asynchronously.
- Parameters:
n_frames (int) – Number of frame updates to await.