Skip to main content

Tests PyPI - Python Version PyPI License: MIT Code style: black Ruff codecov CodeFactor

Be Patient

bepatient is a library aimed at facilitating work with asynchronous applications. It allows for the repeated execution of specific actions until the desired effect is achieved.

Features

  • Set up and monitor requests for expected values.
  • Flexible comparison using various checkers and comparers.
  • Configure multiple conditions to be met by response.
  • Inspect various aspects of the response (body, status code, headers).
  • Detailed logs (containing cURLs), facilitating the analysis of the test process.
  • Retry mechanism with customizable retries and delay.

Installation

To install bepatient, you can use pip:

pip install bepatient

bepatient supports Python 3.10+

Basic Usage

Using RequestsWaiter object:

from requests import get

from bepatient import RequestsWaiter

waiter = RequestsWaiter(request=get("https://example.com/api"))
waiter.add_checker(comparer="contain", expected_value="string")
waiter.run()

response = waiter.get_result()

assert response.status_code == 200

Simple way:

from requests import get

from bepatient import wait_for_value_in_request

response = wait_for_value_in_request(
    request=get("https://example.com/api"), comparer="contain", expected_value="string"
)
assert response.status_code == 200

If we need add more than one checker:

from requests import get

from bepatient import wait_for_values_in_request

list_of_checkers = [
    {"checker": "json_checker", "comparer": "contain", "expected_value": "string"},
    {
        "checker": "headers_checker",
        "comparer": "is_equal",
        "expected_value": "cloudflare",
        "dict_path": "Server",
    },
]
response = wait_for_values_in_request(
    request=get("https://example.com/api"),
    checkers=list_of_checkers,
    retries=5,
)
assert response.status_code == 200

License

MIT License

Copyright (c) 2023-present Dawid Szaniawski

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Release files for bepatient 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bepatient 1.1.0
File Size Uploaded
bepatient-1.1.0.tar.gz 22.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for bepatient 1.1.0
File Interpreter ABI Platform
bepatient-1.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 41.8 kB

Release files / bepatient-1.1.0.tar.gz

Download URL bepatient-1.1.0.tar.gz
Size 22.8 kB
Tags Source
SHA-256 checksum
How to use checksums
02fc678f58b94c23a835e73eace66510da5659719599425c65ff9a6086f1a02e
BLAKE2b-256 checksum
How to use checksums
dc5df8d812d8dd1c529b04524827ff9a64dee3eddd200f5faf2e0a55d9142db6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / bepatient-1.1.0-py3-none-any.whl

Download URL bepatient-1.1.0-py3-none-any.whl
Size 19.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b69c83c31a116b897fad35b6a3997ed2986362bcc58dc04514e6bac6ffa12489
BLAKE2b-256 checksum
How to use checksums
f84c414c054384e83f439fc695c7e29470a9075e712fd8c3f489e66fcada939f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release history Release notifications | RSS feed

This release

1.1.0 This release

2 release files

1.0.0

2 release files

0.17.0

2 release files

0.16.0

2 release files

0.15.0

2 release files

0.14.0

2 release files

0.13.0

2 release files

0.12.0

2 release files

0.10.2

2 release files

0.10.1

2 release files

0.9.0

2 release files

0.8.1

2 release files

0.8.0

2 release files

0.7.0

2 release files

0.6.0

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page