Skip to content

[bug/tests] Flawed tests due to timezone handling #611

@nemesifier

Description

@nemesifier

Got these seemingly random test failure both locally and in the CI:

======================================================================
FAIL: test_delete_old_radiusbatch_users_command (openwisp_radius.tests.test_commands.TestCommands) [Test executing command with older_than_days argument]
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.10.18/x64/lib/python3.10/site-packages/openwisp_utils/tests/utils.py", line 97, in wrapped_function
    function(*args, **kwargs)
TypeError: TestCommands.test_delete_old_radiusbatch_users_command() takes 1 positional argument but 2 were given

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/runner/work/openwisp-radius/openwisp-radius/openwisp_radius/tests/test_commands.py", line 201, in test_delete_old_radiusbatch_users_command
    self.assertEqual(get_user_model().objects.all().count(), 0)
AssertionError: 3 != 0

======================================================================
FAIL: test_delete_old_radiusbatch_users_command (openwisp_radius.tests.test_commands.TestCommands) [Test executing command with both arguments]
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.10.18/x64/lib/python3.10/site-packages/openwisp_utils/tests/utils.py", line 97, in wrapped_function
    function(*args, **kwargs)
TypeError: TestCommands.test_delete_old_radiusbatch_users_command() takes 1 positional argument but 2 were given

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/runner/work/openwisp-radius/openwisp-radius/openwisp_radius/tests/test_commands.py", line 210, in test_delete_old_radiusbatch_users_command
    self.assertEqual(get_user_model().objects.all().count(), 0)
AssertionError: 3 != 0

I remember in the past we had some tests suffering the same problem due to timezone issues but I don't remember the details right now, @pandafy please help me remember if you can.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    Projects

    Status

    Backlog

    Status

    To do (general)

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions