skipping warning tests where six package < 1.7.0
Those versions of six cause problems for python3.
This commit is contained in:
parent
60d24aa2e6
commit
95448daa2e
17 changed files with 160 additions and 54 deletions
|
|
@ -8,9 +8,14 @@ import textwrap
|
|||
import warnings
|
||||
|
||||
import numpy as np
|
||||
import six
|
||||
|
||||
import glymur
|
||||
|
||||
# Some versions of "six" on python3 cause problems when verifying warnings.
|
||||
# Only use when the version is 1.7 or higher.
|
||||
CANNOT_USE_WITH_SIX = ((sys.hexversion >= 0x03000000) and
|
||||
(re.match('1.[0-6]', six.__version__) is not None))
|
||||
|
||||
# The Python XMP Toolkit may be used for XMP UUIDs, but only if available and
|
||||
# if the version is at least 2.0.0.
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ else:
|
|||
|
||||
import glymur
|
||||
|
||||
from .fixtures import CANNOT_USE_WITH_SIX
|
||||
|
||||
@unittest.skipIf(glymur.lib.openjp2.OPENJP2 is None,
|
||||
"Missing openjp2 library.")
|
||||
|
|
@ -36,6 +37,7 @@ class TestCallbacks(unittest.TestCase):
|
|||
def tearDown(self):
|
||||
pass
|
||||
|
||||
@unittest.skipIf(CANNOT_USE_WITH_SIX, "Cannot use this version of six.")
|
||||
@unittest.skipIf(os.name == "nt", "Temporary file issue on window.")
|
||||
def test_info_callback_on_write(self):
|
||||
"""Verify messages printed when writing an image in verbose mode."""
|
||||
|
|
|
|||
|
|
@ -5,9 +5,6 @@ Test suite for codestream parsing.
|
|||
# unittest doesn't work well with R0904.
|
||||
# pylint: disable=R0904
|
||||
|
||||
# tempfile.TemporaryDirectory, unittest.assertWarns introduced in 3.2
|
||||
# pylint: disable=E1101
|
||||
|
||||
import os
|
||||
import struct
|
||||
import sys
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ else:
|
|||
import glymur
|
||||
from glymur import Jp2k
|
||||
|
||||
from .fixtures import CANNOT_USE_WITH_SIX
|
||||
|
||||
@unittest.skipIf(sys.hexversion < 0x03020000,
|
||||
"TemporaryDirectory introduced in 3.2.")
|
||||
|
|
@ -69,6 +70,7 @@ class TestSuite(unittest.TestCase):
|
|||
imp.reload(glymur.lib.openjp2)
|
||||
Jp2k(self.jp2file)
|
||||
|
||||
@unittest.skipIf(CANNOT_USE_WITH_SIX, "Cannot use this version of six.")
|
||||
def test_xdg_env_config_file_is_bad(self):
|
||||
"""A non-existant library location should be rejected."""
|
||||
with tempfile.TemporaryDirectory() as tdir:
|
||||
|
|
|
|||
|
|
@ -18,13 +18,13 @@ import six
|
|||
from glymur import Jp2k
|
||||
import glymur
|
||||
|
||||
from .fixtures import opj_data_file, OPJ_DATA_ROOT
|
||||
from .fixtures import opj_data_file, OPJ_DATA_ROOT, CANNOT_USE_WITH_SIX
|
||||
|
||||
@unittest.skipIf(sys.hexversion < 0x03040000 and platform.system() == 'Linux',
|
||||
"inexplicable failures on 3.3 and linux")
|
||||
@unittest.skipIf(sys.hexversion < 0x03030000,
|
||||
"assertWarn methods introduced in 3.x")
|
||||
@unittest.skipIf(re.match('1.[0-6]', six.__version__) is not None,
|
||||
@unittest.skipIf(CANNOT_USE_WITH_SIX,
|
||||
"Problem with earlier versions of six on python3")
|
||||
@unittest.skipIf(OPJ_DATA_ROOT is None,
|
||||
"OPJ_DATA_ROOT environment variable not set")
|
||||
|
|
|
|||
|
|
@ -13,9 +13,10 @@ import unittest
|
|||
import numpy as np
|
||||
|
||||
from glymur import Jp2k
|
||||
from .fixtures import OPJ_DATA_ROOT, opj_data_file
|
||||
from .fixtures import OPJ_DATA_ROOT, opj_data_file, CANNOT_USE_WITH_SIX
|
||||
|
||||
|
||||
@unittest.skipIf(CANNOT_USE_WITH_SIX, "Cannot use this version of six.")
|
||||
@unittest.skipIf(OPJ_DATA_ROOT is None,
|
||||
"OPJ_DATA_ROOT environment variable not set")
|
||||
class TestICC(unittest.TestCase):
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ from glymur.jp2box import JPEG2000SignatureBox
|
|||
from glymur.core import COLOR, OPACITY
|
||||
from glymur.core import RED, GREEN, BLUE, GREY, WHOLE_IMAGE
|
||||
|
||||
from .fixtures import opj_data_file
|
||||
from .fixtures import opj_data_file, CANNOT_USE_WITH_SIX
|
||||
|
||||
try:
|
||||
FORMAT_CORPUS_DATA_ROOT = os.environ['FORMAT_CORPUS_DATA_ROOT']
|
||||
|
|
@ -356,6 +356,7 @@ class TestChannelDefinition(unittest.TestCase):
|
|||
with self.assertRaises((IOError, OSError)):
|
||||
j2k.wrap(tfile.name, boxes=boxes)
|
||||
|
||||
@unittest.skipIf(CANNOT_USE_WITH_SIX, "Cannot use this version of six.")
|
||||
def test_bad_type(self):
|
||||
"""Channel types are limited to 0, 1, 2, 65535
|
||||
Should reject if not all of index, channel_type, association the
|
||||
|
|
@ -368,6 +369,7 @@ class TestChannelDefinition(unittest.TestCase):
|
|||
glymur.jp2box.ChannelDefinitionBox(channel_type=channel_type,
|
||||
association=association)
|
||||
|
||||
@unittest.skipIf(CANNOT_USE_WITH_SIX, "Cannot use this version of six.")
|
||||
def test_wrong_lengths(self):
|
||||
"""Should reject if not all of index, channel_type, association the
|
||||
same length.
|
||||
|
|
@ -388,6 +390,7 @@ class TestFileTypeBox(unittest.TestCase):
|
|||
def tearDown(self):
|
||||
pass
|
||||
|
||||
@unittest.skipIf(CANNOT_USE_WITH_SIX, "Cannot use this version of six.")
|
||||
def test_brand_unknown(self):
|
||||
"""A ftyp box brand must be 'jp2 ' or 'jpx '."""
|
||||
with self.assertWarns(UserWarning):
|
||||
|
|
@ -396,6 +399,7 @@ class TestFileTypeBox(unittest.TestCase):
|
|||
with tempfile.TemporaryFile() as tfile:
|
||||
ftyp.write(tfile)
|
||||
|
||||
@unittest.skipIf(CANNOT_USE_WITH_SIX, "Cannot use this version of six.")
|
||||
def test_cl_entry_unknown(self):
|
||||
"""A ftyp box cl list can only contain 'jp2 ', 'jpx ', or 'jpxb'."""
|
||||
with self.assertWarns(UserWarning):
|
||||
|
|
@ -470,6 +474,7 @@ class TestColourSpecificationBox(unittest.TestCase):
|
|||
self.assertEqual(colr.colorspace, glymur.core.SRGB)
|
||||
self.assertIsNone(colr.icc_profile)
|
||||
|
||||
@unittest.skipIf(CANNOT_USE_WITH_SIX, "Cannot use this version of six.")
|
||||
def test_colr_with_cspace_and_icc(self):
|
||||
"""Colour specification boxes can't have both."""
|
||||
regex = 'Colorspace and icc_profile cannot both be set'
|
||||
|
|
@ -479,6 +484,7 @@ class TestColourSpecificationBox(unittest.TestCase):
|
|||
glymur.jp2box.ColourSpecificationBox(colorspace=colorspace,
|
||||
icc_profile=rawb)
|
||||
|
||||
@unittest.skipIf(CANNOT_USE_WITH_SIX, "Cannot use this version of six.")
|
||||
def test_colr_with_bad_method(self):
|
||||
"""colr must have a valid method field"""
|
||||
colorspace = glymur.core.SRGB
|
||||
|
|
@ -488,6 +494,7 @@ class TestColourSpecificationBox(unittest.TestCase):
|
|||
glymur.jp2box.ColourSpecificationBox(colorspace=colorspace,
|
||||
method=method)
|
||||
|
||||
@unittest.skipIf(CANNOT_USE_WITH_SIX, "Cannot use this version of six.")
|
||||
def test_colr_with_bad_approx(self):
|
||||
"""colr should have a valid approximation field"""
|
||||
colorspace = glymur.core.SRGB
|
||||
|
|
@ -518,6 +525,7 @@ class TestPaletteBox(unittest.TestCase):
|
|||
def tearDown(self):
|
||||
pass
|
||||
|
||||
@unittest.skipIf(CANNOT_USE_WITH_SIX, "Cannot use this version of six.")
|
||||
def test_mismatched_bitdepth_signed(self):
|
||||
"""bitdepth and signed arguments must have equal length"""
|
||||
palette = np.array([[255, 0, 255], [0, 255, 0]], dtype=np.uint8)
|
||||
|
|
@ -527,6 +535,7 @@ class TestPaletteBox(unittest.TestCase):
|
|||
pclr = glymur.jp2box.PaletteBox(palette, bits_per_component=bps,
|
||||
signed=signed)
|
||||
|
||||
@unittest.skipIf(CANNOT_USE_WITH_SIX, "Cannot use this version of six.")
|
||||
def test_mismatched_signed_palette(self):
|
||||
"""bitdepth and signed arguments must have equal length"""
|
||||
palette = np.array([[255, 0, 255], [0, 255, 0]], dtype=np.uint8)
|
||||
|
|
|
|||
|
|
@ -18,6 +18,8 @@ from glymur.jp2box import DataEntryURLBox, FileTypeBox, JPEG2000SignatureBox
|
|||
from glymur.jp2box import DataReferenceBox, FragmentListBox, FragmentTableBox
|
||||
from glymur.jp2box import ColourSpecificationBox
|
||||
|
||||
from .fixtures import CANNOT_USE_WITH_SIX
|
||||
|
||||
@unittest.skipIf(os.name == "nt", "Temporary file issue on window.")
|
||||
class TestJPXWrap(unittest.TestCase):
|
||||
"""Test suite for wrapping JPX files."""
|
||||
|
|
@ -304,6 +306,7 @@ class TestJPXWrap(unittest.TestCase):
|
|||
with self.assertRaises(IOError):
|
||||
jp2.wrap(tfile.name, boxes=boxes)
|
||||
|
||||
@unittest.skipIf(CANNOT_USE_WITH_SIX, "Cannot use this version of six.")
|
||||
def test_deurl_child_of_dtbl(self):
|
||||
"""Data reference boxes can only contain data entry url boxes."""
|
||||
jp2 = Jp2k(self.jp2file)
|
||||
|
|
@ -429,6 +432,7 @@ class TestJPX(unittest.TestCase):
|
|||
def tearDown(self):
|
||||
pass
|
||||
|
||||
@unittest.skipIf(CANNOT_USE_WITH_SIX, "Cannot use this version of six.")
|
||||
def test_flst_lens_not_the_same(self):
|
||||
"""A fragment list box items must be the same length."""
|
||||
offset = [89]
|
||||
|
|
@ -440,6 +444,7 @@ class TestJPX(unittest.TestCase):
|
|||
with tempfile.TemporaryFile() as tfile:
|
||||
flst.write(tfile)
|
||||
|
||||
@unittest.skipIf(CANNOT_USE_WITH_SIX, "Cannot use this version of six.")
|
||||
def test_flst_offsets_not_positive(self):
|
||||
"""A fragment list box offsets must be positive."""
|
||||
offset = [0]
|
||||
|
|
@ -451,6 +456,7 @@ class TestJPX(unittest.TestCase):
|
|||
with tempfile.TemporaryFile() as tfile:
|
||||
flst.write(tfile)
|
||||
|
||||
@unittest.skipIf(CANNOT_USE_WITH_SIX, "Cannot use this version of six.")
|
||||
def test_flst_lengths_not_positive(self):
|
||||
"""A fragment list box lengths must be positive."""
|
||||
offset = [89]
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ else:
|
|||
|
||||
import lxml.etree
|
||||
|
||||
from .fixtures import HAS_PYTHON_XMP_TOOLKIT, OPJ_DATA_ROOT
|
||||
from .fixtures import HAS_PYTHON_XMP_TOOLKIT, OPJ_DATA_ROOT, CANNOT_USE_WITH_SIX
|
||||
if HAS_PYTHON_XMP_TOOLKIT:
|
||||
from libxmp import XMPMeta
|
||||
|
||||
|
|
@ -45,8 +45,8 @@ from .fixtures import OPJ_DATA_ROOT, opj_data_file, SimpleRDF
|
|||
|
||||
|
||||
@unittest.skipIf(os.name == "nt", "Unexplained failure on windows")
|
||||
class TestUUIDXMP(unittest.TestCase):
|
||||
"""Tests for UUIDs of XMP type."""
|
||||
class TestSuite(unittest.TestCase):
|
||||
"""Tests for XMP, Exif UUIDs."""
|
||||
|
||||
def setUp(self):
|
||||
self.jp2file = glymur.data.nemo()
|
||||
|
|
@ -54,7 +54,7 @@ class TestUUIDXMP(unittest.TestCase):
|
|||
def tearDown(self):
|
||||
pass
|
||||
|
||||
def test_append(self):
|
||||
def test_append_xmp_uuid(self):
|
||||
"""Should be able to append an XMP UUID box."""
|
||||
the_uuid = uuid.UUID('be7acfcb-97a9-42e8-9c71-999491e3afac')
|
||||
raw_data = SimpleRDF.encode('utf-8')
|
||||
|
|
@ -74,16 +74,42 @@ class TestUUIDXMP(unittest.TestCase):
|
|||
self.assertTrue(isinstance(jp2.box[-1].data,
|
||||
lxml.etree._ElementTree))
|
||||
|
||||
def test_big_endian_exif(self):
|
||||
"""Verify read of Exif big-endian IFD."""
|
||||
with tempfile.NamedTemporaryFile(suffix='.jp2', mode='wb') as tfile:
|
||||
|
||||
with open(self.jp2file, 'rb') as ifptr:
|
||||
tfile.write(ifptr.read())
|
||||
|
||||
# Write L, T, UUID identifier.
|
||||
tfile.write(struct.pack('>I4s', 52, b'uuid'))
|
||||
tfile.write(b'JpgTiffExif->JP2')
|
||||
|
||||
tfile.write(b'Exif\x00\x00')
|
||||
xbuffer = struct.pack('>BBHI', 77, 77, 42, 8)
|
||||
tfile.write(xbuffer)
|
||||
|
||||
# We will write just a single tag.
|
||||
tfile.write(struct.pack('>H', 1))
|
||||
|
||||
# The "Make" tag is tag no. 271.
|
||||
tfile.write(struct.pack('>HHI4s', 271, 2, 3, b'HTC\x00'))
|
||||
tfile.flush()
|
||||
|
||||
jp2 = glymur.Jp2k(tfile.name)
|
||||
self.assertEqual(jp2.box[-1].data['Make'], "HTC")
|
||||
|
||||
@unittest.skipIf(CANNOT_USE_WITH_SIX, "Cannot use this version of six.")
|
||||
@unittest.skipIf(os.name == "nt", "Unexplained failure on windows")
|
||||
class TestUUIDExif(unittest.TestCase):
|
||||
"""Tests for UUIDs of Exif type."""
|
||||
class TestSuiteWarns(unittest.TestCase):
|
||||
"""Tests for XMP, Exif UUIDs, issues warnings."""
|
||||
|
||||
def setUp(self):
|
||||
self.jp2file = glymur.data.nemo()
|
||||
|
||||
def tearDown(self):
|
||||
pass
|
||||
|
||||
|
||||
def test_unrecognized_exif_tag(self):
|
||||
"""Verify warning in case of unrecognized tag."""
|
||||
with tempfile.NamedTemporaryFile(suffix='.jp2', mode='wb') as tfile:
|
||||
|
|
@ -164,30 +190,5 @@ class TestUUIDExif(unittest.TestCase):
|
|||
|
||||
self.assertEqual(jp2.box[-1].box_id, 'uuid')
|
||||
|
||||
def test_big_endian(self):
|
||||
"""Verify read of big-endian IFD."""
|
||||
with tempfile.NamedTemporaryFile(suffix='.jp2', mode='wb') as tfile:
|
||||
|
||||
with open(self.jp2file, 'rb') as ifptr:
|
||||
tfile.write(ifptr.read())
|
||||
|
||||
# Write L, T, UUID identifier.
|
||||
tfile.write(struct.pack('>I4s', 52, b'uuid'))
|
||||
tfile.write(b'JpgTiffExif->JP2')
|
||||
|
||||
tfile.write(b'Exif\x00\x00')
|
||||
xbuffer = struct.pack('>BBHI', 77, 77, 42, 8)
|
||||
tfile.write(xbuffer)
|
||||
|
||||
# We will write just a single tag.
|
||||
tfile.write(struct.pack('>H', 1))
|
||||
|
||||
# The "Make" tag is tag no. 271.
|
||||
tfile.write(struct.pack('>HHI4s', 271, 2, 3, b'HTC\x00'))
|
||||
tfile.flush()
|
||||
|
||||
jp2 = glymur.Jp2k(tfile.name)
|
||||
self.assertEqual(jp2.box[-1].data['Make'], "HTC")
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ from glymur.jp2box import ColourSpecificationBox, ContiguousCodestreamBox
|
|||
from glymur.jp2box import FileTypeBox, ImageHeaderBox, JP2HeaderBox
|
||||
from glymur.jp2box import JPEG2000SignatureBox
|
||||
|
||||
from .fixtures import OPJ_DATA_ROOT, opj_data_file
|
||||
from .fixtures import OPJ_DATA_ROOT, opj_data_file, CANNOT_USE_WITH_SIX
|
||||
|
||||
@unittest.skipIf(os.name == "nt", "Temporary file issue on window.")
|
||||
class TestXML(unittest.TestCase):
|
||||
|
|
@ -206,6 +206,7 @@ class TestJp2kBadXmlFile(unittest.TestCase):
|
|||
def tearDown(self):
|
||||
pass
|
||||
|
||||
@unittest.skipIf(CANNOT_USE_WITH_SIX, "Cannot use this version of six.")
|
||||
@unittest.skipIf(sys.hexversion < 0x03020000, "assertWarns not until 3.2")
|
||||
def test_invalid_xml_box(self):
|
||||
"""Should be able to recover info from xml box with bad xml."""
|
||||
|
|
@ -259,6 +260,7 @@ class TestBadButRecoverableXmlFile(unittest.TestCase):
|
|||
def tearDownClass(cls):
|
||||
os.unlink(cls._bad_xml_file)
|
||||
|
||||
@unittest.skipIf(CANNOT_USE_WITH_SIX, "Cannot use this version of six.")
|
||||
@unittest.skipIf(sys.hexversion < 0x03020000, "assertWarns not until 3.2")
|
||||
def test_bad_xml_box_warning(self):
|
||||
"""Should warn in case of bad XML"""
|
||||
|
|
@ -266,6 +268,7 @@ class TestBadButRecoverableXmlFile(unittest.TestCase):
|
|||
with self.assertWarnsRegex(UserWarning, regex):
|
||||
Jp2k(self._bad_xml_file)
|
||||
|
||||
@unittest.skipIf(CANNOT_USE_WITH_SIX, "Cannot use this version of six.")
|
||||
def test_recover_from_bad_xml(self):
|
||||
"""Should be able to recover info from xml box with bad xml."""
|
||||
with self.assertWarns(UserWarning):
|
||||
|
|
@ -278,6 +281,7 @@ class TestBadButRecoverableXmlFile(unittest.TestCase):
|
|||
b'<test>this is a test</test>')
|
||||
|
||||
|
||||
@unittest.skipIf(CANNOT_USE_WITH_SIX, "Cannot use this version of six.")
|
||||
@unittest.skipIf(sys.hexversion < 0x03020000, "assertWarns not until 3.2")
|
||||
@unittest.skipIf(OPJ_DATA_ROOT is None,
|
||||
"OPJ_DATA_ROOT environment variable not set")
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ import pkg_resources
|
|||
import glymur
|
||||
from glymur import Jp2k
|
||||
|
||||
from .fixtures import HAS_PYTHON_XMP_TOOLKIT
|
||||
from .fixtures import HAS_PYTHON_XMP_TOOLKIT, CANNOT_USE_WITH_SIX
|
||||
if HAS_PYTHON_XMP_TOOLKIT:
|
||||
import libxmp
|
||||
from libxmp import XMPMeta
|
||||
|
|
@ -1018,6 +1018,7 @@ class TestJp2k_2_1(unittest.TestCase):
|
|||
self.assertEqual(j.box[2].box[0].num_components, 4)
|
||||
self.assertEqual(j.box[2].box[1].colorspace, glymur.core.SRGB)
|
||||
|
||||
@unittest.skipIf(CANNOT_USE_WITH_SIX, "Cannot use this version of six.")
|
||||
@unittest.skipIf(os.name == "nt", "NamedTemporaryFile issue on windows")
|
||||
def test_openjpeg_library_message(self):
|
||||
"""Verify the error message produced by the openjpeg library"""
|
||||
|
|
@ -1066,6 +1067,7 @@ class TestParsing(unittest.TestCase):
|
|||
def tearDown(self):
|
||||
pass
|
||||
|
||||
@unittest.skipIf(CANNOT_USE_WITH_SIX, "Cannot use this version of six.")
|
||||
@unittest.skipIf(sys.hexversion < 0x03020000, "assertWarns not until 3.2")
|
||||
def test_bad_rsiz(self):
|
||||
"""Should not warn if RSIZ when parsing is turned off."""
|
||||
|
|
@ -1087,6 +1089,7 @@ class TestParsing(unittest.TestCase):
|
|||
main_header = jp2c.main_header
|
||||
self.assertIsNotNone(jp2c._main_header)
|
||||
|
||||
@unittest.skipIf(CANNOT_USE_WITH_SIX, "Cannot use this version of six.")
|
||||
@unittest.skipIf(sys.hexversion < 0x03020000, "assertWarns not until 3.2")
|
||||
@unittest.skipIf(OPJ_DATA_ROOT is None,
|
||||
"OPJ_DATA_ROOT environment variable not set")
|
||||
|
|
@ -1155,10 +1158,12 @@ class TestJp2kOpjDataRoot(unittest.TestCase):
|
|||
actdata = j.read()
|
||||
self.assertTrue(fixtures.mse(actdata, expdata) < 250)
|
||||
|
||||
@unittest.skipIf(CANNOT_USE_WITH_SIX, "Cannot use this version of six.")
|
||||
def test_no_cxform_pclr_jp2(self):
|
||||
"""Indices for pclr jpxfile if no color transform"""
|
||||
filename = opj_data_file('input/conformance/file9.jp2')
|
||||
j = Jp2k(filename)
|
||||
with self.assertWarns(UserWarning):
|
||||
j = Jp2k(filename)
|
||||
rgb = j.read()
|
||||
idx = j.read(ignore_pclr_cmap_cdef=True)
|
||||
self.assertEqual(rgb.shape, (512, 768, 3))
|
||||
|
|
@ -1183,7 +1188,8 @@ class TestJp2kOpjDataRoot(unittest.TestCase):
|
|||
j = Jp2k(filename)
|
||||
with self.assertRaises(RuntimeError):
|
||||
j.read()
|
||||
|
||||
|
||||
@unittest.skipIf(CANNOT_USE_WITH_SIX, "Cannot use this version of six.")
|
||||
def test_no_cxform_cmap(self):
|
||||
"""Bands as physically ordered, not as physically intended"""
|
||||
# This file has the components physically reversed. The cmap box
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ import numpy as np
|
|||
from glymur import Jp2k
|
||||
import glymur
|
||||
|
||||
from .fixtures import OPJ_DATA_ROOT
|
||||
from .fixtures import OPJ_DATA_ROOT, CANNOT_USE_WITH_SIX
|
||||
from .fixtures import mse, peak_tolerance, read_pgx, opj_data_file
|
||||
|
||||
|
||||
|
|
@ -202,6 +202,7 @@ class TestSuite(unittest.TestCase):
|
|||
self.assertTrue(peak_tolerance(jpdata, pgxdata) < 624)
|
||||
self.assertTrue(mse(jpdata, pgxdata) < 3080)
|
||||
|
||||
@unittest.skipIf(CANNOT_USE_WITH_SIX, "Cannot use this version of six.")
|
||||
def test_ETS_JP2_file1(self):
|
||||
jfile = opj_data_file('input/conformance/file1.jp2')
|
||||
with self.assertWarns(UserWarning):
|
||||
|
|
@ -210,6 +211,7 @@ class TestSuite(unittest.TestCase):
|
|||
jpdata = jp2k.read()
|
||||
self.assertEqual(jpdata.shape, (512, 768, 3))
|
||||
|
||||
@unittest.skipIf(CANNOT_USE_WITH_SIX, "Cannot use this version of six.")
|
||||
def test_ETS_JP2_file2(self):
|
||||
jfile = opj_data_file('input/conformance/file2.jp2')
|
||||
with self.assertWarns(UserWarning):
|
||||
|
|
@ -217,6 +219,7 @@ class TestSuite(unittest.TestCase):
|
|||
jpdata = jp2k.read()
|
||||
self.assertEqual(jpdata.shape, (640, 480, 3))
|
||||
|
||||
@unittest.skipIf(CANNOT_USE_WITH_SIX, "Cannot use this version of six.")
|
||||
@unittest.skipIf(glymur.version.openjpeg_version_tuple[0] < 2,
|
||||
"Functionality not implemented for 1.x")
|
||||
def test_ETS_JP2_file3(self):
|
||||
|
|
@ -228,6 +231,7 @@ class TestSuite(unittest.TestCase):
|
|||
self.assertEqual(jpdata[1].shape, (320, 240))
|
||||
self.assertEqual(jpdata[2].shape, (320, 240))
|
||||
|
||||
@unittest.skipIf(CANNOT_USE_WITH_SIX, "Cannot use this version of six.")
|
||||
def test_ETS_JP2_file4(self):
|
||||
jfile = opj_data_file('input/conformance/file4.jp2')
|
||||
with self.assertWarns(UserWarning):
|
||||
|
|
@ -235,6 +239,7 @@ class TestSuite(unittest.TestCase):
|
|||
jpdata = jp2k.read()
|
||||
self.assertEqual(jpdata.shape, (512, 768))
|
||||
|
||||
@unittest.skipIf(CANNOT_USE_WITH_SIX, "Cannot use this version of six.")
|
||||
def test_ETS_JP2_file5(self):
|
||||
jfile = opj_data_file('input/conformance/file5.jp2')
|
||||
with self.assertWarns(UserWarning):
|
||||
|
|
@ -244,6 +249,7 @@ class TestSuite(unittest.TestCase):
|
|||
jpdata = jp2k.read()
|
||||
self.assertEqual(jpdata.shape, (512, 768, 3))
|
||||
|
||||
@unittest.skipIf(CANNOT_USE_WITH_SIX, "Cannot use this version of six.")
|
||||
def test_ETS_JP2_file6(self):
|
||||
jfile = opj_data_file('input/conformance/file6.jp2')
|
||||
with self.assertWarns(UserWarning):
|
||||
|
|
@ -251,6 +257,7 @@ class TestSuite(unittest.TestCase):
|
|||
jpdata = jp2k.read()
|
||||
self.assertEqual(jpdata.shape, (512, 768))
|
||||
|
||||
@unittest.skipIf(CANNOT_USE_WITH_SIX, "Cannot use this version of six.")
|
||||
def test_ETS_JP2_file7(self):
|
||||
jfile = opj_data_file('input/conformance/file7.jp2')
|
||||
with self.assertWarns(UserWarning):
|
||||
|
|
@ -258,6 +265,7 @@ class TestSuite(unittest.TestCase):
|
|||
jpdata = jp2k.read()
|
||||
self.assertEqual(jpdata.shape, (640, 480, 3))
|
||||
|
||||
@unittest.skipIf(CANNOT_USE_WITH_SIX, "Cannot use this version of six.")
|
||||
def test_ETS_JP2_file8(self):
|
||||
jfile = opj_data_file('input/conformance/file8.jp2')
|
||||
with self.assertWarns(UserWarning):
|
||||
|
|
@ -265,6 +273,7 @@ class TestSuite(unittest.TestCase):
|
|||
jpdata = jp2k.read()
|
||||
self.assertEqual(jpdata.shape, (400, 700))
|
||||
|
||||
@unittest.skipIf(CANNOT_USE_WITH_SIX, "Cannot use this version of six.")
|
||||
def test_ETS_JP2_file9(self):
|
||||
jfile = opj_data_file('input/conformance/file9.jp2')
|
||||
with self.assertWarns(UserWarning):
|
||||
|
|
@ -272,6 +281,7 @@ class TestSuite(unittest.TestCase):
|
|||
jpdata = jp2k.read()
|
||||
self.assertEqual(jpdata.shape, (512, 768, 3))
|
||||
|
||||
@unittest.skipIf(CANNOT_USE_WITH_SIX, "Cannot use this version of six.")
|
||||
def test_NR_broken_jp2_dump(self):
|
||||
jfile = opj_data_file('input/nonregression/broken.jp2')
|
||||
|
||||
|
|
@ -476,6 +486,7 @@ class TestSuite(unittest.TestCase):
|
|||
Jp2k(jfile).read()
|
||||
self.assertTrue(True)
|
||||
|
||||
@unittest.skipIf(CANNOT_USE_WITH_SIX, "Cannot use this version of six.")
|
||||
def test_NR_DEC_orb_blue_lin_jp2_25_decode(self):
|
||||
jfile = opj_data_file('input/nonregression/orb-blue10-lin-jp2.jp2')
|
||||
with self.assertWarns(UserWarning):
|
||||
|
|
@ -483,6 +494,7 @@ class TestSuite(unittest.TestCase):
|
|||
Jp2k(jfile).read()
|
||||
self.assertTrue(True)
|
||||
|
||||
@unittest.skipIf(CANNOT_USE_WITH_SIX, "Cannot use this version of six.")
|
||||
def test_NR_DEC_orb_blue_win_jp2_26_decode(self):
|
||||
jfile = opj_data_file('input/nonregression/orb-blue10-win-jp2.jp2')
|
||||
with self.assertWarns(UserWarning):
|
||||
|
|
@ -632,6 +644,7 @@ class TestSuite2point0(unittest.TestCase):
|
|||
pgxdata = read_pgx(pgxfile)
|
||||
np.testing.assert_array_equal(jpdata[:, :, 2], pgxdata)
|
||||
|
||||
@unittest.skipIf(CANNOT_USE_WITH_SIX, "Cannot use this version of six.")
|
||||
def test_NR_DEC_broken2_jp2_5_decode(self):
|
||||
# Null pointer access
|
||||
jfile = opj_data_file('input/nonregression/broken2.jp2')
|
||||
|
|
@ -641,6 +654,7 @@ class TestSuite2point0(unittest.TestCase):
|
|||
Jp2k(jfile).read()
|
||||
self.assertTrue(True)
|
||||
|
||||
@unittest.skipIf(CANNOT_USE_WITH_SIX, "Cannot use this version of six.")
|
||||
def test_NR_DEC_broken4_jp2_7_decode(self):
|
||||
jfile = opj_data_file('input/nonregression/broken4.jp2')
|
||||
with self.assertRaises(IOError):
|
||||
|
|
@ -649,6 +663,7 @@ class TestSuite2point0(unittest.TestCase):
|
|||
Jp2k(jfile).read()
|
||||
self.assertTrue(True)
|
||||
|
||||
@unittest.skipIf(CANNOT_USE_WITH_SIX, "Cannot use this version of six.")
|
||||
def test_NR_DEC_kakadu_v4_4_openjpegv2_broken_j2k_16_decode(self):
|
||||
# This test actually passes in 1.5, but produces unpleasant warning
|
||||
# messages that cannot be turned off?
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ import numpy as np
|
|||
from glymur import Jp2k
|
||||
import glymur
|
||||
|
||||
from .fixtures import OPJ_DATA_ROOT
|
||||
from .fixtures import OPJ_DATA_ROOT, CANNOT_USE_WITH_SIX
|
||||
from .fixtures import mse, peak_tolerance, read_pgx, opj_data_file
|
||||
|
||||
|
||||
|
|
@ -54,6 +54,7 @@ class TestSuite2point1(unittest.TestCase):
|
|||
def tearDown(self):
|
||||
pass
|
||||
|
||||
@unittest.skipIf(CANNOT_USE_WITH_SIX, "Cannot use this version of six.")
|
||||
def test_NR_DEC_text_GBR_jp2_29_decode(self):
|
||||
jfile = opj_data_file('input/nonregression/text_GBR.jp2')
|
||||
with self.assertWarns(UserWarning):
|
||||
|
|
@ -82,6 +83,7 @@ class TestSuite2point1(unittest.TestCase):
|
|||
Jp2k(jfile).read()
|
||||
self.assertTrue(True)
|
||||
|
||||
@unittest.skipIf(CANNOT_USE_WITH_SIX, "Cannot use this version of six.")
|
||||
def test_NR_DEC_gdal_fuzzer_unchecked_num_resolutions_jp2_36_decode(self):
|
||||
f = 'input/nonregression/gdal_fuzzer_unchecked_numresolutions.jp2'
|
||||
jfile = opj_data_file(f)
|
||||
|
|
@ -91,6 +93,7 @@ class TestSuite2point1(unittest.TestCase):
|
|||
with self.assertRaises(IOError):
|
||||
j.read()
|
||||
|
||||
@unittest.skipIf(CANNOT_USE_WITH_SIX, "Cannot use this version of six.")
|
||||
def test_NR_DEC_gdal_fuzzer_check_number_of_tiles_jp2_38_decode(self):
|
||||
relpath = 'input/nonregression/gdal_fuzzer_check_number_of_tiles.jp2'
|
||||
jfile = opj_data_file(relpath)
|
||||
|
|
@ -100,6 +103,7 @@ class TestSuite2point1(unittest.TestCase):
|
|||
with self.assertRaises(IOError):
|
||||
j.read()
|
||||
|
||||
@unittest.skipIf(CANNOT_USE_WITH_SIX, "Cannot use this version of six.")
|
||||
def test_NR_DEC_gdal_fuzzer_check_comp_dx_dy_jp2_39_decode(self):
|
||||
relpath = 'input/nonregression/gdal_fuzzer_check_comp_dx_dy.jp2'
|
||||
jfile = opj_data_file(relpath)
|
||||
|
|
@ -146,6 +150,7 @@ class TestSuite2point1(unittest.TestCase):
|
|||
odata = jp2k.read(rlevel=1)
|
||||
np.testing.assert_array_equal(tdata, odata[64:128, 256:320])
|
||||
|
||||
@unittest.skipIf(CANNOT_USE_WITH_SIX, "Cannot use this version of six.")
|
||||
def test_NR_DEC_jp2_36_decode(self):
|
||||
lst = ('input',
|
||||
'nonregression',
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ import numpy as np
|
|||
from glymur import Jp2k
|
||||
import glymur
|
||||
|
||||
from .fixtures import OPJ_DATA_ROOT
|
||||
from .fixtures import OPJ_DATA_ROOT, CANNOT_USE_WITH_SIX
|
||||
from .fixtures import mse, peak_tolerance, read_pgx, opj_data_file
|
||||
|
||||
|
||||
|
|
@ -102,6 +102,7 @@ class TestSuite(unittest.TestCase):
|
|||
self.assertIsNone(actual.icc_profile)
|
||||
|
||||
|
||||
@unittest.skipIf(CANNOT_USE_WITH_SIX, "Cannot use this version of six.")
|
||||
@unittest.skipIf(re.match("1.5|2.0.0", glymur.version.openjpeg_version),
|
||||
"Test not passing on 1.5, 2.0: not introduced until 2.x")
|
||||
def test_NR_DEC_issue188_beach_64bitsbox_jp2_41_decode(self):
|
||||
|
|
@ -116,6 +117,7 @@ class TestSuite(unittest.TestCase):
|
|||
self.assertTrue(True)
|
||||
|
||||
|
||||
@unittest.skipIf(CANNOT_USE_WITH_SIX, "Cannot use this version of six.")
|
||||
def test_NR_broken4_jp2_dump(self):
|
||||
jfile = opj_data_file('input/nonregression/broken4.jp2')
|
||||
with self.assertWarns(UserWarning):
|
||||
|
|
@ -123,6 +125,7 @@ class TestSuite(unittest.TestCase):
|
|||
|
||||
self.assertEqual(jp2.box[-1].main_header.segment[-1].marker_id, 'QCC')
|
||||
|
||||
@unittest.skipIf(CANNOT_USE_WITH_SIX, "Cannot use this version of six.")
|
||||
@unittest.skipIf(sys.maxsize < 2**32, 'Do not run on 32-bit platforms')
|
||||
def test_NR_broken3_jp2_dump(self):
|
||||
"""
|
||||
|
|
@ -222,6 +225,7 @@ class TestSuite(unittest.TestCase):
|
|||
self.assertEqual(c.segment[6].exponent,
|
||||
[8] + [9, 9, 10] * 5)
|
||||
|
||||
@unittest.skipIf(CANNOT_USE_WITH_SIX, "Cannot use this version of six.")
|
||||
def test_NR_broken2_jp2_dump(self):
|
||||
"""
|
||||
Invalid marker ID in the codestream.
|
||||
|
|
@ -2459,6 +2463,7 @@ class TestSuite(unittest.TestCase):
|
|||
# EOC: end of codestream
|
||||
self.assertEqual(c.segment[-1].marker_id, 'EOC')
|
||||
|
||||
@unittest.skipIf(CANNOT_USE_WITH_SIX, "Cannot use this version of six.")
|
||||
def test_NR_file1_dump(self):
|
||||
jfile = opj_data_file('input/conformance/file1.jp2')
|
||||
with self.assertWarns(UserWarning):
|
||||
|
|
@ -2494,6 +2499,7 @@ class TestSuite(unittest.TestCase):
|
|||
'{http://www.jpeg.org/jpx/1.0/xml}LOCATION',
|
||||
'{http://www.jpeg.org/jpx/1.0/xml}EVENT'])
|
||||
|
||||
@unittest.skipIf(CANNOT_USE_WITH_SIX, "Cannot use this version of six.")
|
||||
def test_NR_file2_dump(self):
|
||||
jfile = opj_data_file('input/conformance/file2.jp2')
|
||||
with self.assertWarns(UserWarning):
|
||||
|
|
@ -2521,6 +2527,7 @@ class TestSuite(unittest.TestCase):
|
|||
self.assertEqual(jp2.box[2].box[2].channel_type, (0, 0, 0)) # color
|
||||
self.assertEqual(jp2.box[2].box[2].association, (3, 2, 1)) # reverse
|
||||
|
||||
@unittest.skipIf(CANNOT_USE_WITH_SIX, "Cannot use this version of six.")
|
||||
def test_NR_file3_dump(self):
|
||||
# Three 8-bit components in the sRGB-YCC colourspace, with the Cb and
|
||||
# Cr components being subsampled 2x in both the horizontal and
|
||||
|
|
@ -2556,6 +2563,7 @@ class TestSuite(unittest.TestCase):
|
|||
self.assertEqual(codestream.segment[1].xrsiz[2], 2)
|
||||
self.assertEqual(codestream.segment[1].yrsiz[2], 2)
|
||||
|
||||
@unittest.skipIf(CANNOT_USE_WITH_SIX, "Cannot use this version of six.")
|
||||
def test_NR_file4_dump(self):
|
||||
# One 8-bit component in the sRGB-grey colourspace.
|
||||
jfile = opj_data_file('input/conformance/file4.jp2')
|
||||
|
|
@ -2578,6 +2586,7 @@ class TestSuite(unittest.TestCase):
|
|||
colorspace=glymur.core.GREYSCALE, approximation=1)
|
||||
self.verifyColourSpecificationBox(jp2.box[2].box[1], colr)
|
||||
|
||||
@unittest.skipIf(CANNOT_USE_WITH_SIX, "Cannot use this version of six.")
|
||||
def test_NR_file5_dump(self):
|
||||
# Three 8-bit components in the ROMM-RGB colourspace, encapsulated in a
|
||||
# JPX file. The components have been transformed using
|
||||
|
|
@ -2608,6 +2617,7 @@ class TestSuite(unittest.TestCase):
|
|||
self.verifyColourSpecificationBox(jp2.box[3].box[1], colr)
|
||||
self.assertEqual(jp2.box[3].box[1].icc_profile['Size'], 546)
|
||||
|
||||
@unittest.skipIf(CANNOT_USE_WITH_SIX, "Cannot use this version of six.")
|
||||
def test_NR_file6_dump(self):
|
||||
jfile = opj_data_file('input/conformance/file6.jp2')
|
||||
with self.assertWarns(UserWarning):
|
||||
|
|
@ -2631,6 +2641,7 @@ class TestSuite(unittest.TestCase):
|
|||
approximation=1)
|
||||
self.verifyColourSpecificationBox(jp2.box[2].box[1], colr)
|
||||
|
||||
@unittest.skipIf(CANNOT_USE_WITH_SIX, "Cannot use this version of six.")
|
||||
def test_NR_file7_dump(self):
|
||||
# Three 16-bit components in the e-sRGB colourspace, encapsulated in a
|
||||
# JP2 compatible JPX file. The components have been transformed using
|
||||
|
|
@ -2663,6 +2674,7 @@ class TestSuite(unittest.TestCase):
|
|||
self.verifyColourSpecificationBox(jp2.box[3].box[1], colr)
|
||||
self.assertEqual(jp2.box[3].box[1].icc_profile['Size'], 13332)
|
||||
|
||||
@unittest.skipIf(CANNOT_USE_WITH_SIX, "Cannot use this version of six.")
|
||||
def test_NR_file8_dump(self):
|
||||
# One 8-bit component in a gamma 1.8 space. The colourspace is
|
||||
# specified using a Restricted ICC profile.
|
||||
|
|
@ -2707,6 +2719,7 @@ class TestSuite(unittest.TestCase):
|
|||
'{http://www.jpeg.org/jpx/1.0/xml}THING',
|
||||
'{http://www.jpeg.org/jpx/1.0/xml}EVENT'])
|
||||
|
||||
@unittest.skipIf(CANNOT_USE_WITH_SIX, "Cannot use this version of six.")
|
||||
def test_NR_file9_dump(self):
|
||||
# Colormap
|
||||
jfile = opj_data_file('input/conformance/file9.jp2')
|
||||
|
|
@ -3951,6 +3964,7 @@ class TestSuite(unittest.TestCase):
|
|||
self.assertEqual(c.segment[3].mantissa, [0] * 16)
|
||||
self.assertEqual(c.segment[3].exponent, [8] + [9, 9, 10] * 5)
|
||||
|
||||
@unittest.skipIf(CANNOT_USE_WITH_SIX, "Cannot use this version of six.")
|
||||
def test_NR_issue188_beach_64bitsbox(self):
|
||||
lst = ['input', 'nonregression', 'issue188_beach_64bitsbox.jp2']
|
||||
jfile = opj_data_file('/'.join(lst))
|
||||
|
|
@ -4346,6 +4360,7 @@ class TestSuite(unittest.TestCase):
|
|||
podvals = (glymur.core.LRCP, glymur.core.LRCP)
|
||||
self.assertEqual(c.segment[4].ppod, podvals)
|
||||
|
||||
@unittest.skipIf(CANNOT_USE_WITH_SIX, "Cannot use this version of six.")
|
||||
def test_NR_orb_blue10_lin_jp2_dump(self):
|
||||
jfile = opj_data_file('input/nonregression/orb-blue10-lin-jp2.jp2')
|
||||
with self.assertWarns(UserWarning):
|
||||
|
|
@ -4421,6 +4436,7 @@ class TestSuite(unittest.TestCase):
|
|||
self.assertEqual(c.segment[3].exponent,
|
||||
[8, 9, 9, 10, 9, 9, 10, 9, 9, 10, 9, 9, 10, 9, 9, 10])
|
||||
|
||||
@unittest.skipIf(CANNOT_USE_WITH_SIX, "Cannot use this version of six.")
|
||||
def test_NR_orb_blue10_win_jp2_dump(self):
|
||||
jfile = opj_data_file('input/nonregression/orb-blue10-win-jp2.jp2')
|
||||
with self.assertWarns(UserWarning):
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ except ImportError:
|
|||
from .fixtures import OPJ_DATA_ROOT, opj_data_file, read_image
|
||||
from .fixtures import NO_READ_BACKEND, NO_READ_BACKEND_MSG
|
||||
from .fixtures import NO_SKIMAGE_FREEIMAGE_SUPPORT
|
||||
from .fixtures import CANNOT_USE_WITH_SIX
|
||||
|
||||
from glymur import Jp2k
|
||||
import glymur
|
||||
|
|
@ -75,6 +76,7 @@ class TestSuiteNegative(unittest.TestCase):
|
|||
jp2k.get_codestream(header_only=False)
|
||||
self.assertTrue(True)
|
||||
|
||||
@unittest.skipIf(CANNOT_USE_WITH_SIX, "Cannot use this version of six.")
|
||||
def test_nr_illegalclrtransform(self):
|
||||
"""EOC marker is bad"""
|
||||
relpath = 'input/nonregression/illegalcolortransform.j2k'
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ except ImportError:
|
|||
|
||||
from .fixtures import read_image, NO_READ_BACKEND, NO_READ_BACKEND_MSG
|
||||
from .fixtures import OPJ_DATA_ROOT, NO_SKIMAGE_FREEIMAGE_SUPPORT
|
||||
from .fixtures import opj_data_file
|
||||
from .fixtures import opj_data_file, CANNOT_USE_WITH_SIX
|
||||
from . import fixtures
|
||||
|
||||
from glymur import Jp2k
|
||||
|
|
@ -150,73 +150,92 @@ class TestSuiteWriteCinema(unittest.TestCase):
|
|||
|
||||
|
||||
|
||||
@unittest.skipIf(CANNOT_USE_WITH_SIX, "Cannot use this version of six.")
|
||||
def test_NR_ENC_ElephantDream_4K_tif_21_encode(self):
|
||||
relfile = 'input/nonregression/ElephantDream_4K.tif'
|
||||
infile = opj_data_file(relfile)
|
||||
data = skimage.io.imread(infile)
|
||||
with tempfile.NamedTemporaryFile(suffix='.j2k') as tfile:
|
||||
j = Jp2k(tfile.name, 'wb')
|
||||
j.write(data, cinema4k=True)
|
||||
regex = 'OpenJPEG library warning: JPEG 2000 Profile-3 and 4 '
|
||||
regex += '(2k/4k dc profile) requires'
|
||||
with self.assertWarnsRegex(UserWarning, regex):
|
||||
j.write(data, cinema4k=True)
|
||||
|
||||
codestream = j.get_codestream()
|
||||
self.check_cinema4k_codestream(codestream, (4096, 2160))
|
||||
|
||||
|
||||
@unittest.skipIf(CANNOT_USE_WITH_SIX, "Cannot use this version of six.")
|
||||
def test_NR_ENC_X_5_2K_24_235_CBR_STEM24_000_tif_19_encode(self):
|
||||
relfile = 'input/nonregression/X_5_2K_24_235_CBR_STEM24_000.tif'
|
||||
infile = opj_data_file(relfile)
|
||||
data = skimage.io.imread(infile)
|
||||
with tempfile.NamedTemporaryFile(suffix='.j2k') as tfile:
|
||||
j = Jp2k(tfile.name, 'wb')
|
||||
j.write(data, cinema2k=48)
|
||||
with self.assertWarnsRegex(UserWarning, 'OpenJPEG library warning'):
|
||||
j.write(data, cinema2k=48)
|
||||
|
||||
codestream = j.get_codestream()
|
||||
self.check_cinema2k_codestream(codestream, (2048, 857))
|
||||
|
||||
|
||||
@unittest.skipIf(CANNOT_USE_WITH_SIX, "Cannot use this version of six.")
|
||||
def test_NR_ENC_X_6_2K_24_FULL_CBR_CIRCLE_000_tif_20_encode(self):
|
||||
relfile = 'input/nonregression/X_6_2K_24_FULL_CBR_CIRCLE_000.tif'
|
||||
infile = opj_data_file(relfile)
|
||||
data = skimage.io.imread(infile)
|
||||
with tempfile.NamedTemporaryFile(suffix='.j2k') as tfile:
|
||||
j = Jp2k(tfile.name, 'wb')
|
||||
j.write(data, cinema2k=48)
|
||||
with self.assertWarnsRegex(UserWarning, 'OpenJPEG library warning'):
|
||||
j.write(data, cinema2k=48)
|
||||
|
||||
codestream = j.get_codestream()
|
||||
self.check_cinema2k_codestream(codestream, (2048, 1080))
|
||||
|
||||
|
||||
@unittest.skipIf(CANNOT_USE_WITH_SIX, "Cannot use this version of six.")
|
||||
def test_NR_ENC_X_6_2K_24_FULL_CBR_CIRCLE_000_tif_17_encode(self):
|
||||
relfile = 'input/nonregression/X_6_2K_24_FULL_CBR_CIRCLE_000.tif'
|
||||
infile = opj_data_file(relfile)
|
||||
data = skimage.io.imread(infile)
|
||||
with tempfile.NamedTemporaryFile(suffix='.j2k') as tfile:
|
||||
j = Jp2k(tfile.name, 'wb')
|
||||
j.write(data, cinema2k=24)
|
||||
with self.assertWarnsRegex(UserWarning, 'OpenJPEG library warning'):
|
||||
j.write(data, cinema2k=24)
|
||||
|
||||
codestream = j.get_codestream()
|
||||
self.check_cinema2k_codestream(codestream, (2048, 1080))
|
||||
|
||||
|
||||
@unittest.skipIf(CANNOT_USE_WITH_SIX, "Cannot use this version of six.")
|
||||
def test_NR_ENC_X_5_2K_24_235_CBR_STEM24_000_tif_16_encode(self):
|
||||
relfile = 'input/nonregression/X_5_2K_24_235_CBR_STEM24_000.tif'
|
||||
infile = opj_data_file(relfile)
|
||||
data = skimage.io.imread(infile)
|
||||
with tempfile.NamedTemporaryFile(suffix='.j2k') as tfile:
|
||||
j = Jp2k(tfile.name, 'wb')
|
||||
j.write(data, cinema2k=24)
|
||||
with self.assertWarnsRegex(UserWarning, 'OpenJPEG library warning'):
|
||||
# OpenJPEG library warning: The desired maximum codestream
|
||||
# size has limited at least one of the desired quality layers
|
||||
j.write(data, cinema2k=24)
|
||||
|
||||
codestream = j.get_codestream()
|
||||
self.check_cinema2k_codestream(codestream, (2048, 857))
|
||||
|
||||
|
||||
@unittest.skipIf(CANNOT_USE_WITH_SIX, "Cannot use this version of six.")
|
||||
def test_NR_ENC_X_4_2K_24_185_CBR_WB_000_tif_18_encode(self):
|
||||
relfile = 'input/nonregression/X_4_2K_24_185_CBR_WB_000.tif'
|
||||
infile = opj_data_file(relfile)
|
||||
data = skimage.io.imread(infile)
|
||||
with tempfile.NamedTemporaryFile(suffix='.j2k') as tfile:
|
||||
j = Jp2k(tfile.name, 'wb')
|
||||
j.write(data, cinema2k=48)
|
||||
regex = 'OpenJPEG library warning'
|
||||
with self.assertWarnsRegex(UserWarning, regex):
|
||||
# OpenJPEG library warning: The desired maximum codestream
|
||||
# size has limited at least one of the desired quality layers
|
||||
j.write(data, cinema2k=48)
|
||||
|
||||
codestream = j.get_codestream()
|
||||
self.check_cinema2k_codestream(codestream, (1998, 1080))
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ import lxml.etree as ET
|
|||
import glymur
|
||||
from glymur import Jp2k, command_line
|
||||
from . import fixtures
|
||||
from .fixtures import OPJ_DATA_ROOT, opj_data_file
|
||||
from .fixtures import OPJ_DATA_ROOT, opj_data_file, CANNOT_USE_WITH_SIX
|
||||
from .fixtures import text_gbr_27, text_gbr_33, text_gbr_34
|
||||
|
||||
|
||||
|
|
@ -70,6 +70,7 @@ class TestPrinting(unittest.TestCase):
|
|||
|
||||
self.assertTrue(True)
|
||||
|
||||
@unittest.skipIf(CANNOT_USE_WITH_SIX, "Cannot use this version of six.")
|
||||
def test_unknown_superbox(self):
|
||||
"""Verify that we can handle an unknown superbox."""
|
||||
with tempfile.NamedTemporaryFile(suffix='.jpx') as tfile:
|
||||
|
|
@ -642,6 +643,7 @@ class TestPrintingOpjDataRoot(unittest.TestCase):
|
|||
actual = fake_out.getvalue().strip()
|
||||
self.assertEqual(actual, fixtures.cinema2k_profile)
|
||||
|
||||
@unittest.skipIf(CANNOT_USE_WITH_SIX, "Cannot use this version of six.")
|
||||
def test_invalid_colorspace(self):
|
||||
"""An invalid colorspace shouldn't cause an error."""
|
||||
filename = opj_data_file('input/nonregression/edf_c2_1103421.jp2')
|
||||
|
|
@ -650,6 +652,7 @@ class TestPrintingOpjDataRoot(unittest.TestCase):
|
|||
with patch('sys.stdout', new=StringIO()) as fake_out:
|
||||
print(jp2)
|
||||
|
||||
@unittest.skipIf(CANNOT_USE_WITH_SIX, "Cannot use this version of six.")
|
||||
def test_bad_rsiz(self):
|
||||
"""Should still be able to print if rsiz is bad, issue196"""
|
||||
filename = opj_data_file('input/nonregression/edf_c2_1002767.jp2')
|
||||
|
|
@ -658,6 +661,7 @@ class TestPrintingOpjDataRoot(unittest.TestCase):
|
|||
with patch('sys.stdout', new=StringIO()) as fake_out:
|
||||
print(j)
|
||||
|
||||
@unittest.skipIf(CANNOT_USE_WITH_SIX, "Cannot use this version of six.")
|
||||
def test_bad_wavelet_transform(self):
|
||||
"""Should still be able to print if wavelet xform is bad, issue195"""
|
||||
filename = opj_data_file('input/nonregression/edf_c2_10025.jp2')
|
||||
|
|
@ -666,6 +670,7 @@ class TestPrintingOpjDataRoot(unittest.TestCase):
|
|||
with patch('sys.stdout', new=StringIO()) as fake_out:
|
||||
print(jp2)
|
||||
|
||||
@unittest.skipIf(CANNOT_USE_WITH_SIX, "Cannot use this version of six.")
|
||||
def test_invalid_progression_order(self):
|
||||
"""Should still be able to print even if prog order is invalid."""
|
||||
jfile = opj_data_file('input/nonregression/2977.pdf.asan.67.2198.jp2')
|
||||
|
|
@ -827,6 +832,7 @@ class TestPrintingOpjDataRoot(unittest.TestCase):
|
|||
expected = '\n'.join(lines)
|
||||
self.assertEqual(actual, expected)
|
||||
|
||||
@unittest.skipIf(CANNOT_USE_WITH_SIX, "Cannot use this version of six.")
|
||||
def test_xml(self):
|
||||
"""verify printing of XML box"""
|
||||
filename = opj_data_file('input/conformance/file1.jp2')
|
||||
|
|
@ -837,6 +843,7 @@ class TestPrintingOpjDataRoot(unittest.TestCase):
|
|||
actual = fake_out.getvalue().strip()
|
||||
self.assertEqual(actual, fixtures.file1_xml)
|
||||
|
||||
@unittest.skipIf(CANNOT_USE_WITH_SIX, "Cannot use this version of six.")
|
||||
def test_channel_definition(self):
|
||||
"""verify printing of cdef box"""
|
||||
filename = opj_data_file('input/conformance/file2.jp2')
|
||||
|
|
@ -853,6 +860,7 @@ class TestPrintingOpjDataRoot(unittest.TestCase):
|
|||
expected = '\n'.join(lines)
|
||||
self.assertEqual(actual, expected)
|
||||
|
||||
@unittest.skipIf(CANNOT_USE_WITH_SIX, "Cannot use this version of six.")
|
||||
def test_component_mapping(self):
|
||||
"""verify printing of cmap box"""
|
||||
filename = opj_data_file('input/conformance/file9.jp2')
|
||||
|
|
@ -879,6 +887,7 @@ class TestPrintingOpjDataRoot(unittest.TestCase):
|
|||
self.assertEqual(newbox.mapping_type, (1, 1, 1))
|
||||
self.assertEqual(newbox.palette_index, (0, 1, 2))
|
||||
|
||||
@unittest.skipIf(CANNOT_USE_WITH_SIX, "Cannot use this version of six.")
|
||||
def test_palette7(self):
|
||||
"""verify printing of pclr box"""
|
||||
filename = opj_data_file('input/conformance/file9.jp2')
|
||||
|
|
@ -892,6 +901,7 @@ class TestPrintingOpjDataRoot(unittest.TestCase):
|
|||
expected = '\n'.join(lines)
|
||||
self.assertEqual(actual, expected)
|
||||
|
||||
@unittest.skipIf(CANNOT_USE_WITH_SIX, "Cannot use this version of six.")
|
||||
def test_rreq(self):
|
||||
"""verify printing of reader requirements box"""
|
||||
filename = opj_data_file('input/nonregression/text_GBR.jp2')
|
||||
|
|
@ -923,6 +933,7 @@ class TestPrintingOpjDataRoot(unittest.TestCase):
|
|||
expected = '\n'.join(lines)
|
||||
self.assertEqual(actual, expected)
|
||||
|
||||
@unittest.skipIf(CANNOT_USE_WITH_SIX, "Cannot use this version of six.")
|
||||
def test_palette_box(self):
|
||||
"""Verify that palette (pclr) boxes are printed without error."""
|
||||
filename = opj_data_file('input/conformance/file9.jp2')
|
||||
|
|
@ -936,6 +947,7 @@ class TestPrintingOpjDataRoot(unittest.TestCase):
|
|||
expected = '\n'.join(lines)
|
||||
self.assertEqual(actual, expected)
|
||||
|
||||
@unittest.skipIf(CANNOT_USE_WITH_SIX, "Cannot use this version of six.")
|
||||
def test_icc_profile(self):
|
||||
"""verify icc profile printing with a jpx"""
|
||||
# ICC profiles may be used in JP2, but the approximation field should
|
||||
|
|
@ -957,6 +969,7 @@ class TestPrintingOpjDataRoot(unittest.TestCase):
|
|||
|
||||
self.assertEqual(actual, expected)
|
||||
|
||||
@unittest.skipIf(CANNOT_USE_WITH_SIX, "Cannot use this version of six.")
|
||||
def test_uuid(self):
|
||||
"""verify printing of UUID box"""
|
||||
filename = opj_data_file('input/nonregression/text_GBR.jp2')
|
||||
|
|
@ -973,6 +986,7 @@ class TestPrintingOpjDataRoot(unittest.TestCase):
|
|||
expected = '\n'.join(lines)
|
||||
self.assertEqual(actual, expected)
|
||||
|
||||
@unittest.skipIf(CANNOT_USE_WITH_SIX, "Cannot use this version of six.")
|
||||
def test_issue182(self):
|
||||
"""Should not show the format string in output."""
|
||||
# The cmap box is wildly broken, but printing was still wrong.
|
||||
|
|
@ -987,6 +1001,7 @@ class TestPrintingOpjDataRoot(unittest.TestCase):
|
|||
actual = fake_out.getvalue().strip()
|
||||
self.assertEqual(actual, fixtures.issue_182_cmap)
|
||||
|
||||
@unittest.skipIf(CANNOT_USE_WITH_SIX, "Cannot use this version of six.")
|
||||
def test_issue183(self):
|
||||
filename = opj_data_file('input/nonregression/orb-blue10-lin-jp2.jp2')
|
||||
|
||||
|
|
@ -998,6 +1013,7 @@ class TestPrintingOpjDataRoot(unittest.TestCase):
|
|||
actual = fake_out.getvalue().strip()
|
||||
self.assertEqual(actual, fixtures.issue_183_colr)
|
||||
|
||||
@unittest.skipIf(CANNOT_USE_WITH_SIX, "Cannot use this version of six.")
|
||||
def test_bom(self):
|
||||
"""Byte order markers are illegal in UTF-8. Issue 185"""
|
||||
filename = opj_data_file(os.path.join('input',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue