mirror of
https://github.com/Hopiu/django-imagekit.git
synced 2026-03-16 21:30:23 +00:00
Clean up test utils; write to media dir
This commit is contained in:
parent
7f11f44c67
commit
938e2e178b
4 changed files with 9 additions and 22 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
|
@ -7,4 +7,5 @@
|
|||
MANIFEST
|
||||
build
|
||||
dist
|
||||
/tests/media
|
||||
/tests/media/*
|
||||
!/tests/media/lenna.png
|
||||
|
|
|
|||
BIN
tests/media/lenna.png
Normal file
BIN
tests/media/lenna.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 463 KiB |
|
|
@ -2,12 +2,11 @@ from bs4 import BeautifulSoup
|
|||
from django.template import Context, Template, TemplateSyntaxError
|
||||
from nose.tools import eq_, assert_not_in, raises, assert_not_equal
|
||||
from . import imagespecs
|
||||
from .utils import get_named_image_file
|
||||
from .utils import get_image_file
|
||||
|
||||
|
||||
def render_tag(ttag):
|
||||
img = get_named_image_file()
|
||||
img.name = 'tmp' # FIXME: If we don't do this, we get a SuspiciousOperation
|
||||
img = get_image_file()
|
||||
template = Template('{%% load imagekit %%}%s' % ttag)
|
||||
context = Context({'img': img})
|
||||
return template.render(context)
|
||||
|
|
|
|||
|
|
@ -1,14 +1,12 @@
|
|||
import os
|
||||
|
||||
from django.conf import settings
|
||||
from django.core.files.base import ContentFile
|
||||
|
||||
from imagekit.lib import Image, StringIO
|
||||
from tempfile import NamedTemporaryFile
|
||||
from .models import Photo
|
||||
import pickle
|
||||
from .models import Photo
|
||||
|
||||
|
||||
def _get_image_file(file_factory):
|
||||
def get_image_file():
|
||||
"""
|
||||
See also:
|
||||
|
||||
|
|
@ -16,19 +14,8 @@ def _get_image_file(file_factory):
|
|||
http://sipi.usc.edu/database/database.php?volume=misc&image=12
|
||||
|
||||
"""
|
||||
path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'assets', 'lenna-800x600-white-border.jpg')
|
||||
tmp = file_factory()
|
||||
tmp.write(open(path, 'r+b').read())
|
||||
tmp.seek(0)
|
||||
return tmp
|
||||
|
||||
|
||||
def get_image_file():
|
||||
return _get_image_file(StringIO)
|
||||
|
||||
|
||||
def get_named_image_file():
|
||||
return _get_image_file(NamedTemporaryFile)
|
||||
path = os.path.join(settings.MEDIA_ROOT, 'lenna.png')
|
||||
return open(path, 'r+b')
|
||||
|
||||
|
||||
def create_image():
|
||||
|
|
|
|||
Loading…
Reference in a new issue