Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sleep time based tests more robust and faster #824

Open
Pijukatel opened this issue Dec 16, 2024 · 0 comments
Open

Make sleep time based tests more robust and faster #824

Pijukatel opened this issue Dec 16, 2024 · 0 comments
Labels
debt Code quality improvement or decrease of technical debt. t-tooling Issues with this label are in the ownership of the tooling team.

Comments

@Pijukatel
Copy link
Contributor

Pijukatel commented Dec 16, 2024

Quite a lot tests in our code base have pattern like this:

action

sleep(sleep_time)

assert expectation

Such test can be flaky when sleep time is not large enough or will take a lot of time, when sleep time is too big.
It can be advantageous to create a helper function that makes such test more robust in worst case scenario and faster in best case scenario.

action

assert expectation_met_within_deadline(expectation, check_period, check_deadline)

where check_period is very low number and check_deadline is larger number.

Non abstracted version of this pattern was used here for example:
https://github.com/apify/crawlee-python/pull/810/files

Create such abstracted helper function and apply it across the codebase tests.

@Pijukatel Pijukatel added t-tooling Issues with this label are in the ownership of the tooling team. debt Code quality improvement or decrease of technical debt. labels Dec 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
debt Code quality improvement or decrease of technical debt. t-tooling Issues with this label are in the ownership of the tooling team.
Projects
None yet
Development

No branches or pull requests

1 participant