From 6b07387ad403e797d91fd0d3ee4037d98033f2d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Tue, 19 Nov 2019 14:34:17 +0100 Subject: [PATCH] tests: get test_finish_interrupted_request responses content (#36515) --- tests/test_publisher.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/test_publisher.py b/tests/test_publisher.py index 023de2633..1e9796f9e 100644 --- a/tests/test_publisher.py +++ b/tests/test_publisher.py @@ -15,6 +15,7 @@ from django.core.management.base import CommandError from django.http import Http404 from django.test import override_settings from django.utils import six +from django.utils.encoding import force_text from django.utils.six import BytesIO, StringIO from quixote import cleanup from wcs.qommon import get_publisher_class @@ -106,7 +107,7 @@ def test_finish_interrupted_request(): 'CONTENT_LENGTH': 'aaa', }) response = pub.process_request(req) - assert 'invalid content-length header' in str(response) + assert b'invalid content-length header' in response.getvalue() req = HTTPRequest(StringIO(''), { 'SERVER_NAME': 'example.net', 'SCRIPT_NAME': '', @@ -114,7 +115,7 @@ def test_finish_interrupted_request(): 'CONTENT_LENGTH': '1', }) response = pub.process_request(req) - assert 'Invalid request: unexpected end of request body' in str(response) + assert b'Invalid request: unexpected end of request body' in response.getvalue() req = HTTPRequest(StringIO(''), { 'SERVER_NAME': 'example.net', 'SCRIPT_NAME': '', @@ -122,7 +123,7 @@ def test_finish_interrupted_request(): 'CONTENT_LENGTH': '1', }) response = pub.process_request(req) - assert 'Invalid request: multipart/form-data missing boundary' in str(response) + assert b'Invalid request: multipart/form-data missing boundary' in response.getvalue() with pytest.raises(Http404): req = HTTPRequest(StringIO(''), { 'SERVER_NAME': 'example.net',