Extract utils for use in other modules

This commit is contained in:
Matthew Tretter 2013-01-08 23:36:22 -05:00
parent 11d511f9cc
commit 3177eb8e19
2 changed files with 15 additions and 14 deletions

View file

@ -1,19 +1,7 @@
from bs4 import BeautifulSoup
from django.template import Context, Template, TemplateSyntaxError
from django.template import TemplateSyntaxError
from nose.tools import eq_, assert_not_in, raises, assert_not_equal
from . import imagespecs # noqa
from .utils import get_image_file
def render_tag(ttag):
img = get_image_file()
template = Template('{%% load imagekit %%}%s' % ttag)
context = Context({'img': img})
return template.render(context)
def get_html_attrs(ttag):
return BeautifulSoup(render_tag(ttag)).img.attrs
from .utils import render_tag, get_html_attrs
def test_img_tag():

View file

@ -1,6 +1,8 @@
from bs4 import BeautifulSoup
import os
from django.conf import settings
from django.core.files.base import ContentFile
from django.template import Context, Template
from imagekit.lib import Image, StringIO
import pickle
from .models import Photo
@ -42,3 +44,14 @@ def pickleback(obj):
pickle.dump(obj, pickled)
pickled.seek(0)
return pickle.load(pickled)
def render_tag(ttag):
img = get_image_file()
template = Template('{%% load imagekit %%}%s' % ttag)
context = Context({'img': img})
return template.render(context)
def get_html_attrs(ttag):
return BeautifulSoup(render_tag(ttag)).img.attrs