From 4cce1d1312a96298aed125379baccc228729f983 Mon Sep 17 00:00:00 2001 From: jokiefer Date: Thu, 17 Oct 2024 09:09:06 +0200 Subject: [PATCH] fixes django backward compatibility issue --- tests/test_views.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tests/test_views.py b/tests/test_views.py index caa3eb6..83ce388 100644 --- a/tests/test_views.py +++ b/tests/test_views.py @@ -1,5 +1,6 @@ import json +from django import VERSION from django.test import Client, RequestFactory, TestCase from atomic_operations.consts import ( @@ -195,8 +196,15 @@ def test_view_processing_with_valid_request(self): self.assertEqual(RelatedModel.objects.get(pk=1), BasicModel.objects.get(pk=2).to_one) - self.assertQuerySetEqual(RelatedModelTwo.objects.filter(pk__in=[1, 2]), - BasicModel.objects.get(pk=2).to_many.all()) + + major, minor, _, _, _ = VERSION + if int(major) <= 4 and int(minor) <= 1: + self.assertQuerysetEqual(RelatedModelTwo.objects.filter(pk__in=[1, 2]), + BasicModel.objects.get(pk=2).to_many.all()) + else: + # with django 4.2 TransactionTestCase.assertQuerysetEqual() is deprecated in favor of assertQuerySetEqual(). + self.assertQuerySetEqual(RelatedModelTwo.objects.filter(pk__in=[1, 2]), + BasicModel.objects.get(pk=2).to_many.all()) def test_bulk_view_processing_with_valid_request(self): operations = [