From aae6aeb142e92305c71ec392c6bf35d7d60a0317 Mon Sep 17 00:00:00 2001 From: Matthew Tretter Date: Thu, 14 Mar 2013 22:23:47 -0400 Subject: [PATCH] Add truthy/falsy file assertion utils --- tests/test_cachefiles.py | 5 +++-- tests/utils.py | 9 +++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/tests/test_cachefiles.py b/tests/test_cachefiles.py index 5db081f..6579e89 100644 --- a/tests/test_cachefiles.py +++ b/tests/test_cachefiles.py @@ -1,6 +1,7 @@ from imagekit.cachefiles import ImageCacheFile -from nose.tools import assert_false, raises +from nose.tools import raises from .imagegenerators import TestSpec +from .utils import assert_file_is_falsy def test_no_source(): @@ -9,7 +10,7 @@ def test_no_source(): """ spec = TestSpec(source=None) file = ImageCacheFile(spec) - assert_false(bool(file)) + assert_file_is_falsy(file) @raises(TestSpec.MissingSource) diff --git a/tests/utils.py b/tests/utils.py index 2763f8f..39f2271 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -4,6 +4,7 @@ from django.conf import settings from django.core.files import File from django.template import Context, Template from imagekit.lib import Image, StringIO +from nose.tools import assert_true, assert_false import pickle from .models import Photo @@ -53,3 +54,11 @@ def render_tag(ttag): def get_html_attrs(ttag): return BeautifulSoup(render_tag(ttag)).img.attrs + + +def assert_file_is_falsy(file): + assert_false(bool(file), 'File is not falsy') + + +def assert_file_is_truthy(file): + assert_true(bool(file), 'File is not truthy')