summaryrefslogtreecommitdiff
path: root/tests/forms_tests/field_tests/test_urlfield.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/forms_tests/field_tests/test_urlfield.py')
-rw-r--r--tests/forms_tests/field_tests/test_urlfield.py61
1 files changed, 3 insertions, 58 deletions
diff --git a/tests/forms_tests/field_tests/test_urlfield.py b/tests/forms_tests/field_tests/test_urlfield.py
index 54bc7c5e46..f7d318fdc9 100644
--- a/tests/forms_tests/field_tests/test_urlfield.py
+++ b/tests/forms_tests/field_tests/test_urlfield.py
@@ -1,16 +1,10 @@
-import sys
-from types import ModuleType
-
-from django.conf import FORMS_URLFIELD_ASSUME_HTTPS_DEPRECATED_MSG, Settings, settings
from django.core.exceptions import ValidationError
from django.forms import URLField
-from django.test import SimpleTestCase, ignore_warnings
-from django.utils.deprecation import RemovedInDjango60Warning
+from django.test import SimpleTestCase
from . import FormFieldAssertionsMixin
-@ignore_warnings(category=RemovedInDjango60Warning)
class URLFieldTest(FormFieldAssertionsMixin, SimpleTestCase):
def test_urlfield_widget(self):
f = URLField()
@@ -32,9 +26,7 @@ class URLFieldTest(FormFieldAssertionsMixin, SimpleTestCase):
f.clean("http://abcdefghijklmnopqrstuvwxyz.com")
def test_urlfield_clean(self):
- # RemovedInDjango60Warning: When the deprecation ends, remove the
- # assume_scheme argument.
- f = URLField(required=False, assume_scheme="https")
+ f = URLField(required=False)
tests = [
("http://localhost", "http://localhost"),
("http://example.com", "http://example.com"),
@@ -146,55 +138,8 @@ class URLFieldTest(FormFieldAssertionsMixin, SimpleTestCase):
def test_urlfield_assume_scheme(self):
f = URLField()
- # RemovedInDjango60Warning: When the deprecation ends, replace with:
- # "https://example.com"
- self.assertEqual(f.clean("example.com"), "http://example.com")
+ self.assertEqual(f.clean("example.com"), "https://example.com")
f = URLField(assume_scheme="http")
self.assertEqual(f.clean("example.com"), "http://example.com")
f = URLField(assume_scheme="https")
self.assertEqual(f.clean("example.com"), "https://example.com")
-
-
-class URLFieldAssumeSchemeDeprecationTest(FormFieldAssertionsMixin, SimpleTestCase):
- def test_urlfield_raises_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) as ctx:
- f = URLField()
- self.assertEqual(f.clean("example.com"), "http://example.com")
- self.assertEqual(ctx.filename, __file__)
-
- @ignore_warnings(category=RemovedInDjango60Warning)
- def test_urlfield_forms_urlfield_assume_https(self):
- with self.settings(FORMS_URLFIELD_ASSUME_HTTPS=True):
- f = URLField()
- self.assertEqual(f.clean("example.com"), "https://example.com")
- f = URLField(assume_scheme="http")
- self.assertEqual(f.clean("example.com"), "http://example.com")
-
- def test_override_forms_urlfield_assume_https_setting_warning(self):
- msg = FORMS_URLFIELD_ASSUME_HTTPS_DEPRECATED_MSG
- with self.assertRaisesMessage(RemovedInDjango60Warning, msg):
- # Changing FORMS_URLFIELD_ASSUME_HTTPS via self.settings() raises a
- # deprecation warning.
- with self.settings(FORMS_URLFIELD_ASSUME_HTTPS=True):
- pass
-
- def test_settings_init_forms_urlfield_assume_https_warning(self):
- settings_module = ModuleType("fake_settings_module")
- settings_module.FORMS_URLFIELD_ASSUME_HTTPS = True
- sys.modules["fake_settings_module"] = settings_module
- msg = FORMS_URLFIELD_ASSUME_HTTPS_DEPRECATED_MSG
- try:
- with self.assertRaisesMessage(RemovedInDjango60Warning, msg):
- Settings("fake_settings_module")
- finally:
- del sys.modules["fake_settings_module"]
-
- def test_access_forms_urlfield_assume_https(self):
- # Warning is not raised on access.
- self.assertEqual(settings.FORMS_URLFIELD_ASSUME_HTTPS, False)