airtest.core.assertions module¶
Assertions for Airtest
-
assert_exists
(v, msg='')[source]¶ Assert target exists on device screen
Parameters: - v – target to be checked
- msg – short description of assertion, it will be recorded in the report
Raises: AssertionError – if assertion fails
Returns: coordinates of the target
Platforms: Android, Windows, iOS
Example: >>> assert_exists(Template(r"tpl1607324047907.png"), "assert exists")
-
assert_not_exists
(v, msg='')[source]¶ Assert target does not exist on device screen
Parameters: - v – target to be checked
- msg – short description of assertion, it will be recorded in the report
Raises: AssertionError – if assertion fails
Returns: None.
Platforms: Android, Windows, iOS
Example: >>> assert_not_exists(Template(r"tpl1607324047907.png"), "assert not exists")
-
assert_equal
(first, second, msg='', snapshot=True)[source]¶ Assert two values are equal
Parameters: - first – first value
- second – second value
- msg – short description of assertion, it will be recorded in the report
Raises: AssertionError – if assertion fails
Returns: None
Platforms: Android, Windows, iOS
Example: >>> assert_equal(1, 1, msg="assert 1==1")
-
assert_not_equal
(first, second, msg='', snapshot=True)[source]¶ Assert two values are not equal
Parameters: - first – first value
- second – second value
- msg – short description of assertion, it will be recorded in the report
Raises: AssertionError – if assertion
Returns: None
Platforms: Android, Windows, iOS
Example: >>> assert_not_equal(1, 2, msg="assert 1!=2")
-
assert_true
(expr, msg='', snapshot=True)[source]¶ Assert expression is True ( bool(expr) is True ) Note that this is equivalent to bool(expr) is True and not to expr is True (use assertIs(expr, True) for the latter).
Example: >>> assert_true(1==1, msg="assert 1==1")
-
assert_false
(expr, msg='', snapshot=True)[source]¶ Assert expression is False ( bool(expr) is False )
Example: >>> assert_false(1==2, msg="assert 1!=2")
-
assert_is
(first, second, msg='', snapshot=True)[source]¶ Test that first and second are the same object.
Example: >>> assert_is(1, 1, msg="assert 1 is 1")
-
assert_is_not
(first, second, msg='', snapshot=True)[source]¶ Test that first and second are not the same object.
Example: >>> assert_is_not(1, 2, msg="assert 1 is not 2")
-
assert_is_none
(expr, msg='', snapshot=True)[source]¶ Test that expr is None.
Example: >>> assert_is_none(None, msg="assert None is None")
-
assert_is_not_none
(expr, msg='', snapshot=True)[source]¶ Test that expr is not None.
Example: >>> assert_is_not_none(1, msg="assert 1 is not None")
-
assert_in
(first, second, msg='', snapshot=True)[source]¶ Test that first is in second.
Example: >>> assert_in(1, [1, 2], msg="assert 1 in [1, 2]")
-
assert_not_in
(first, second, msg='', snapshot=True)[source]¶ Test that first is not in second.
Example: >>> assert_not_in(3, [1, 2], msg="assert 3 not in [1, 2]")
-
assert_is_instance
(obj, cls, msg='', snapshot=True)[source]¶ Test that obj is an instance of cls (which can be a class or a tuple of classes, as supported by isinstance()).
Example: >>> assert_is_instance(1, int, msg="assert 1 is int")
-
assert_not_is_instance
(obj, cls, msg='', snapshot=True)[source]¶ Test that obj is not an instance of cls.
Example: >>> assert_not_is_instance(1, str, msg="assert 1 is not str")
-
assert_greater
(first, second, msg='', snapshot=True)[source]¶ Test that first is greater than second. (first > second)
Example: >>> assert_greater(2, 1, msg="assert 2 > 1")
-
assert_greater_equal
(first, second, msg='', snapshot=True)[source]¶ Test that first is greater than or equal to second. (first >= second)
Example: >>> assert_greater_equal(1, 1, msg="assert 1 >= 1")