From 3b10868832d9e4439b82e736c14b948de6f24a49 Mon Sep 17 00:00:00 2001 From: Krzysztof Klimonda Date: Fri, 5 Apr 2013 19:10:17 +0200 Subject: [PATCH] Open binary files in the binary mode Make sure that we are using binary mode to read binary files like images, this Fixes #20 --- pinry/core/tests/api.py | 2 +- pinry/core/tests/helpers.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pinry/core/tests/api.py b/pinry/core/tests/api.py index ac6ffb3..8cffb0a 100644 --- a/pinry/core/tests/api.py +++ b/pinry/core/tests/api.py @@ -19,7 +19,7 @@ def filter_generator_for(size): def mock_requests_get(url): - response = mock.Mock(content=open('logo.png').read()) + response = mock.Mock(content=open('logo.png', 'rb').read()) return response diff --git a/pinry/core/tests/helpers.py b/pinry/core/tests/helpers.py index 069c504..ce4e6fd 100644 --- a/pinry/core/tests/helpers.py +++ b/pinry/core/tests/helpers.py @@ -1,6 +1,6 @@ from django.conf import settings from django.contrib.auth.models import Permission -from django.core.files import File +from django.core.files.images import ImageFile from django.db.models.query import QuerySet from django.test import TestCase @@ -33,7 +33,7 @@ class TagFactory(factory.Factory): class ImageFactory(factory.Factory): - image = factory.LazyAttribute(lambda a: File(open(TEST_IMAGE_PATH))) + image = factory.LazyAttribute(lambda a: ImageFile(open(TEST_IMAGE_PATH, 'rb'))) class PinFactory(factory.Factory):