forked from CGM_Public/pretix_original
Do not run during tests
This commit is contained in:
@@ -80,15 +80,19 @@ 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):
|
||||||
with connection.cursor() as cursor:
|
if not is_under_test:
|
||||||
if 'postgresql' in settings.DATABASES['default']['ENGINE']:
|
# We're not running this in tests, where we can basically not use this since the test runner does its
|
||||||
cursor.execute('SET TRANSACTION ISOLATION LEVEL REPEATABLE READ;')
|
# own transaction logic for efficiency
|
||||||
elif 'sqlite' in settings.DATABASES['default']['ENGINE']:
|
with connection.cursor() as cursor:
|
||||||
pass # noop
|
if 'postgresql' in settings.DATABASES['default']['ENGINE']:
|
||||||
else:
|
cursor.execute('SET TRANSACTION ISOLATION LEVEL REPEATABLE READ;')
|
||||||
raise ImproperlyConfigured("Cannot set transaction isolation mode on this database backend")
|
elif 'sqlite' in settings.DATABASES['default']['ENGINE']:
|
||||||
|
pass # noop
|
||||||
|
else:
|
||||||
|
raise ImproperlyConfigured("Cannot set transaction isolation mode on this database backend")
|
||||||
|
|
||||||
connection.tx_in_repeatable_read = True
|
connection.tx_in_repeatable_read = True
|
||||||
yield
|
yield
|
||||||
|
|||||||
Reference in New Issue
Block a user