Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove references to unsupported Django versions #115

Merged
merged 2 commits into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
12 changes: 2 additions & 10 deletions tests/test_models.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 ValidationError
from django.db import DataError, models, transaction
from django.test import TestCase, override_settings
Expand Down Expand Up @@ -137,18 +136,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
Loading