skipping tests requiring NamedTemporaryFile on windows.
Windows platform does not allow us to reopen the tempfile using its filesystem name, which really is necessary for use. Some pylint work
This commit is contained in:
parent
e6032a8b80
commit
1a14773447
14 changed files with 97 additions and 57 deletions
|
|
@ -17,8 +17,8 @@ def nemo():
|
||||||
file : str
|
file : str
|
||||||
Platform-independent path to nemo.jp2.
|
Platform-independent path to nemo.jp2.
|
||||||
"""
|
"""
|
||||||
file = pkg_resources.resource_filename(__name__, "nemo.jp2")
|
filename = pkg_resources.resource_filename(__name__, "nemo.jp2")
|
||||||
return file
|
return filename
|
||||||
|
|
||||||
|
|
||||||
def goodstuff():
|
def goodstuff():
|
||||||
|
|
@ -29,5 +29,5 @@ def goodstuff():
|
||||||
file : str
|
file : str
|
||||||
Platform-independent path to goodstuff.j2k.
|
Platform-independent path to goodstuff.j2k.
|
||||||
"""
|
"""
|
||||||
file = pkg_resources.resource_filename(__name__, "goodstuff.j2k")
|
filename = pkg_resources.resource_filename(__name__, "goodstuff.j2k")
|
||||||
return file
|
return filename
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
#pylint: disable-all
|
||||||
import doctest
|
import doctest
|
||||||
import os
|
import os
|
||||||
import pkg_resources
|
import pkg_resources
|
||||||
|
|
@ -12,6 +13,7 @@ import numpy as np
|
||||||
import glymur
|
import glymur
|
||||||
|
|
||||||
|
|
||||||
|
@unittest.skipIf(os.name == "nt", "Temporary file issue on window.")
|
||||||
@unittest.skipIf(glymur.lib._openjp2.OPENJP2 is None,
|
@unittest.skipIf(glymur.lib._openjp2.OPENJP2 is None,
|
||||||
"Missing openjp2 library.")
|
"Missing openjp2 library.")
|
||||||
class TestOpenJP2(unittest.TestCase):
|
class TestOpenJP2(unittest.TestCase):
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
#pylint: disable-all
|
||||||
import ctypes
|
import ctypes
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,19 +3,18 @@ import sys
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
||||||
def mse(A, B):
|
def mse(amat, bmat):
|
||||||
"""Mean Square Error"""
|
"""Mean Square Error"""
|
||||||
diff = A.astype(np.double) - B.astype(np.double)
|
diff = amat.astype(np.double) - bmat.astype(np.double)
|
||||||
#e = np.sqrt(np.mean(diff**2))
|
err = np.mean(diff**2)
|
||||||
e = np.mean(diff**2)
|
return err
|
||||||
return e
|
|
||||||
|
|
||||||
|
|
||||||
def peak_tolerance(A, B):
|
def peak_tolerance(amat, bmat):
|
||||||
"""Peak Tolerance"""
|
"""Peak Tolerance"""
|
||||||
diff = np.abs(A.astype(np.double) - B.astype(np.double))
|
diff = np.abs(amat.astype(np.double) - bmat.astype(np.double))
|
||||||
p = diff.max()
|
ptol = diff.max()
|
||||||
return p
|
return ptol
|
||||||
|
|
||||||
|
|
||||||
def read_pgx(pgx_file):
|
def read_pgx(pgx_file):
|
||||||
|
|
@ -28,42 +27,42 @@ def read_pgx(pgx_file):
|
||||||
PG%[ \t]%c%c%[ \t+-]%d%[ \t]%d%[ \t]%d"
|
PG%[ \t]%c%c%[ \t+-]%d%[ \t]%d%[ \t]%d"
|
||||||
"""
|
"""
|
||||||
header = ''
|
header = ''
|
||||||
with open(pgx_file, 'rb') as fp:
|
with open(pgx_file, 'rb') as fptr:
|
||||||
while True:
|
while True:
|
||||||
x = fp.read(1)
|
char = fptr.read(1)
|
||||||
if x[0] == 10 or x == '\n':
|
if char[0] == 10 or char == '\n':
|
||||||
pos = fp.tell()
|
pos = fptr.tell()
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
if sys.hexversion < 0x03000000:
|
if sys.hexversion < 0x03000000:
|
||||||
header += x
|
header += char
|
||||||
else:
|
else:
|
||||||
header += chr(x[0])
|
header += chr(char[0])
|
||||||
|
|
||||||
header = header.rstrip()
|
header = header.rstrip()
|
||||||
n = re.split('\s', header)
|
tokens = re.split('\s', header)
|
||||||
|
|
||||||
if (n[1][0] == 'M') and (sys.byteorder == 'little'):
|
if (tokens[1][0] == 'M') and (sys.byteorder == 'little'):
|
||||||
swapbytes = True
|
swapbytes = True
|
||||||
elif (n[1][0] == 'L') and (sys.byteorder == 'big'):
|
elif (tokens[1][0] == 'L') and (sys.byteorder == 'big'):
|
||||||
swapbytes = True
|
swapbytes = True
|
||||||
else:
|
else:
|
||||||
swapbytes = False
|
swapbytes = False
|
||||||
|
|
||||||
if (len(n) == 6):
|
if (len(tokens) == 6):
|
||||||
bitdepth = int(n[3])
|
bitdepth = int(tokens[3])
|
||||||
signed = bitdepth < 0
|
signed = bitdepth < 0
|
||||||
if signed:
|
if signed:
|
||||||
bitdepth = -1 * bitdepth
|
bitdepth = -1 * bitdepth
|
||||||
nrows = int(n[5])
|
nrows = int(tokens[5])
|
||||||
ncols = int(n[4])
|
ncols = int(tokens[4])
|
||||||
else:
|
else:
|
||||||
bitdepth = int(n[2])
|
bitdepth = int(tokens[2])
|
||||||
signed = bitdepth < 0
|
signed = bitdepth < 0
|
||||||
if signed:
|
if signed:
|
||||||
bitdepth = -1 * bitdepth
|
bitdepth = -1 * bitdepth
|
||||||
nrows = int(n[4])
|
nrows = int(tokens[4])
|
||||||
ncols = int(n[3])
|
ncols = int(tokens[3])
|
||||||
|
|
||||||
if signed:
|
if signed:
|
||||||
if bitdepth <= 8:
|
if bitdepth <= 8:
|
||||||
|
|
@ -84,9 +83,9 @@ def read_pgx(pgx_file):
|
||||||
|
|
||||||
# Reopen the file in binary mode and seek to the start of the binary
|
# Reopen the file in binary mode and seek to the start of the binary
|
||||||
# data
|
# data
|
||||||
with open(pgx_file, 'rb') as fp:
|
with open(pgx_file, 'rb') as fptr:
|
||||||
fp.seek(pos)
|
fptr.seek(pos)
|
||||||
data = np.fromfile(file=fp, dtype=dtype).reshape(shape)
|
data = np.fromfile(file=fptr, dtype=dtype).reshape(shape)
|
||||||
|
|
||||||
return(data.byteswap(swapbytes))
|
return(data.byteswap(swapbytes))
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
#pylint: disable-all
|
||||||
import os
|
import os
|
||||||
import pkg_resources
|
import pkg_resources
|
||||||
import re
|
import re
|
||||||
|
|
@ -29,6 +30,7 @@ class TestCallbacks(unittest.TestCase):
|
||||||
# Restore stdout.
|
# Restore stdout.
|
||||||
sys.stdout = self.stdout
|
sys.stdout = self.stdout
|
||||||
|
|
||||||
|
@unittest.skipIf(os.name == "nt", "Temporary file issue on window.")
|
||||||
def test_info_callback_on_write(self):
|
def test_info_callback_on_write(self):
|
||||||
# Verify the messages printed when writing an image in verbose mode.
|
# Verify the messages printed when writing an image in verbose mode.
|
||||||
j = glymur.Jp2k(self.jp2file)
|
j = glymur.Jp2k(self.jp2file)
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
#pylint: disable-all
|
||||||
import os
|
import os
|
||||||
import struct
|
import struct
|
||||||
import sys
|
import sys
|
||||||
|
|
@ -29,6 +30,7 @@ class TestCodestream(unittest.TestCase):
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@unittest.skipIf(os.name == "nt", "Temporary file issue on window.")
|
||||||
def test_reserved_marker_segment(self):
|
def test_reserved_marker_segment(self):
|
||||||
# Some marker segments were reserved in FCD15444-1. Since that
|
# Some marker segments were reserved in FCD15444-1. Since that
|
||||||
# standard is old, some of them may have come into use.
|
# standard is old, some of them may have come into use.
|
||||||
|
|
@ -58,6 +60,7 @@ class TestCodestream(unittest.TestCase):
|
||||||
self.assertEqual(c.segment[2].length, 3)
|
self.assertEqual(c.segment[2].length, 3)
|
||||||
self.assertEqual(c.segment[2]._data, b'\x00')
|
self.assertEqual(c.segment[2]._data, b'\x00')
|
||||||
|
|
||||||
|
@unittest.skipIf(os.name == "nt", "Temporary file issue on window.")
|
||||||
@unittest.skipIf(sys.hexversion < 0x03020000,
|
@unittest.skipIf(sys.hexversion < 0x03020000,
|
||||||
"Uses features introduced in 3.2.")
|
"Uses features introduced in 3.2.")
|
||||||
def test_unknown_marker_segment(self):
|
def test_unknown_marker_segment(self):
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
"""These tests are for edge cases where OPENJPEG does not exist, but
|
"""These tests are for edge cases where OPENJPEG does not exist, but
|
||||||
OPENJP2 may be present in some form or other.
|
OPENJP2 may be present in some form or other.
|
||||||
"""
|
"""
|
||||||
|
#pylint: disable-all
|
||||||
|
|
||||||
import imp
|
import imp
|
||||||
import os
|
import os
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
#pylint: disable-all
|
||||||
import datetime
|
import datetime
|
||||||
import os
|
import os
|
||||||
import struct
|
import struct
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
#pylint: disable-all
|
||||||
import doctest
|
import doctest
|
||||||
import os
|
import os
|
||||||
import tempfile
|
import tempfile
|
||||||
|
|
@ -14,10 +15,14 @@ from glymur.jp2box import *
|
||||||
|
|
||||||
# Doc tests should be run as well.
|
# Doc tests should be run as well.
|
||||||
def load_tests(loader, tests, ignore):
|
def load_tests(loader, tests, ignore):
|
||||||
|
if os.name == "nt":
|
||||||
|
# Can't do it on windows, temporary file issue.
|
||||||
|
return tests
|
||||||
tests.addTests(doctest.DocTestSuite('glymur.jp2box'))
|
tests.addTests(doctest.DocTestSuite('glymur.jp2box'))
|
||||||
return tests
|
return tests
|
||||||
|
|
||||||
|
|
||||||
|
@unittest.skipIf(os.name == "nt", "Temporary file issue on window.")
|
||||||
@unittest.skipIf(glymur.lib.openjp2.OPENJP2 is None,
|
@unittest.skipIf(glymur.lib.openjp2.OPENJP2 is None,
|
||||||
"Missing openjp2 library.")
|
"Missing openjp2 library.")
|
||||||
class TestChannelDefinition(unittest.TestCase):
|
class TestChannelDefinition(unittest.TestCase):
|
||||||
|
|
@ -232,6 +237,7 @@ class TestChannelDefinition(unittest.TestCase):
|
||||||
association=[1, 2, 3])
|
association=[1, 2, 3])
|
||||||
|
|
||||||
|
|
||||||
|
@unittest.skipIf(os.name == "nt", "Temporary file issue on window.")
|
||||||
class TestXML(unittest.TestCase):
|
class TestXML(unittest.TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
|
@ -370,6 +376,7 @@ class TestColourSpecificationBox(unittest.TestCase):
|
||||||
with self.assertRaises(NotImplementedError):
|
with self.assertRaises(NotImplementedError):
|
||||||
j2k.wrap(tfile.name, boxes=boxes)
|
j2k.wrap(tfile.name, boxes=boxes)
|
||||||
|
|
||||||
|
@unittest.skipIf(os.name == "nt", "Temporary file issue on window.")
|
||||||
def test_missing_colr_box(self):
|
def test_missing_colr_box(self):
|
||||||
j2k = Jp2k(self.j2kfile)
|
j2k = Jp2k(self.j2kfile)
|
||||||
boxes = [self.jP, self.ftyp, self.jp2h, self.jp2c]
|
boxes = [self.jP, self.ftyp, self.jp2h, self.jp2c]
|
||||||
|
|
@ -501,12 +508,14 @@ class TestJp2Boxes(unittest.TestCase):
|
||||||
self.assertEqual(jp2.box[2].box[1].colorspace, glymur.core.SRGB)
|
self.assertEqual(jp2.box[2].box[1].colorspace, glymur.core.SRGB)
|
||||||
self.assertIsNone(jp2.box[2].box[1].icc_profile)
|
self.assertIsNone(jp2.box[2].box[1].icc_profile)
|
||||||
|
|
||||||
|
@unittest.skipIf(os.name == "nt", "Temporary file issue on window.")
|
||||||
def test_wrap(self):
|
def test_wrap(self):
|
||||||
j2k = Jp2k(self.j2kfile)
|
j2k = Jp2k(self.j2kfile)
|
||||||
with tempfile.NamedTemporaryFile(suffix=".jp2") as tfile:
|
with tempfile.NamedTemporaryFile(suffix=".jp2") as tfile:
|
||||||
j2k.wrap(tfile.name)
|
j2k.wrap(tfile.name)
|
||||||
self.verify_wrapped_raw(tfile.name)
|
self.verify_wrapped_raw(tfile.name)
|
||||||
|
|
||||||
|
@unittest.skipIf(os.name == "nt", "Temporary file issue on window.")
|
||||||
def test_wrap_jp2(self):
|
def test_wrap_jp2(self):
|
||||||
j2k = Jp2k(self.j2kfile)
|
j2k = Jp2k(self.j2kfile)
|
||||||
with tempfile.NamedTemporaryFile(suffix=".jp2") as tfile:
|
with tempfile.NamedTemporaryFile(suffix=".jp2") as tfile:
|
||||||
|
|
@ -514,6 +523,7 @@ class TestJp2Boxes(unittest.TestCase):
|
||||||
boxes = [box.box_id for box in jp2.box]
|
boxes = [box.box_id for box in jp2.box]
|
||||||
self.assertEqual(boxes, ['jP ', 'ftyp', 'jp2h', 'jp2c'])
|
self.assertEqual(boxes, ['jP ', 'ftyp', 'jp2h', 'jp2c'])
|
||||||
|
|
||||||
|
@unittest.skipIf(os.name == "nt", "Temporary file issue on window.")
|
||||||
def test_default_layout_but_with_specified_boxes(self):
|
def test_default_layout_but_with_specified_boxes(self):
|
||||||
j2k = Jp2k(self.j2kfile)
|
j2k = Jp2k(self.j2kfile)
|
||||||
boxes = [JPEG2000SignatureBox(),
|
boxes = [JPEG2000SignatureBox(),
|
||||||
|
|
@ -532,6 +542,7 @@ class TestJp2Boxes(unittest.TestCase):
|
||||||
j2k.wrap(tfile.name, boxes=boxes)
|
j2k.wrap(tfile.name, boxes=boxes)
|
||||||
self.verify_wrapped_raw(tfile.name)
|
self.verify_wrapped_raw(tfile.name)
|
||||||
|
|
||||||
|
@unittest.skipIf(os.name == "nt", "Temporary file issue on window.")
|
||||||
def test_image_header_box_not_first_in_jp2_header(self):
|
def test_image_header_box_not_first_in_jp2_header(self):
|
||||||
# The specification says that ihdr must be the first box in jp2h.
|
# The specification says that ihdr must be the first box in jp2h.
|
||||||
j2k = Jp2k(self.j2kfile)
|
j2k = Jp2k(self.j2kfile)
|
||||||
|
|
@ -551,6 +562,7 @@ class TestJp2Boxes(unittest.TestCase):
|
||||||
with self.assertRaises(IOError):
|
with self.assertRaises(IOError):
|
||||||
j2k.wrap(tfile.name, boxes=boxes)
|
j2k.wrap(tfile.name, boxes=boxes)
|
||||||
|
|
||||||
|
@unittest.skipIf(os.name == "nt", "Temporary file issue on window.")
|
||||||
def test_first_2_boxes_not_jP_and_ftyp(self):
|
def test_first_2_boxes_not_jP_and_ftyp(self):
|
||||||
j2k = Jp2k(self.j2kfile)
|
j2k = Jp2k(self.j2kfile)
|
||||||
c = j2k.get_codestream()
|
c = j2k.get_codestream()
|
||||||
|
|
@ -571,6 +583,7 @@ class TestJp2Boxes(unittest.TestCase):
|
||||||
with self.assertRaises(IOError):
|
with self.assertRaises(IOError):
|
||||||
j2k.wrap(tfile.name, boxes=boxes)
|
j2k.wrap(tfile.name, boxes=boxes)
|
||||||
|
|
||||||
|
@unittest.skipIf(os.name == "nt", "Temporary file issue on window.")
|
||||||
def test_jp2h_not_preceeding_jp2c(self):
|
def test_jp2h_not_preceeding_jp2c(self):
|
||||||
j2k = Jp2k(self.j2kfile)
|
j2k = Jp2k(self.j2kfile)
|
||||||
c = j2k.get_codestream()
|
c = j2k.get_codestream()
|
||||||
|
|
@ -591,6 +604,7 @@ class TestJp2Boxes(unittest.TestCase):
|
||||||
with self.assertRaises(IOError):
|
with self.assertRaises(IOError):
|
||||||
j2k.wrap(tfile.name, boxes=boxes)
|
j2k.wrap(tfile.name, boxes=boxes)
|
||||||
|
|
||||||
|
@unittest.skipIf(os.name == "nt", "Temporary file issue on window.")
|
||||||
def test_missing_codestream(self):
|
def test_missing_codestream(self):
|
||||||
j2k = Jp2k(self.j2kfile)
|
j2k = Jp2k(self.j2kfile)
|
||||||
c = j2k.get_codestream()
|
c = j2k.get_codestream()
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,5 @@
|
||||||
import contextlib
|
# pylint: disable-all
|
||||||
import ctypes
|
|
||||||
import doctest
|
import doctest
|
||||||
import imp
|
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import shutil
|
import shutil
|
||||||
|
|
@ -33,6 +31,9 @@ except:
|
||||||
|
|
||||||
# Doc tests should be run as well.
|
# Doc tests should be run as well.
|
||||||
def load_tests(loader, tests, ignore):
|
def load_tests(loader, tests, ignore):
|
||||||
|
if os.name == "nt":
|
||||||
|
# Can't do it on windows, temporary file issue.
|
||||||
|
return tests
|
||||||
if glymur.lib.openjp2.OPENJP2 is not None:
|
if glymur.lib.openjp2.OPENJP2 is not None:
|
||||||
tests.addTests(doctest.DocTestSuite('glymur.jp2k'))
|
tests.addTests(doctest.DocTestSuite('glymur.jp2k'))
|
||||||
return tests
|
return tests
|
||||||
|
|
@ -671,42 +672,48 @@ class TestJp2k15(unittest.TestCase):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def test_bands(self):
|
def test_bands(self):
|
||||||
# Reading individual bands is an advanced maneuver.
|
"""Reading individual bands is an advanced maneuver.
|
||||||
|
"""
|
||||||
jp2k = Jp2k(self.j2kfile)
|
jp2k = Jp2k(self.j2kfile)
|
||||||
with self.assertRaises(NotImplementedError) as ce:
|
with self.assertRaises(NotImplementedError):
|
||||||
jpdata = jp2k.read_bands()
|
jp2k.read_bands()
|
||||||
|
|
||||||
def test_area(self):
|
def test_area(self):
|
||||||
# Area option not allowed for 1.5.1.
|
"""Area option not allowed for 1.5.1.
|
||||||
|
"""
|
||||||
j2k = Jp2k(self.j2kfile)
|
j2k = Jp2k(self.j2kfile)
|
||||||
with self.assertRaises(TypeError) as ce:
|
with self.assertRaises(TypeError):
|
||||||
d = j2k.read(area=(0, 0, 100, 100))
|
j2k.read(area=(0, 0, 100, 100))
|
||||||
|
|
||||||
def test_tile(self):
|
def test_tile(self):
|
||||||
# tile option not allowed for 1.5.1.
|
"""tile option not allowed for 1.5.1.
|
||||||
|
"""
|
||||||
j2k = Jp2k(self.j2kfile)
|
j2k = Jp2k(self.j2kfile)
|
||||||
with self.assertRaises(TypeError) as ce:
|
with self.assertRaises(TypeError):
|
||||||
d = j2k.read(tile=0)
|
j2k.read(tile=0)
|
||||||
|
|
||||||
def test_layer(self):
|
def test_layer(self):
|
||||||
# layer option not allowed for 1.5.1.
|
"""layer option not allowed for 1.5.1.
|
||||||
|
"""
|
||||||
j2k = Jp2k(self.j2kfile)
|
j2k = Jp2k(self.j2kfile)
|
||||||
with self.assertRaises(TypeError) as ce:
|
with self.assertRaises(TypeError):
|
||||||
d = j2k.read(layer=1)
|
j2k.read(layer=1)
|
||||||
|
|
||||||
def test_basic_jp2(self):
|
def test_basic_jp2(self):
|
||||||
# This test is only useful when openjp2 is not available
|
"""This test is only useful when openjp2 is not available
|
||||||
# and OPJ_DATA_ROOT is not set. We need at least one
|
and OPJ_DATA_ROOT is not set. We need at least one
|
||||||
# working JP2 test.
|
working JP2 test.
|
||||||
|
"""
|
||||||
j2k = Jp2k(self.jp2file)
|
j2k = Jp2k(self.jp2file)
|
||||||
d = j2k.read(rlevel=1)
|
j2k.read(rlevel=1)
|
||||||
|
|
||||||
def test_basic_j2k(self):
|
def test_basic_j2k(self):
|
||||||
# This test is only useful when openjp2 is not available
|
"""This test is only useful when openjp2 is not available
|
||||||
# and OPJ_DATA_ROOT is not set. We need at least one
|
and OPJ_DATA_ROOT is not set. We need at least one
|
||||||
# working J2K test.
|
working J2K test.
|
||||||
|
"""
|
||||||
j2k = Jp2k(self.j2kfile)
|
j2k = Jp2k(self.j2kfile)
|
||||||
d = j2k.read()
|
j2k.read()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
The tests defined here roughly correspond to what is in the OpenJPEG test
|
The tests defined here roughly correspond to what is in the OpenJPEG test
|
||||||
suite.
|
suite.
|
||||||
"""
|
"""
|
||||||
|
#pylint: disable-all
|
||||||
|
|
||||||
from contextlib import contextmanager
|
from contextlib import contextmanager
|
||||||
import os
|
import os
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
The tests here do not correspond directly to the OpenJPEG test suite, but
|
The tests here do not correspond directly to the OpenJPEG test suite, but
|
||||||
seem like logical negative tests to add.
|
seem like logical negative tests to add.
|
||||||
"""
|
"""
|
||||||
|
#pylint: disable-all
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import tempfile
|
import tempfile
|
||||||
|
|
@ -71,6 +72,7 @@ class TestSuiteNegative(unittest.TestCase):
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@unittest.skipIf(os.name == "nt", "Temporary file issue on window.")
|
||||||
def test_negative_psnr_with_cratios(self):
|
def test_negative_psnr_with_cratios(self):
|
||||||
# Using psnr with cratios options is not allowed.
|
# Using psnr with cratios options is not allowed.
|
||||||
# Not an OpenJPEG test, but close.
|
# Not an OpenJPEG test, but close.
|
||||||
|
|
@ -126,6 +128,7 @@ class TestSuiteNegative(unittest.TestCase):
|
||||||
# the end of SOT.
|
# the end of SOT.
|
||||||
self.assertEqual(c.segment[-1].marker_id, 'SOD')
|
self.assertEqual(c.segment[-1].marker_id, 'SOD')
|
||||||
|
|
||||||
|
@unittest.skipIf(os.name == "nt", "Temporary file issue on window.")
|
||||||
def test_code_block_dimensions(self):
|
def test_code_block_dimensions(self):
|
||||||
# opj_compress doesn't allow the dimensions of a codeblock
|
# opj_compress doesn't allow the dimensions of a codeblock
|
||||||
# to be too small or too big, so neither will we.
|
# to be too small or too big, so neither will we.
|
||||||
|
|
@ -154,6 +157,7 @@ class TestSuiteNegative(unittest.TestCase):
|
||||||
with self.assertWarns(UserWarning) as cw:
|
with self.assertWarns(UserWarning) as cw:
|
||||||
j = Jp2k(infile)
|
j = Jp2k(infile)
|
||||||
|
|
||||||
|
@unittest.skipIf(os.name == "nt", "Temporary file issue on window.")
|
||||||
def test_precinct_size_not_multiple_of_two(self):
|
def test_precinct_size_not_multiple_of_two(self):
|
||||||
# Seems like precinct sizes should be powers of two.
|
# Seems like precinct sizes should be powers of two.
|
||||||
ifile = Jp2k(self.j2kfile)
|
ifile = Jp2k(self.j2kfile)
|
||||||
|
|
@ -163,6 +167,7 @@ class TestSuiteNegative(unittest.TestCase):
|
||||||
with self.assertRaises(IOError) as ce:
|
with self.assertRaises(IOError) as ce:
|
||||||
ofile.write(data, psizes=[(13, 13)])
|
ofile.write(data, psizes=[(13, 13)])
|
||||||
|
|
||||||
|
@unittest.skipIf(os.name == "nt", "Temporary file issue on window.")
|
||||||
def test_codeblock_size_not_multiple_of_two(self):
|
def test_codeblock_size_not_multiple_of_two(self):
|
||||||
# Seems like code block sizes should be powers of two.
|
# Seems like code block sizes should be powers of two.
|
||||||
ifile = Jp2k(self.j2kfile)
|
ifile = Jp2k(self.j2kfile)
|
||||||
|
|
@ -172,6 +177,7 @@ class TestSuiteNegative(unittest.TestCase):
|
||||||
with self.assertRaises(IOError) as ce:
|
with self.assertRaises(IOError) as ce:
|
||||||
ofile.write(data, cbsize=(13, 12))
|
ofile.write(data, cbsize=(13, 12))
|
||||||
|
|
||||||
|
@unittest.skipIf(os.name == "nt", "Temporary file issue on window.")
|
||||||
def test_codeblock_size_with_precinct_size(self):
|
def test_codeblock_size_with_precinct_size(self):
|
||||||
# Seems like code block sizes should never exceed half that of
|
# Seems like code block sizes should never exceed half that of
|
||||||
# precinct size.
|
# precinct size.
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
The tests defined here roughly correspond to what is in the OpenJPEG test
|
The tests defined here roughly correspond to what is in the OpenJPEG test
|
||||||
suite.
|
suite.
|
||||||
"""
|
"""
|
||||||
|
#pylint: disable-all
|
||||||
import os
|
import os
|
||||||
import platform
|
import platform
|
||||||
import sys
|
import sys
|
||||||
|
|
@ -57,6 +58,7 @@ def read_image(infile):
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
|
||||||
|
@unittest.skipIf(os.name == "nt", "no write support on windows, period")
|
||||||
@unittest.skipIf(glymur.lib.openjp2.OPENJP2 is None,
|
@unittest.skipIf(glymur.lib.openjp2.OPENJP2 is None,
|
||||||
"Missing openjp2 library.")
|
"Missing openjp2 library.")
|
||||||
@unittest.skipIf(no_read_backend, no_read_backend_msg)
|
@unittest.skipIf(no_read_backend, no_read_backend_msg)
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
#pylint: disable-all
|
||||||
import os
|
import os
|
||||||
import pkg_resources
|
import pkg_resources
|
||||||
import struct
|
import struct
|
||||||
|
|
@ -21,6 +22,7 @@ except:
|
||||||
raise
|
raise
|
||||||
|
|
||||||
|
|
||||||
|
@unittest.skipIf(os.name == "nt", "Temporary file issue on window.")
|
||||||
@unittest.skipIf(glymur.lib.openjp2.OPENJP2 is None,
|
@unittest.skipIf(glymur.lib.openjp2.OPENJP2 is None,
|
||||||
"Missing openjp2 library.")
|
"Missing openjp2 library.")
|
||||||
class TestPrintingNeedsLib(unittest.TestCase):
|
class TestPrintingNeedsLib(unittest.TestCase):
|
||||||
|
|
@ -782,8 +784,7 @@ class TestPrinting(unittest.TestCase):
|
||||||
expected = '\n'.join(lines)
|
expected = '\n'.join(lines)
|
||||||
self.assertEqual(actual, expected)
|
self.assertEqual(actual, expected)
|
||||||
|
|
||||||
@unittest.skipIf(os.name == "nt",
|
@unittest.skipIf(os.name == "nt", "Temporary file issue on window.")
|
||||||
"Problems using NamedTemporaryFile on windows.")
|
|
||||||
def test_less_common_boxes(self):
|
def test_less_common_boxes(self):
|
||||||
with tempfile.NamedTemporaryFile(suffix='.jp2') as tfile:
|
with tempfile.NamedTemporaryFile(suffix='.jp2') as tfile:
|
||||||
with open(self.jp2file, 'rb') as ifile:
|
with open(self.jp2file, 'rb') as ifile:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue