Do not run during tests

This commit is contained in:
Raphael Michel
2025-10-06 10:12:33 +02:00
parent dff26910e5
commit 00c78a2ed3

View File

@@ -80,8 +80,12 @@ def repeatable_reads_transaction():
**You should only make read-only queries during this transaction and not rely on quota calculations.** **You should only make read-only queries during this transaction and not rely on quota calculations.**
""" """
is_under_test = 'tests.testdummy' in settings.INSTALLED_APPS
try: try:
with transaction.atomic(durable=True): with transaction.atomic(durable=not is_under_test):
if not is_under_test:
# We're not running this in tests, where we can basically not use this since the test runner does its
# own transaction logic for efficiency
with connection.cursor() as cursor: with connection.cursor() as cursor:
if 'postgresql' in settings.DATABASES['default']['ENGINE']: if 'postgresql' in settings.DATABASES['default']['ENGINE']:
cursor.execute('SET TRANSACTION ISOLATION LEVEL REPEATABLE READ;') cursor.execute('SET TRANSACTION ISOLATION LEVEL REPEATABLE READ;')