From 23c142a84553b18f672c797ace9065181d2bbeef Mon Sep 17 00:00:00 2001 From: Awais Qureshi Date: Thu, 31 Aug 2023 18:48:04 +0500 Subject: [PATCH] test: adding check to run migrations tests only if its django32. (#33141) --- common/djangoapps/util/tests/test_db.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/common/djangoapps/util/tests/test_db.py b/common/djangoapps/util/tests/test_db.py index 4d13666462..77f2ac07f0 100644 --- a/common/djangoapps/util/tests/test_db.py +++ b/common/djangoapps/util/tests/test_db.py @@ -1,9 +1,10 @@ """Tests for util.db module.""" +from importlib.metadata import version from io import StringIO import ddt - +import pytest from django.core.management import call_command from django.db.transaction import TransactionManagementError, atomic from django.test import TestCase, TransactionTestCase @@ -11,6 +12,8 @@ from django.test.utils import override_settings from common.djangoapps.util.db import enable_named_outer_atomic, generate_int_id, outer_atomic +GET_DJANGO_VERSION = int(version('django').split('.')[0]) + def do_nothing(): """Just return.""" @@ -116,6 +119,7 @@ class GenerateIntIdTestCase(TestCase): assert int_id in list(set(range(minimum, (maximum + 1))) - used_ids) +@pytest.mark.skipif(GET_DJANGO_VERSION > 3, reason="django4.2 brings new migrations, so only run for dj32 for now.") class MigrationTests(TestCase): """ Tests for migrations.