Skip to content

Commit

Permalink
Fix integration tests for Celery 5.4.0
Browse files Browse the repository at this point in the history
Fix the following error:

```
____ TestCeleryUserRateLimitIntegrationNoLimit.test_mock_pass_user_id_task _____

self = <integration.test_celery_user_rate_limit.TestCeleryUserRateLimitIntegrationNoLimit object at 0x7f978fc0e400>

    def test_mock_pass_user_id_task(self):
>       self._test_mock_pass_user_id_task(2, 3, self._user_rate_limit)

test/integration/test_celery_user_rate_limit.py:161:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <integration.test_celery_user_rate_limit.TestCeleryUserRateLimitIntegrationNoLimit object at 0x7f978fc0e400>
num_users = 2, num_calls = 3, tasks_per_user_per_sec = 0.0

        for user_results in results.values():
            last_task_end_time = start_time
            for result in user_results:
>               if result.date_done > last_task_end_time:
E               TypeError: can't compare offset-naive and offset-aware datetimes

test/integration/test_celery_user_rate_limit.py:110: TypeError
```

Also https://docs.python.org/3/library/datetime.html#datetime.datetime.utcnow
is deprecated since Python 3.12 .
  • Loading branch information
nsoranzo committed Apr 25, 2024
1 parent 501c9e3 commit 37a50cc
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion test/integration/test_celery_user_rate_limit.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def _test_mock_pass_user_id_task(self, num_users: int, num_calls: int, tasks_per
expected_duration = secs_between_tasks_per_user * (num_calls - 1)
expected_duration_lbound = expected_duration - 4
expected_duration_hbound = expected_duration + 4
start_time = datetime.datetime.utcnow()
start_time = datetime.datetime.now(datetime.timezone.utc)
timer = ExecutionTimer()
# Invoke test task num_calls times for each user
results: Dict[int, List[AsyncResult]] = {}
Expand Down

0 comments on commit 37a50cc

Please sign in to comment.