Skip to content

Assertions

contains_string(expected)

Asserts that the actual value contains the provided string.

Parameters:

Name Type Description Default
expected

The string to check for in the actual value.

required

Examples:

>>> from reqflow import Client, given
>>> from reqflow.assertions import contains_string
>>> client = Client(base_url="https://httpbin.org")
>>> given(client).when("GET", "/get?foo=bar").then().assert_body("url", contains_string("foo=bar"))

Returns:

Type Description

An assertion function that checks if the actual value contains the provided string.

equal_to(expected)

Asserts that the actual value is equal to the provided value.

Parameters:

Name Type Description Default
expected

The value to check for equality against the actual value.

required

Examples:

>>> from reqflow import Client, given
>>> from reqflow.assertions import equal_to
>>> client = Client(base_url="https://httpbin.org")
>>> given(client).when("GET", "/get?foo=bar").then().assert_body("url", equal_to("https://httpbin.org/get?foo=bar"))

Returns:

Type Description

An assertion function that checks if the actual value is equal to the provided value.

not_equal_to(expected)

Asserts that the actual value is not equal to the provided value.

Parameters:

Name Type Description Default
expected

The value to check for inequality against the actual value.

required

Examples:

>>> from reqflow import Client, given
>>> from reqflow.assertions import not_equal_to
>>> client = Client(base_url="https://httpbin.org")
>>> given(client).when("GET", "/get?foo=bar").then().assert_body("url", not_equal_to("https://httpbin.org/get?foo=bar"))

Returns:

Type Description

An assertion function that checks if the actual value is not equal to the provided value.

greater_than(expected)

Asserts that the actual value is greater than the provided value.

Parameters:

Name Type Description Default
expected

The value to check for greater than the actual value.

required

Examples:

>>> from reqflow import Client, given
>>> from reqflow.assertions import greater_than
>>> client = Client(base_url="https://httpbin.org")
>>> given(client).when("GET").then().assert_body("some_value", greater_than("777"))

Returns:

Type Description

An assertion function that checks if the actual value is greater than the provided value.

less_than(expected)

Asserts that the actual value is less than the provided value.

Parameters:

Name Type Description Default
expected

The value to check for less than the actual value.

required

Examples:

>>> from reqflow import Client, given
>>> from reqflow.assertions import greater_than
>>> client = Client(base_url="https://httpbin.org")
>>> given(client).when("GET").then().assert_body("some_value", less_than("777"))

Returns:

Type Description

An assertion function that checks if the actual value is less than the provided value.

list_contains(expected)

Asserts that the actual value is contained in the response array list.

Parameters:

Name Type Description Default
expected

The list to check for the actual value.

required

Examples:

>>> from reqflow import Client, given
>>> from reqflow.assertions import list_contains
>>> client = Client(base_url="https://httpbin.org")
>>> given(client).when("GET").then().assert_body("json.some_array", list_contains(["foo", "bar", "baz"]))

Returns:

Type Description

An assertion function that checks if the actual value is contained in the provided list.

is_none()

Asserts that the actual value is None.

Examples:

>>> from reqflow import Client, given
>>> from reqflow.assertions import is_none
>>> client = Client(base_url="https://httpbin.org")
>>> given(client).when("GET").then().assert_body("json.some_value", is_none())

Returns:

Type Description

An assertion function that checks if the actual value is None.

is_not_none()

Asserts that the actual value is not None.

Examples:

>>> from reqflow import Client, given
>>> from reqflow.assertions import is_none
>>> client = Client(base_url="https://httpbin.org")
>>> given(client).when("GET").then().assert_body("json.some_value", is_not_none())

Returns:

Type Description

An assertion function that checks if the actual value is not None.

matches_regex(pattern)

Asserts that the actual value matches the provided regex pattern.

Parameters:

Name Type Description Default
pattern

A regex pattern to match against the actual value.

required

Examples:

>>> from reqflow import Client, given
>>> from reqflow.assertions import matches_regex
>>> client = Client(base_url="https://httpbin.org")
>>> given(client).when("GET").then().assert_body("json.some_value", matches_regex(r"^\d{3}$"))

Returns:

Type Description

An assertion function that checks if the actual value matches the provided regex pattern.

and_(*assertions)

Combines multiple assertions with a logical AND, requiring all assertions to pass.

Parameters:

Name Type Description Default
*assertions

A variable number of assertion functions.

()

Examples:

>>> from reqflow import Client, given
>>> from reqflow.assertions import and_, greater_than, less_than
>>> client = Client(base_url="https://httpbin.org")
>>> given(client).when("GET").then().assert_body("json.some_value", and_(greater_than(1), less_than(100)))

Returns:

Type Description

A combined assertion function that checks all provided assertions.

or_(*assertions)

Combines multiple assertions with a logical OR, requiring at least one assertion to pass.

Parameters:

Name Type Description Default
*assertions

A variable number of assertion functions.

()

Examples:

>>> from reqflow import Client, given
>>> from reqflow.assertions import or_, greater_than, less_than
>>> client = Client(base_url="https://httpbin.org")
>>> given(client).when("GET").then().assert_body("json.some_value", or_(greater_than(1), less_than(100)))

Returns:

Type Description

A combined assertion function that checks if any of the provided assertions pass.