Skip to content

Commit

Permalink
tests/common: move assert_image*() here.
Browse files Browse the repository at this point in the history
  • Loading branch information
jwilk committed Jun 8, 2015
1 parent ffadbc3 commit ae9d242
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
13 changes: 13 additions & 0 deletions tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)$',
Expand Down Expand Up @@ -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',
Expand Down
13 changes: 2 additions & 11 deletions tests/test_djvu.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
from . common import (
assert_equal,
assert_greater,
assert_image_sizes_equal,
assert_images_equal,
assert_true,
exception,
)
Expand All @@ -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(
Expand Down

0 comments on commit ae9d242

Please sign in to comment.