mobly package¶
Subpackages¶
- mobly.controllers package
- Subpackages
- mobly.controllers.android_device_lib package
- Subpackages
- Submodules
- mobly.controllers.android_device_lib.adb module
- mobly.controllers.android_device_lib.callback_handler module
- mobly.controllers.android_device_lib.errors module
- mobly.controllers.android_device_lib.event_dispatcher module
- mobly.controllers.android_device_lib.fastboot module
- mobly.controllers.android_device_lib.jsonrpc_client_base module
- mobly.controllers.android_device_lib.jsonrpc_shell_base module
- mobly.controllers.android_device_lib.service_manager module
- mobly.controllers.android_device_lib.sl4a_client module
- mobly.controllers.android_device_lib.snippet_client module
- mobly.controllers.android_device_lib.snippet_event module
- Module contents
- mobly.controllers.attenuator_lib package
- mobly.controllers.sniffer_lib package
- mobly.controllers.android_device_lib package
- Submodules
- mobly.controllers.android_device module
- mobly.controllers.attenuator module
- mobly.controllers.iperf_server module
- mobly.controllers.monsoon module
- mobly.controllers.sniffer module
- Module contents
- Subpackages
Submodules¶
mobly.asserts module¶
-
mobly.asserts.
abort_all
(reason, extras=None)[source]¶ Abort all subsequent tests, including the ones not in this test class or iteration.
Parameters: - reason – The reason to abort.
- extras – An optional field for extra information to be included in test result.
Raises: signals.TestAbortAll
– Abort all subsequent tests.
-
mobly.asserts.
abort_all_if
(expr, reason, extras=None)[source]¶ Abort all subsequent tests, if the expression evaluates to True.
Parameters: - expr – The expression that is evaluated.
- reason – The reason to abort.
- extras – An optional field for extra information to be included in test result.
Raises: signals.TestAbortAll
– Abort all subsequent tests.
-
mobly.asserts.
abort_class
(reason, extras=None)[source]¶ Abort all subsequent tests within the same test class in one iteration.
If one test class is requested multiple times in a test run, this can only abort one of the requested executions, NOT all.
Parameters: - reason – The reason to abort.
- extras – An optional field for extra information to be included in test result.
Raises: signals.TestAbortClass
– Abort all subsequent tests in a test class.
-
mobly.asserts.
abort_class_if
(expr, reason, extras=None)[source]¶ Abort all subsequent tests within the same test class in one iteration, if expression evaluates to True.
If one test class is requested multiple times in a test run, this can only abort one of the requested executions, NOT all.
Parameters: - expr – The expression that is evaluated.
- reason – The reason to abort.
- extras – An optional field for extra information to be included in test result.
Raises: signals.TestAbortClass
– Abort all subsequent tests in a test class.
-
mobly.asserts.
assert_almost_equal
(first, second, places=None, msg=None, delta=None, extras=None)[source]¶ Asserts that first is almost equal to second.
Fails if the two objects are unequal as determined by their difference rounded to the given number of decimal places (default 7) and comparing to zero, or by comparing that the difference between the two objects is more than the given delta. If the two objects compare equal then they automatically compare almost equal.
Parameters: - first – The first value to compare.
- second – The second value to compare.
- places – How many decimal places to take into account for comparison. Note that decimal places (from zero) are usually not the same as significant digits (measured from the most significant digit).
- msg – A string that adds additional info about the failure.
- delta – Delta to use for comparison instead of decimal places.
- extras – An optional field for extra information to be included in test result.
-
mobly.asserts.
assert_count_equal
(first, second, msg=None, extras=None)[source]¶ Asserts that two iterables have the same element count.
Element order does not matter. Similar to assert_equal(Counter(list(first)), Counter(list(second))).
Parameters: - first – The first iterable to compare.
- second – The second iterable to compare.
- msg – A string that adds additional info about the failure.
- extras – An optional field for extra information to be included in test result.
Example
assert_count_equal([0, 1, 1], [1, 0, 1]) passes the assertion. assert_count_equal([0, 0, 1], [0, 1]) raises an assertion error.
-
mobly.asserts.
assert_equal
(first, second, msg=None, extras=None)[source]¶ Asserts the equality of objects, otherwise fail the test.
Error message is “first != second” by default. Additional explanation can be supplied in the message.
Parameters: - first – The first object to compare.
- second – The second object to compare.
- msg – A string that adds additional info about the failure.
- extras – An optional field for extra information to be included in test result.
-
mobly.asserts.
assert_false
(expr, msg, extras=None)[source]¶ Assert an expression evaluates to false, otherwise fail the test.
Parameters: - expr – The expression that is evaluated.
- msg – A string explaining the details in case of failure.
- extras – An optional field for extra information to be included in test result.
-
mobly.asserts.
assert_in
(member, container, msg=None, extras=None)[source]¶ Asserts that member is in container.
-
mobly.asserts.
assert_is_instance
(obj, cls, msg=None, extras=None)[source]¶ Asserts that obj is an instance of cls.
-
mobly.asserts.
assert_is_not
(expr1, expr2, msg=None, extras=None)[source]¶ Asserts that expr1 is not expr2.
-
mobly.asserts.
assert_not_almost_equal
(first, second, places=None, msg=None, delta=None, extras=None)[source]¶ Asserts that first is not almost equal to second.
Parameters: - first – The first value to compare.
- second – The second value to compare.
- places – How many decimal places to take into account for comparison. Note that decimal places (from zero) are usually not the same as significant digits (measured from the most significant digit).
- msg – A string that adds additional info about the failure.
- delta – Delta to use for comparison instead of decimal places.
- extras – An optional field for extra information to be included in test result.
-
mobly.asserts.
assert_not_equal
(first, second, msg=None, extras=None)[source]¶ Asserts that first is not equal (!=) to second.
-
mobly.asserts.
assert_not_in
(member, container, msg=None, extras=None)[source]¶ Asserts that member is not in container.
-
mobly.asserts.
assert_not_is_instance
(obj, cls, msg=None, extras=None)[source]¶ Asserts that obj is not an instance of cls.
-
mobly.asserts.
assert_not_regex
(text, unexpected_regex, msg=None, extras=None)[source]¶ Fails the test if the text matches the regular expression.
-
mobly.asserts.
assert_raises
(expected_exception, extras=None, *args, **kwargs)[source]¶ Assert that an exception is raised when a function is called.
If no exception is raised, test fail. If an exception is raised but not of the expected type, the exception is let through.
- This should only be used as a context manager:
- with assert_raises(Exception):
- func()
Parameters: - expected_exception – An exception class that is expected to be raised.
- extras – An optional field for extra information to be included in test result.
-
mobly.asserts.
assert_raises_regex
(expected_exception, expected_regex, extras=None, *args, **kwargs)[source]¶ Assert that an exception is raised when a function is called.
If no exception is raised, test fail. If an exception is raised but not of the expected type, the exception is let through. If an exception of the expected type is raised but the error message does not match the expected_regex, test fail.
- This should only be used as a context manager:
- with assert_raises(Exception):
- func()
Parameters: - expected_exception – An exception class that is expected to be raised.
- extras – An optional field for extra information to be included in test result.
-
mobly.asserts.
assert_regex
(text, expected_regex, msg=None, extras=None)[source]¶ Fails the test unless the text matches the regular expression.
-
mobly.asserts.
assert_true
(expr, msg, extras=None)[source]¶ Assert an expression evaluates to true, otherwise fail the test.
Parameters: - expr – The expression that is evaluated.
- msg – A string explaining the details in case of failure.
- extras – An optional field for extra information to be included in test result.
-
mobly.asserts.
explicit_pass
(msg, extras=None)[source]¶ Explicitly pass a test.
This will pass the test explicitly regardless of any other error happened in the test body. E.g. even if errors have been recorded with expects, the test will still be marked pass if this is called.
A test without uncaught exception will pass implicitly so this should be used scarcely.
Parameters: - msg – A string explaining the details of the passed test.
- extras – An optional field for extra information to be included in test result.
Raises: signals.TestPass
– Mark a test as passed.
-
mobly.asserts.
fail
(msg, extras=None)[source]¶ Explicitly fail a test.
Parameters: - msg – A string explaining the details of the failure.
- extras – An optional field for extra information to be included in test result.
Raises: signals.TestFailure
– Mark a test as failed.
mobly.base_instrumentation_test module¶
mobly.base_test module¶
mobly.config_parser module¶
mobly.controller_manager module¶
mobly.expects module¶
mobly.keys module¶
mobly.logger module¶
mobly.records module¶
mobly.runtime_test_info module¶
mobly.signals module¶
This module is where all the test signal classes and related utilities live.
-
exception
mobly.signals.
ControllerError
[source]¶ Bases:
Exception
Raised when an error occurred in controller classes.
-
exception
mobly.signals.
TestAbortAll
(details, extras=None)[source]¶ Bases:
mobly.signals.TestAbortSignal
Raised when all subsequent tests should be aborted.
-
exception
mobly.signals.
TestAbortClass
(details, extras=None)[source]¶ Bases:
mobly.signals.TestAbortSignal
Raised when all subsequent tests within the same test class should be aborted.
-
exception
mobly.signals.
TestAbortSignal
(details, extras=None)[source]¶ Bases:
mobly.signals.TestSignal
Base class for abort signals.
-
exception
mobly.signals.
TestError
(details, extras=None)[source]¶ Bases:
mobly.signals.TestSignal
Raised when a test has an unexpected error.
-
exception
mobly.signals.
TestFailure
(details, extras=None)[source]¶ Bases:
mobly.signals.TestSignal
Raised when a test has failed.
-
exception
mobly.signals.
TestPass
(details, extras=None)[source]¶ Bases:
mobly.signals.TestSignal
Raised when a test has passed.
-
exception
mobly.signals.
TestSignal
(details, extras=None)[source]¶ Bases:
Exception
Base class for all test result control signals. This is used to signal the result of a test.
-
details
¶ A string that describes the reason for raising this signal.
-
extras
¶ A json-serializable data type to convey extra information about a test result.
-
-
exception
mobly.signals.
TestSignalError
[source]¶ Bases:
Exception
Raised when an error occurs inside a test signal.
-
exception
mobly.signals.
TestSkip
(details, extras=None)[source]¶ Bases:
mobly.signals.TestSignal
Raised when a test has been skipped.