From b879ada6b8ba2ab5e02e542f5bedae123f3e5a06 Mon Sep 17 00:00:00 2001 From: Paul Marillonnet Date: Wed, 1 Apr 2020 11:46:58 +0200 Subject: [PATCH] py3: force text on b64-encoded test data (#41220) --- tests/test_api.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/test_api.py b/tests/test_api.py index 440a574..c69386f 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -5,6 +5,8 @@ import uuid import pytest from django.contrib.auth import get_user_model +from django.utils.encoding import force_text + from authentic2_cut import models from utils import login @@ -53,7 +55,7 @@ def helper_test_validation_image(glc_app, john, image_file, extension): response = glc_app.post_json('/api/users/%s/validate/' % john._oidc_sub, params={ 'external_id': external_id, 'justificatifs': [{ - 'b64_content': base64.b64encode(image_file), + 'b64_content': force_text(base64.b64encode(image_file)), }], }, status=201) assert response.json == { @@ -97,13 +99,13 @@ def test_many_attachments(app, admin, glc_app, john, png_file, jpeg_file, pdf_fi 'external_id': external_id, 'justificatifs': [ { - 'b64_content': base64.b64encode(png_file), + 'b64_content': force_text(base64.b64encode(png_file)), }, { - 'b64_content': base64.b64encode(jpeg_file), + 'b64_content': force_text(base64.b64encode(jpeg_file)), }, { - 'b64_content': base64.b64encode(pdf_file), + 'b64_content': force_text(base64.b64encode(pdf_file)), }, ], }, status=201)