From 331216240962f09a3f4dcf547fac196790ca68ee Mon Sep 17 00:00:00 2001 From: Neil Muller Date: Mon, 4 Mar 2024 12:04:37 +0200 Subject: [PATCH] Make tests compatible with Django 5 changes --- wafer/schedule/tests/test_admin.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/wafer/schedule/tests/test_admin.py b/wafer/schedule/tests/test_admin.py index eafdcba9..6570f925 100644 --- a/wafer/schedule/tests/test_admin.py +++ b/wafer/schedule/tests/test_admin.py @@ -2,7 +2,7 @@ from django.test import TestCase from django.http import HttpRequest -from django.utils import timezone +from django.utils import timezone, version from wafer.pages.models import Page from wafer.schedule.admin import ( @@ -197,16 +197,23 @@ def _make_block_filter(self, block): # We can get away with request None, since SimpleListFilter # doesn't use request in the bits we want to test if block: - return SlotBlockFilter(None, {'block': str(block.pk)}, Slot, self.admin) + value = str(block.pk) else: - return SlotBlockFilter(None, {'block': None}, Slot, self.admin) + value = None + if version.get_complete_version()[0] >= 5: + # Django 5 changes the way filter parameters are handled + value = [value] + return SlotBlockFilter(None, {'block': value}, Slot, self.admin) def _make_time_filter(self, time): """create a list filter for testing.""" if time: - return SlotStartTimeFilter(None, {'start': time}, Slot, self.admin) + value = time else: - return SlotStartTimeFilter(None, {'start': None}, Slot, self.admin) + value = None + if version.get_complete_version()[0] >= 5: + value = [value] + return SlotStartTimeFilter(None, {'start': value}, Slot, self.admin) def test_day_filter_lookups(self): """Test that filter lookups are sane."""