From ae9d24267b638d7fb8100189dd67f06835e44f6f Mon Sep 17 00:00:00 2001 From: Jakub Wilk Date: Mon, 8 Jun 2015 22:05:19 +0200 Subject: [PATCH] tests/common: move assert_image*() here. --- tests/common.py | 13 +++++++++++++ tests/test_djvu.py | 13 ++----------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/tests/common.py b/tests/common.py index 7591ac5..948e520 100644 --- a/tests/common.py +++ b/tests/common.py @@ -71,6 +71,17 @@ def assert_regexp_matches(regexp, text): message = "Regexp didn't match: {0!r} not found in {1!r}".format(regexp.pattern, text) raise AssertionError(message) +def assert_image_sizes_equal(i1, i2): + assert_equal(i1.size, i2.size) + +def assert_images_equal(i1, i2): + assert_equal(i1.size, i2.size) + assert_true( + list(i1.getdata()) == + list(i2.getdata()), + msg='images are not equal' + ) + def assert_rfc3339_timestamp(timestamp): return assert_regexp_matches( '^[0-9]{4}(-[0-9]{2}){2}T[0-9]{2}(:[0-9]{2}){2}([+-][0-9]{2}:[0-9]{2}|Z)$', @@ -200,6 +211,8 @@ def fork_isolation(f): 'assert_equal', 'assert_false', 'assert_greater', + 'assert_image_sizes_equal', + 'assert_images_equal', 'assert_is', 'assert_is_instance', 'assert_is_none', diff --git a/tests/test_djvu.py b/tests/test_djvu.py index f92d40e..2535b5b 100644 --- a/tests/test_djvu.py +++ b/tests/test_djvu.py @@ -18,6 +18,8 @@ from . common import ( assert_equal, assert_greater, + assert_image_sizes_equal, + assert_images_equal, assert_true, exception, ) @@ -33,17 +35,6 @@ def setup_module(): djvu.require_cli() -def assert_image_sizes_equal(i1, i2): - assert_equal(i1.size, i2.size) - -def assert_images_equal(i1, i2): - assert_equal(i1.size, i2.size) - assert_true( - list(i1.getdata()) == - list(i2.getdata()), - msg='images are not equal' - ) - def ddjvu(djvu_file, fmt='ppm'): cmdline = ['ddjvu', '-1', '-format=' + fmt] stdio = dict(