Skip to content
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
12 changes: 4 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ requires-python = ">=3.10"
classifiers = [
"Development Status :: 5 - Production/Stable",
"Environment :: Web Environment",
"Framework :: Django :: 4.2",
"Framework :: Django :: 5.2",
"Intended Audience :: Science/Research",
"Operating System :: OS Independent",
"Programming Language :: Python",
Expand All @@ -41,7 +41,7 @@ dependencies = [
# in minor version updates anytime
"defusedcsv>=2.0,<4.0",
"defusedxml>=0.7.1,<1.0",
"django>=4.2,<5.0",
"django>=5.2.8,<6.0",
"django-cleanup>=8.0,<10.0",
"django-compressor>=4.4,<5.0",
"django-extensions>=3.2,<5.0",
Expand Down Expand Up @@ -203,15 +203,11 @@ markers = [
"e2e: marks tests as end-to-end tests using playwright (deselect with '-m \"not e2e\"')",
]
filterwarnings = [
# fail on RemovedInDjango50Warning exception
"error::django.utils.deprecation.RemovedInDjango50Warning",
# throw an error when using methods deprecated in the next django version
"error::django.utils.deprecation.RemovedInNextVersionWarning",

# ignore warnings raised by widget_tweaks.py
"ignore:'maxsplit' is passed as positional argument",

# ignore warnings raised from within django itself
# django/core/files/storage/__init__.py
"ignore:django.core.files.storage.get_storage_class is deprecated:django.utils.deprecation.RemovedInDjango51Warning",
]

[tool.coverage.run]
Expand Down
15 changes: 11 additions & 4 deletions rdmo/core/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,11 @@
]

invalid_date_strings = [
("2025-02-31","day is out of range for month"),
("2025-02-31", (
"day is out of range for month", # Python 3.10
"day 31 must be in range 1..28 for month 2 in year 2025" # Python 3.14
)
),
("2025-17-02", "month must be in 1..12"),
("99/99/9999", "Invalid date format"),
("abcd-ef-gh", "Invalid date format"),
Expand Down Expand Up @@ -91,11 +95,14 @@ def test_parse_date_from_string_valid_formats(settings, locale, date_string, exp

@pytest.mark.parametrize("invalid_date, error_msg", invalid_date_strings)
def test_parse_date_from_string_invalid_formats(settings, invalid_date, error_msg):
if not isinstance(invalid_date,str):
with pytest.raises(TypeError, match=error_msg):
patterns = error_msg if isinstance(error_msg, (tuple, list)) else (error_msg,)
match = "|".join(f"(?:{pattern})" for pattern in patterns)

if not isinstance(invalid_date, str):
with pytest.raises(TypeError, match=match):
parse_date_from_string(invalid_date)
else:
with pytest.raises(ValueError,match=error_msg):
with pytest.raises(ValueError, match=match):
parse_date_from_string(invalid_date)


Expand Down
11 changes: 11 additions & 0 deletions testing/config/settings/base.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
from warnings import filterwarnings

from django.utils.translation import gettext_lazy as _

Expand Down Expand Up @@ -110,3 +111,13 @@

PROJECT_CONTACT = True
PROJECT_CONTACT_RECIPIENTS = ['email@example.com']

# Ref: https://adamj.eu/tech/2023/12/07/django-fix-urlfield-assume-scheme-warnings
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So there is a warning we need to suppress, even if we set it explicitly? This is a bit weird.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems so, sorry. If you remove this "hack", you get an error.

filterwarnings(
"ignore", "The FORMS_URLFIELD_ASSUME_HTTPS transitional setting is deprecated."
)
# This value will change from False to True in Django 6.0
# Refs:
# - https://docs.djangoproject.com/en/5.2/ref/settings/#forms-urlfield-assume-https
# - https://docs.djangoproject.com/en/5.2/ref/forms/fields/#django.forms.URLField.assume_scheme
FORMS_URLFIELD_ASSUME_HTTPS = True