Skip to content

Commit

Permalink
Fix a flakey test
Browse files Browse the repository at this point in the history
See: https://hypothes-is.slack.com/archives/C4K6M7P5E/p1733303125984169

Sorting the users that these fixtures return effectively randomises
their order (according to their randomly generated h_userid's) which
breaks some tests that implicitly depend on the order.
  • Loading branch information
seanh committed Dec 5, 2024
1 parent 0acd7e2 commit 041f472
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions tests/unit/lms/tasks/email_digests_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ def test_it_sends_digests_for_instructors(
"created_before": "2023-03-09T05:00:00+00:00",
},
)
for participating_instructor in participating_instructors
for participating_instructor in sorted(
participating_instructors, key=lambda u: u.h_userid
)
]

@pytest.mark.usefixtures("participating_instructors_with_no_launches")
Expand Down Expand Up @@ -130,7 +132,7 @@ def participating_instructors(self, participating_instances, make_instructors):

make_instructors(users, participating_instances[0], with_launch=True)

return sorted(users, key=lambda u: u.h_userid)
return users

@pytest.fixture
def participating_instructors_with_no_launches(
Expand All @@ -145,7 +147,7 @@ def participating_instructors_with_no_launches(

make_instructors(users, participating_instances[0], with_launch=False)

return sorted(users, key=lambda u: u.h_userid)
return users

@pytest.fixture
def non_participating_instance(self):
Expand Down

0 comments on commit 041f472

Please sign in to comment.