mirror of
https://github.com/Hopiu/django-imagekit.git
synced 2026-04-18 20:21:01 +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
|
from __future__ import with_statement
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import pickle
|
|
||||||
|
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
|
|
||||||
from imagekit import utils
|
from imagekit import utils
|
||||||
from imagekit.lib import StringIO
|
|
||||||
from .models import (Photo, AbstractImageModel, ConcreteImageModel1,
|
from .models import (Photo, AbstractImageModel, ConcreteImageModel1,
|
||||||
ConcreteImageModel2)
|
ConcreteImageModel2)
|
||||||
from .testutils import create_photo
|
from .testutils import create_photo, pickleback
|
||||||
|
|
||||||
|
|
||||||
class IKTest(TestCase):
|
class IKTest(TestCase):
|
||||||
|
|
@ -66,15 +64,17 @@ class IKUtilsTest(TestCase):
|
||||||
|
|
||||||
|
|
||||||
class PickleTest(TestCase):
|
class PickleTest(TestCase):
|
||||||
def test_source_file(self):
|
def test_model(self):
|
||||||
ph = create_photo('pickletest.jpg')
|
ph = pickleback(create_photo('pickletest.jpg'))
|
||||||
pickled_model = StringIO()
|
|
||||||
pickle.dump(ph, pickled_model)
|
|
||||||
pickled_model.seek(0)
|
|
||||||
unpickled_model = pickle.load(pickled_model)
|
|
||||||
|
|
||||||
# This isn't supposed to error.
|
# 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):
|
class InheritanceTest(TestCase):
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,9 @@ import tempfile
|
||||||
|
|
||||||
from django.core.files.base import ContentFile
|
from django.core.files.base import ContentFile
|
||||||
|
|
||||||
from imagekit.lib import Image
|
from imagekit.lib import Image, StringIO
|
||||||
from .models import Photo
|
from .models import Photo
|
||||||
|
import pickle
|
||||||
|
|
||||||
|
|
||||||
def generate_lenna():
|
def generate_lenna():
|
||||||
|
|
@ -36,3 +37,10 @@ def create_instance(model_class, image_name):
|
||||||
|
|
||||||
def create_photo(name):
|
def create_photo(name):
|
||||||
return create_instance(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