django-planet
July 3, 2023

Django: Flush out test flakiness by randomly ordering QuerySets

published by Adam Johnson
in blog Adam Johnson
original entry Django: Flush out test flakiness by randomly ordering QuerySets

Sometimes code depends on the order of a QuerySet whilst not specifying an order. This can lead to random, flaky test failures because databases can return rows in any order when none is specified. The problem is made worse by some databases, notably PostgreSQL, which nearly always return rows in …