mirror of
https://github.com/Hopiu/django-imagekit.git
synced 2026-03-16 21:30:23 +00:00
Create failing test to illustrate #97
This commit is contained in:
parent
5e1757c1ee
commit
118f6e4206
2 changed files with 19 additions and 11 deletions
|
|
@ -1,15 +1,13 @@
|
|||
from __future__ import with_statement
|
||||
|
||||
import os
|
||||
import pickle
|
||||
|
||||
from django.test import TestCase
|
||||
|
||||
from imagekit import utils
|
||||
from imagekit.lib import StringIO
|
||||
from .models import (Photo, AbstractImageModel, ConcreteImageModel1,
|
||||
ConcreteImageModel2)
|
||||
from .testutils import create_photo
|
||||
from .testutils import create_photo, pickleback
|
||||
|
||||
|
||||
class IKTest(TestCase):
|
||||
|
|
@ -66,15 +64,17 @@ class IKUtilsTest(TestCase):
|
|||
|
||||
|
||||
class PickleTest(TestCase):
|
||||
def test_source_file(self):
|
||||
ph = create_photo('pickletest.jpg')
|
||||
pickled_model = StringIO()
|
||||
pickle.dump(ph, pickled_model)
|
||||
pickled_model.seek(0)
|
||||
unpickled_model = pickle.load(pickled_model)
|
||||
def test_model(self):
|
||||
ph = pickleback(create_photo('pickletest.jpg'))
|
||||
|
||||
# This isn't supposed to error.
|
||||
unpickled_model.thumbnail.source_file
|
||||
ph.thumbnail.source_file
|
||||
|
||||
def test_field(self):
|
||||
thumbnail = pickleback(create_photo('pickletest2.jpg').thumbnail)
|
||||
|
||||
# This isn't supposed to error.
|
||||
thumbnail.source_file
|
||||
|
||||
|
||||
class InheritanceTest(TestCase):
|
||||
|
|
|
|||
|
|
@ -3,8 +3,9 @@ import tempfile
|
|||
|
||||
from django.core.files.base import ContentFile
|
||||
|
||||
from imagekit.lib import Image
|
||||
from imagekit.lib import Image, StringIO
|
||||
from .models import Photo
|
||||
import pickle
|
||||
|
||||
|
||||
def generate_lenna():
|
||||
|
|
@ -36,3 +37,10 @@ def create_instance(model_class, image_name):
|
|||
|
||||
def create_photo(name):
|
||||
return create_instance(Photo, name)
|
||||
|
||||
|
||||
def pickleback(obj):
|
||||
pickled = StringIO()
|
||||
pickle.dump(obj, pickled)
|
||||
pickled.seek(0)
|
||||
return pickle.load(pickled)
|
||||
|
|
|
|||
Loading…
Reference in a new issue