summaryrefslogtreecommitdiff
path: root/tests/model_forms
diff options
context:
space:
mode:
authorSarah Boyce <42296566+sarahboyce@users.noreply.github.com>2024-12-12 17:39:58 +0100
committerSarah Boyce <42296566+sarahboyce@users.noreply.github.com>2025-01-15 22:28:37 +0100
commit9a3f86e96009c1137b286f6d579b9d812a0dee69 (patch)
tree65c8a7d094e5db90a0a2ffe62f36f5ecfce211fb /tests/model_forms
parent9cb1ffa67bb0d13f86c2d4627428fcaa4513136d (diff)
Refs #34380 -- Changed the URLField default scheme to https and removed FORMS_URLFIELD_ASSUME_HTTPS per deprecation timeline.
Diffstat (limited to 'tests/model_forms')
-rw-r--r--tests/model_forms/tests.py43
1 files changed, 2 insertions, 41 deletions
diff --git a/tests/model_forms/tests.py b/tests/model_forms/tests.py
index fd043d3d03..a432f6ce43 100644
--- a/tests/model_forms/tests.py
+++ b/tests/model_forms/tests.py
@@ -22,10 +22,9 @@ from django.forms.models import (
modelform_factory,
)
from django.template import Context, Template
-from django.test import SimpleTestCase, TestCase, ignore_warnings, skipUnlessDBFeature
+from django.test import SimpleTestCase, TestCase, skipUnlessDBFeature
from django.test.utils import isolate_apps
from django.utils.choices import BlankChoiceIterator
-from django.utils.deprecation import RemovedInDjango60Warning
from django.utils.version import PY314, PYPY
from .models import (
@@ -374,7 +373,6 @@ class ModelFormBaseTest(TestCase):
obj = form.save()
self.assertEqual(obj.name, "")
- @ignore_warnings(category=RemovedInDjango60Warning)
def test_save_blank_null_unique_charfield_saves_null(self):
form_class = modelform_factory(
model=NullableUniqueCharFieldModel, fields="__all__"
@@ -913,13 +911,6 @@ class ModelFormBaseTest(TestCase):
self.assertEqual(m2.date_published, datetime.date(2010, 1, 1))
-# RemovedInDjango60Warning.
-# It's a temporary workaround for the deprecation period.
-class HttpsURLField(forms.URLField):
- def __init__(self, **kwargs):
- super().__init__(assume_scheme="https", **kwargs)
-
-
class FieldOverridesByFormMetaForm(forms.ModelForm):
class Meta:
model = Category
@@ -943,7 +934,7 @@ class FieldOverridesByFormMetaForm(forms.ModelForm):
}
}
field_classes = {
- "url": HttpsURLField,
+ "url": forms.URLField,
}
@@ -2918,7 +2909,6 @@ class ModelOtherFieldTests(SimpleTestCase):
},
)
- @ignore_warnings(category=RemovedInDjango60Warning)
def test_url_on_modelform(self):
"Check basic URL field validation on model forms"
@@ -2943,32 +2933,6 @@ class ModelOtherFieldTests(SimpleTestCase):
)
self.assertTrue(HomepageForm({"url": "http://example.com/foo/bar"}).is_valid())
- def test_url_modelform_assume_scheme_warning(self):
- msg = (
- "The default scheme will be changed from 'http' to 'https' in Django "
- "6.0. Pass the forms.URLField.assume_scheme argument to silence this "
- "warning, or set the FORMS_URLFIELD_ASSUME_HTTPS transitional setting to "
- "True to opt into using 'https' as the new default scheme."
- )
- with self.assertWarnsMessage(RemovedInDjango60Warning, msg):
-
- class HomepageForm(forms.ModelForm):
- class Meta:
- model = Homepage
- fields = "__all__"
-
- def test_url_modelform_assume_scheme_early_adopt_https(self):
- msg = "The FORMS_URLFIELD_ASSUME_HTTPS transitional setting is deprecated."
- with (
- self.assertWarnsMessage(RemovedInDjango60Warning, msg),
- self.settings(FORMS_URLFIELD_ASSUME_HTTPS=True),
- ):
-
- class HomepageForm(forms.ModelForm):
- class Meta:
- model = Homepage
- fields = "__all__"
-
def test_modelform_non_editable_field(self):
"""
When explicitly including a non-editable field in a ModelForm, the
@@ -2995,9 +2959,6 @@ class ModelOtherFieldTests(SimpleTestCase):
"""
class HomepageForm(forms.ModelForm):
- # RemovedInDjango60Warning.
- url = forms.URLField(assume_scheme="https")
-
class Meta:
model = Homepage
fields = "__all__"