Skip to content

Commit

Permalink
Remove references to unsupported Django versions
Browse files Browse the repository at this point in the history
  • Loading branch information
dyve committed Apr 24, 2024
1 parent 2d6715c commit 96ae80b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 21 deletions.
6 changes: 1 addition & 5 deletions modeltrans/manager.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from django import VERSION as DJANGO_VERSION
from django.core.exceptions import FieldDoesNotExist
from django.db.models import Count, Func, Manager, Q, QuerySet
from django.db.models.constants import LOOKUP_SEP
Expand Down Expand Up @@ -193,10 +192,7 @@ def _rewrite_expression(self, expr):

def _rewrite_Q(self, q):
if isinstance(q, Q):
if DJANGO_VERSION < (4, 2):
factory = Q._new_instance
else:
factory = Q.create
factory = Q.create
return factory(
list(self._rewrite_Q(child) for child in q.children),
connector=q.connector,
Expand Down
13 changes: 3 additions & 10 deletions tests/test_models.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from django import VERSION as DJANGO_VERSION

from django.core.exceptions import ValidationError
from django.db import DataError, models, transaction
from django.test import TestCase, override_settings
Expand Down Expand Up @@ -137,18 +137,11 @@ def test_creating_with_nonexisting_field(self):
Blogs have titles, not names, so trying to add something with a name
should raise an eror.
"""
if DJANGO_VERSION < (4, 1):
expected_message = "Blog() got an unexpected keyword argument 'name'"
else:
expected_message = "Blog() got unexpected keyword arguments: 'name'"

expected_message = "Blog() got unexpected keyword arguments: 'name'"
with self.assertRaisesMessage(TypeError, expected_message):
Blog.objects.create(name="Falcon")

if DJANGO_VERSION < (4, 1):
expected_message = "Blog() got an unexpected keyword argument 'name_nl'"
else:
expected_message = "Blog() got unexpected keyword arguments: 'name_nl'"
expected_message = "Blog() got unexpected keyword arguments: 'name_nl'"
with self.assertRaisesMessage(TypeError, expected_message):
Blog.objects.create(title="Falcon", name_nl="Valk")

Expand Down
7 changes: 1 addition & 6 deletions tests/test_translating.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from django import VERSION as DJANGO_VERSION
from django.core.exceptions import ImproperlyConfigured, ValidationError
from django.db import models
from django.test import TestCase
Expand Down Expand Up @@ -227,11 +226,7 @@ class Meta:
self.assertFalse(hasattr(m, "title_i18n"))
self.assertFalse(hasattr(m, "title_en"))

if DJANGO_VERSION < (4, 1):
expected_message = "TestModel4() got an unexpected keyword argument 'title_nl'"
else:
expected_message = "TestModel4() got unexpected keyword arguments: 'title_nl'"

expected_message = "TestModel4() got unexpected keyword arguments: 'title_nl'"
with self.assertRaisesMessage(TypeError, expected_message):
TestModel4(title="bar", title_nl="foo")

Expand Down

0 comments on commit 96ae80b

Please sign in to comment.