From b5b22dd183955e7dc551f0417ab352b7401271fe Mon Sep 17 00:00:00 2001 From: Corey Bryant Date: Fri, 8 Sep 2023 14:25:00 -0400 Subject: [PATCH] Fix test failures with Django 4.x The wsgi.input environment variable is expected to be a stream. Closes-Bug: #2034952 Change-Id: I602449245b30d5375251bd7138f538f28068a16a --- horizon/test/helpers.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/horizon/test/helpers.py b/horizon/test/helpers.py index 9da2d1aa78..765a448182 100644 --- a/horizon/test/helpers.py +++ b/horizon/test/helpers.py @@ -18,6 +18,7 @@ import collections.abc import copy +import io import logging import os import socket @@ -200,7 +201,8 @@ class TestCase(django_test.TestCase): The expected number of messages can be specified per message type. Usage would look like ``self.assertMessageCount(success=1)``. """ - temp_req = self.client.request(**{'wsgi.input': None}) + stream = wsgi.LimitedStream(io.BytesIO(), 2) + temp_req = self.client.request(**{'wsgi.input': stream}) temp_req.COOKIES = self.client.cookies storage = default_storage(temp_req) messages = []