Skip to content

Commit

Permalink
Replace sleeps in tests with retries
Browse files Browse the repository at this point in the history
  • Loading branch information
ihabunek committed Jan 1, 2024
1 parent 301c8d2 commit d1fe0ca
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
11 changes: 6 additions & 5 deletions tests/integration/test_status.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import json
import time
import pytest
from tests.utils import run_with_retries

from toot import api, cli
from toot.exceptions import NotFoundError
Expand Down Expand Up @@ -46,11 +47,11 @@ def test_favourite(app, user, run):
assert result.exit_code == 0
assert result.stdout.strip() == "✓ Status unfavourited"

# A short delay is required before the server returns new data
time.sleep(0.2)

status = api.fetch_status(app, user, status["id"]).json()
assert not status["favourited"]
def test_favourited():
nonlocal status
status = api.fetch_status(app, user, status["id"]).json()
assert not status["favourited"]
run_with_retries(test_favourited)


def test_favourite_json(app, user, run):
Expand Down
15 changes: 7 additions & 8 deletions tests/integration/test_timelines.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import pytest

from time import sleep
from uuid import uuid4
from tests.utils import run_with_retries

Expand Down Expand Up @@ -165,13 +164,14 @@ def test_notifications(app, user, other_user, run):

text = f"Paging doctor @{user.username}"
status = _post_status(app, other_user, text)
sleep(0.5) # grr

result = run(cli.timelines.notifications)
assert result.exit_code == 0
assert f"@{other_user.username} mentioned you" in result.stdout
assert status.id in result.stdout
assert text in result.stdout
def test_notifications():
result = run(cli.timelines.notifications)
assert result.exit_code == 0
assert f"@{other_user.username} mentioned you" in result.stdout
assert status.id in result.stdout
assert text in result.stdout
run_with_retries(test_notifications)

result = run(cli.timelines.notifications, "--mentions")
assert result.exit_code == 0
Expand All @@ -185,7 +185,6 @@ def test_notifications_follow(app, user, friend_user, run_as):
assert result.exit_code == 0
assert f"@{user.username} now follows you" in result.stdout


result = run_as(friend_user, cli.timelines.notifications, "--mentions")
assert result.exit_code == 0
assert "now follows you" not in result.stdout
Expand Down

0 comments on commit d1fe0ca

Please sign in to comment.