Merge branch 'issue108' into devel
This commit is contained in:
commit
e8c66517d1
7 changed files with 501 additions and 619 deletions
|
|
@ -1,6 +1,7 @@
|
|||
"""
|
||||
Test fixtures common to more than one test point.
|
||||
"""
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
import warnings
|
||||
|
|
@ -27,6 +28,19 @@ if glymur.lib.openjp2.OPENJP2 is not None:
|
|||
NO_READ_BACKEND_MSG = "Matplotlib with the PIL backend must be available in "
|
||||
NO_READ_BACKEND_MSG += "order to run the tests in this suite."
|
||||
|
||||
try:
|
||||
OPJ_DATA_ROOT = os.environ['OPJ_DATA_ROOT']
|
||||
except KeyError:
|
||||
OPJ_DATA_ROOT = None
|
||||
except:
|
||||
raise
|
||||
|
||||
|
||||
def opj_data_file(relative_file_name):
|
||||
"""Compact way of forming a full filename from OpenJPEG's test suite."""
|
||||
jfile = os.path.join(OPJ_DATA_ROOT, relative_file_name)
|
||||
return jfile
|
||||
|
||||
try:
|
||||
from matplotlib.pyplot import imread
|
||||
|
||||
|
|
|
|||
|
|
@ -20,16 +20,10 @@ else:
|
|||
import numpy as np
|
||||
|
||||
from glymur import Jp2k
|
||||
|
||||
try:
|
||||
DATA_ROOT = os.environ['OPJ_DATA_ROOT']
|
||||
except KeyError:
|
||||
DATA_ROOT = None
|
||||
except:
|
||||
raise
|
||||
from .fixtures import OPJ_DATA_ROOT, opj_data_file
|
||||
|
||||
|
||||
@unittest.skipIf(DATA_ROOT is None,
|
||||
@unittest.skipIf(OPJ_DATA_ROOT is None,
|
||||
"OPJ_DATA_ROOT environment variable not set")
|
||||
class TestICC(unittest.TestCase):
|
||||
"""ICC profile tests"""
|
||||
|
|
@ -42,7 +36,7 @@ class TestICC(unittest.TestCase):
|
|||
|
||||
def test_file5(self):
|
||||
"""basic ICC profile"""
|
||||
filename = os.path.join(DATA_ROOT, 'input/conformance/file5.jp2')
|
||||
filename = opj_data_file('input/conformance/file5.jp2')
|
||||
j = Jp2k(filename)
|
||||
profile = j.box[3].box[1].icc_profile
|
||||
self.assertEqual(profile['Size'], 546)
|
||||
|
|
@ -75,8 +69,7 @@ class TestICC(unittest.TestCase):
|
|||
"Uses features introduced in 3.2.")
|
||||
def test_invalid_profile_header(self):
|
||||
"""invalid ICC header data should cause UserWarning"""
|
||||
jfile = os.path.join(DATA_ROOT,
|
||||
'input/nonregression/orb-blue10-lin-jp2.jp2')
|
||||
jfile = opj_data_file('input/nonregression/orb-blue10-lin-jp2.jp2')
|
||||
|
||||
# assertWarns in Python 3.3 (python2.7/pylint issue)
|
||||
# pylint: disable=E1101
|
||||
|
|
|
|||
|
|
@ -25,10 +25,6 @@ if sys.hexversion < 0x02070000:
|
|||
else:
|
||||
import unittest
|
||||
|
||||
if sys.hexversion <= 0x03030000:
|
||||
from mock import patch
|
||||
else:
|
||||
from unittest.mock import patch
|
||||
import warnings
|
||||
|
||||
import numpy as np
|
||||
|
|
@ -39,13 +35,7 @@ from glymur import Jp2k
|
|||
|
||||
from .fixtures import OPENJP2_IS_V2_OFFICIAL
|
||||
from .fixtures import OPENJPEG_VERSION
|
||||
|
||||
try:
|
||||
DATA_ROOT = os.environ['OPJ_DATA_ROOT']
|
||||
except KeyError:
|
||||
DATA_ROOT = None
|
||||
except:
|
||||
raise
|
||||
from .fixtures import OPJ_DATA_ROOT, opj_data_file
|
||||
|
||||
|
||||
# Doc tests should be run as well.
|
||||
|
|
@ -380,7 +370,7 @@ class TestJp2k(unittest.TestCase):
|
|||
j2k = Jp2k(self.j2kfile)
|
||||
j2k.read()
|
||||
|
||||
@unittest.skipIf(DATA_ROOT is None,
|
||||
@unittest.skipIf(OPJ_DATA_ROOT is None,
|
||||
"OPJ_DATA_ROOT environment variable not set")
|
||||
def test_read_differing_subsamples(self):
|
||||
"""should error out with read used on differently subsampled images"""
|
||||
|
|
@ -388,7 +378,7 @@ class TestJp2k(unittest.TestCase):
|
|||
# on an image with differing subsamples
|
||||
#
|
||||
# Issue 86.
|
||||
filename = os.path.join(DATA_ROOT, 'input/conformance/p0_05.j2k')
|
||||
filename = opj_data_file('input/conformance/p0_05.j2k')
|
||||
j = Jp2k(filename)
|
||||
with self.assertRaises(RuntimeError):
|
||||
j.read()
|
||||
|
|
@ -1039,7 +1029,7 @@ class TestJp2k15(unittest.TestCase):
|
|||
j2k = Jp2k(self.j2kfile)
|
||||
j2k.read()
|
||||
|
||||
@unittest.skipIf(DATA_ROOT is None,
|
||||
@unittest.skipIf(OPJ_DATA_ROOT is None,
|
||||
"OPJ_DATA_ROOT environment variable not set")
|
||||
def test_read_differing_subsamples(self):
|
||||
"""should error out with read used on differently subsampled images"""
|
||||
|
|
@ -1047,7 +1037,7 @@ class TestJp2k15(unittest.TestCase):
|
|||
# on an image with differing subsamples
|
||||
#
|
||||
# Issue 86.
|
||||
filename = os.path.join(DATA_ROOT, 'input/conformance/p0_05.j2k')
|
||||
filename = opj_data_file('input/conformance/p0_05.j2k')
|
||||
j = Jp2k(filename)
|
||||
with self.assertRaises(RuntimeError):
|
||||
j.read()
|
||||
|
|
@ -1347,7 +1337,8 @@ class TestJp2k15(unittest.TestCase):
|
|||
self.assertEqual(jasoc.box[3].box[1].box_id, 'xml ')
|
||||
|
||||
@unittest.skipIf(os.name == "nt", "NamedTemporaryFile issue on windows")
|
||||
@unittest.skipIf(re.match('1\.[345]\.\d', OPENJPEG_VERSION) is not None,
|
||||
@unittest.skipIf(re.match(r"""1\.[345]\.\d""",
|
||||
OPENJPEG_VERSION) is not None,
|
||||
"Segfault on official v1.x series.")
|
||||
def test_openjpeg_library_message(self):
|
||||
"""Verify the error message produced by the openjpeg library"""
|
||||
|
|
@ -1426,6 +1417,5 @@ class TestJp2k15(unittest.TestCase):
|
|||
self.assertFalse('Make' in exif['Image'].keys())
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -23,23 +23,17 @@ else:
|
|||
import numpy as np
|
||||
|
||||
from .fixtures import read_image, NO_READ_BACKEND, NO_READ_BACKEND_MSG
|
||||
from .fixtures import OPJ_DATA_ROOT, opj_data_file
|
||||
|
||||
from glymur import Jp2k
|
||||
import glymur
|
||||
|
||||
try:
|
||||
DATA_ROOT = os.environ['OPJ_DATA_ROOT']
|
||||
except KeyError:
|
||||
DATA_ROOT = None
|
||||
except:
|
||||
raise
|
||||
|
||||
|
||||
@unittest.skipIf(glymur.lib.openjp2.OPENJP2 is None,
|
||||
"Missing openjp2 library.")
|
||||
@unittest.skipIf(NO_READ_BACKEND, NO_READ_BACKEND_MSG)
|
||||
@unittest.skipIf(DATA_ROOT is None,
|
||||
"OPJ_DATA_ROOT environment variable not set")
|
||||
@unittest.skipIf(OPJ_DATA_ROOT is None,
|
||||
"OPJ_OPJ_DATA_ROOT environment variable not set")
|
||||
class TestSuiteNegative(unittest.TestCase):
|
||||
"""Test suite for certain negative tests from openjpeg suite."""
|
||||
|
||||
|
|
@ -54,7 +48,7 @@ class TestSuiteNegative(unittest.TestCase):
|
|||
def test_psnr_with_cratios(self):
|
||||
"""Using psnr with cratios options is not allowed."""
|
||||
# Not an OpenJPEG test, but close.
|
||||
infile = os.path.join(DATA_ROOT, 'input/nonregression/Bretagne1.ppm')
|
||||
infile = opj_data_file('input/nonregression/Bretagne1.ppm')
|
||||
data = read_image(infile)
|
||||
with tempfile.NamedTemporaryFile(suffix='.j2k') as tfile:
|
||||
j = Jp2k(tfile.name, 'wb')
|
||||
|
|
@ -64,7 +58,7 @@ class TestSuiteNegative(unittest.TestCase):
|
|||
def test_nr_marker_not_compliant(self):
|
||||
"""non-compliant marker, should still be able to read"""
|
||||
relpath = 'input/nonregression/MarkerIsNotCompliant.j2k'
|
||||
jfile = os.path.join(DATA_ROOT, relpath)
|
||||
jfile = opj_data_file(relpath)
|
||||
jp2k = Jp2k(jfile)
|
||||
jp2k.get_codestream(header_only=False)
|
||||
self.assertTrue(True)
|
||||
|
|
@ -74,7 +68,7 @@ class TestSuiteNegative(unittest.TestCase):
|
|||
def test_nr_illegalclrtransform(self):
|
||||
"""EOC marker is bad"""
|
||||
relpath = 'input/nonregression/illegalcolortransform.j2k'
|
||||
jfile = os.path.join(DATA_ROOT, relpath)
|
||||
jfile = opj_data_file(relpath)
|
||||
jp2k = Jp2k(jfile)
|
||||
with self.assertWarns(UserWarning):
|
||||
codestream = jp2k.get_codestream(header_only=False)
|
||||
|
|
@ -87,7 +81,7 @@ class TestSuiteNegative(unittest.TestCase):
|
|||
def test_nr_cannotreadwnosizeknown(self):
|
||||
"""not sure exactly what is wrong with this file"""
|
||||
relpath = 'input/nonregression/Cannotreaddatawithnosizeknown.j2k'
|
||||
jfile = os.path.join(DATA_ROOT, relpath)
|
||||
jfile = opj_data_file(relpath)
|
||||
jp2k = Jp2k(jfile)
|
||||
jp2k.get_codestream(header_only=False)
|
||||
self.assertTrue(True)
|
||||
|
|
@ -118,7 +112,7 @@ class TestSuiteNegative(unittest.TestCase):
|
|||
# Verify that a warning is issued if we read past the end of a box
|
||||
# This file has a palette (pclr) box whose length is impossibly
|
||||
# short.
|
||||
infile = os.path.join(DATA_ROOT,
|
||||
infile = os.path.join(OPJ_DATA_ROOT,
|
||||
'input/nonregression/mem-b2ace68c-1381.jp2')
|
||||
with self.assertWarns(UserWarning):
|
||||
Jp2k(infile)
|
||||
|
|
|
|||
|
|
@ -19,23 +19,17 @@ else:
|
|||
import unittest
|
||||
|
||||
from .fixtures import read_image, NO_READ_BACKEND, NO_READ_BACKEND_MSG
|
||||
from .fixtures import OPJ_DATA_ROOT, opj_data_file
|
||||
|
||||
from glymur import Jp2k
|
||||
import glymur
|
||||
|
||||
try:
|
||||
data_root = os.environ['OPJ_DATA_ROOT']
|
||||
except KeyError:
|
||||
data_root = None
|
||||
except:
|
||||
raise
|
||||
|
||||
|
||||
@unittest.skipIf(os.name == "nt", "no write support on windows, period")
|
||||
@unittest.skipIf(glymur.lib.openjp2.OPENJP2 is None,
|
||||
"Missing openjp2 library.")
|
||||
@unittest.skipIf(NO_READ_BACKEND, NO_READ_BACKEND_MSG)
|
||||
@unittest.skipIf(data_root is None,
|
||||
@unittest.skipIf(OPJ_DATA_ROOT is None,
|
||||
"OPJ_DATA_ROOT environment variable not set")
|
||||
class TestSuiteWrite(unittest.TestCase):
|
||||
"""Tests for writing with openjp2 backend.
|
||||
|
|
@ -51,7 +45,7 @@ class TestSuiteWrite(unittest.TestCase):
|
|||
|
||||
def test_NR_ENC_Bretagne1_ppm_1_encode(self):
|
||||
"""NR-ENC-Bretagne1.ppm-1-encode"""
|
||||
infile = os.path.join(data_root, 'input/nonregression/Bretagne1.ppm')
|
||||
infile = opj_data_file('input/nonregression/Bretagne1.ppm')
|
||||
data = read_image(infile)
|
||||
with tempfile.NamedTemporaryFile(suffix='.j2k') as tfile:
|
||||
j = Jp2k(tfile.name, 'wb')
|
||||
|
|
@ -115,7 +109,7 @@ class TestSuiteWrite(unittest.TestCase):
|
|||
|
||||
def test_NR_ENC_Bretagne1_ppm_2_encode(self):
|
||||
"""NR-ENC-Bretagne1.ppm-2-encode"""
|
||||
infile = os.path.join(data_root, 'input/nonregression/Bretagne1.ppm')
|
||||
infile = opj_data_file('input/nonregression/Bretagne1.ppm')
|
||||
data = read_image(infile)
|
||||
with tempfile.NamedTemporaryFile(suffix='.j2k') as tfile:
|
||||
j = Jp2k(tfile.name, 'wb')
|
||||
|
|
@ -180,7 +174,7 @@ class TestSuiteWrite(unittest.TestCase):
|
|||
|
||||
def test_NR_ENC_Bretagne1_ppm_3_encode(self):
|
||||
"""NR-ENC-Bretagne1.ppm-3-encode"""
|
||||
infile = os.path.join(data_root, 'input/nonregression/Bretagne1.ppm')
|
||||
infile = opj_data_file('input/nonregression/Bretagne1.ppm')
|
||||
data = read_image(infile)
|
||||
with tempfile.NamedTemporaryFile(suffix='.j2k') as tfile:
|
||||
j = Jp2k(tfile.name, 'wb')
|
||||
|
|
@ -247,7 +241,7 @@ class TestSuiteWrite(unittest.TestCase):
|
|||
|
||||
def test_NR_ENC_Bretagne2_ppm_4_encode(self):
|
||||
"""NR-ENC-Bretagne2.ppm-4-encode"""
|
||||
infile = os.path.join(data_root, 'input/nonregression/Bretagne2.ppm')
|
||||
infile = opj_data_file('input/nonregression/Bretagne2.ppm')
|
||||
data = read_image(infile)
|
||||
with tempfile.NamedTemporaryFile(suffix='.j2k') as tfile:
|
||||
j = Jp2k(tfile.name, 'wb')
|
||||
|
|
@ -316,7 +310,7 @@ class TestSuiteWrite(unittest.TestCase):
|
|||
|
||||
def test_NR_ENC_Bretagne2_ppm_5_encode(self):
|
||||
"""NR-ENC-Bretagne2.ppm-5-encode"""
|
||||
infile = os.path.join(data_root, 'input/nonregression/Bretagne2.ppm')
|
||||
infile = opj_data_file('input/nonregression/Bretagne2.ppm')
|
||||
data = read_image(infile)
|
||||
with tempfile.NamedTemporaryFile(suffix='.j2k') as tfile:
|
||||
j = Jp2k(tfile.name, 'wb')
|
||||
|
|
@ -379,7 +373,7 @@ class TestSuiteWrite(unittest.TestCase):
|
|||
|
||||
def test_NR_ENC_Bretagne2_ppm_6_encode(self):
|
||||
"""NR-ENC-Bretagne2.ppm-6-encode"""
|
||||
infile = os.path.join(data_root, 'input/nonregression/Bretagne2.ppm')
|
||||
infile = opj_data_file('input/nonregression/Bretagne2.ppm')
|
||||
data = read_image(infile)
|
||||
with tempfile.NamedTemporaryFile(suffix='.j2k') as tfile:
|
||||
j = Jp2k(tfile.name, 'wb')
|
||||
|
|
@ -447,7 +441,7 @@ class TestSuiteWrite(unittest.TestCase):
|
|||
|
||||
def test_NR_ENC_Bretagne2_ppm_7_encode(self):
|
||||
"""NR-ENC-Bretagne2.ppm-7-encode"""
|
||||
infile = os.path.join(data_root, 'input/nonregression/Bretagne2.ppm')
|
||||
infile = opj_data_file('input/nonregression/Bretagne2.ppm')
|
||||
data = read_image(infile)
|
||||
with tempfile.NamedTemporaryFile(suffix='.j2k') as tfile:
|
||||
j = Jp2k(tfile.name, 'wb')
|
||||
|
|
@ -514,7 +508,7 @@ class TestSuiteWrite(unittest.TestCase):
|
|||
|
||||
def test_NR_ENC_Bretagne2_ppm_8_encode(self):
|
||||
"""NR-ENC-Bretagne2.ppm-8-encode"""
|
||||
infile = os.path.join(data_root, 'input/nonregression/Bretagne2.ppm')
|
||||
infile = opj_data_file('input/nonregression/Bretagne2.ppm')
|
||||
data = read_image(infile)
|
||||
with tempfile.NamedTemporaryFile(suffix='.j2k') as tfile:
|
||||
j = Jp2k(tfile.name, 'wb')
|
||||
|
|
@ -578,7 +572,7 @@ class TestSuiteWrite(unittest.TestCase):
|
|||
|
||||
def test_NR_ENC_Cevennes1_bmp_9_encode(self):
|
||||
"""NR-ENC-Cevennes1.bmp-9-encode"""
|
||||
infile = os.path.join(data_root, 'input/nonregression/Cevennes1.bmp')
|
||||
infile = opj_data_file('input/nonregression/Cevennes1.bmp')
|
||||
data = read_image(infile)
|
||||
with tempfile.NamedTemporaryFile(suffix='.j2k') as tfile:
|
||||
j = Jp2k(tfile.name, 'wb')
|
||||
|
|
@ -641,7 +635,7 @@ class TestSuiteWrite(unittest.TestCase):
|
|||
|
||||
def test_NR_ENC_Cevennes2_ppm_10_encode(self):
|
||||
"""NR-ENC-Cevennes2.ppm-10-encode"""
|
||||
infile = os.path.join(data_root, 'input/nonregression/Cevennes2.ppm')
|
||||
infile = opj_data_file('input/nonregression/Cevennes2.ppm')
|
||||
data = read_image(infile)
|
||||
with tempfile.NamedTemporaryFile(suffix='.j2k') as tfile:
|
||||
j = Jp2k(tfile.name, 'wb')
|
||||
|
|
@ -704,8 +698,7 @@ class TestSuiteWrite(unittest.TestCase):
|
|||
|
||||
def test_NR_ENC_Rome_bmp_11_encode(self):
|
||||
"""NR-ENC-Rome.bmp-11-encode"""
|
||||
data = read_image(os.path.join(data_root,
|
||||
'input/nonregression/Rome.bmp'))
|
||||
data = read_image(opj_data_file('input/nonregression/Rome.bmp'))
|
||||
with tempfile.NamedTemporaryFile(suffix='.jp2') as tfile:
|
||||
jp2 = Jp2k(tfile.name, 'wb')
|
||||
jp2.write(data, psnr=[30, 35, 50], prog='LRCP', numres=3)
|
||||
|
|
@ -804,8 +797,7 @@ class TestSuiteWrite(unittest.TestCase):
|
|||
"""NR-ENC-random-issue-0005.tif-12-encode"""
|
||||
# opj_decompress has trouble reading it, but that is not an issue here.
|
||||
# The nature of the image itself seems to give the compressor trouble.
|
||||
infile = os.path.join(data_root,
|
||||
'input/nonregression/random-issue-0005.tif')
|
||||
infile = opj_data_file('input/nonregression/random-issue-0005.tif')
|
||||
data = read_image(infile)
|
||||
with tempfile.NamedTemporaryFile(suffix='.j2k') as tfile:
|
||||
j = Jp2k(tfile.name, 'wb')
|
||||
|
|
|
|||
|
|
@ -32,13 +32,7 @@ else:
|
|||
|
||||
import glymur
|
||||
from glymur import Jp2k
|
||||
|
||||
try:
|
||||
DATA_ROOT = os.environ['OPJ_DATA_ROOT']
|
||||
except KeyError:
|
||||
DATA_ROOT = None
|
||||
except:
|
||||
raise
|
||||
from .fixtures import OPJ_DATA_ROOT, opj_data_file
|
||||
|
||||
|
||||
@unittest.skipIf(os.name == "nt", "Temporary file issue on window.")
|
||||
|
|
@ -287,11 +281,11 @@ class TestPrinting(unittest.TestCase):
|
|||
expected = '\n'.join(lines)
|
||||
self.assertEqual(actual, expected)
|
||||
|
||||
@unittest.skipIf(DATA_ROOT is None,
|
||||
@unittest.skipIf(OPJ_DATA_ROOT is None,
|
||||
"OPJ_DATA_ROOT environment variable not set")
|
||||
def test_icc_profile(self):
|
||||
"""verify printing of colr box with ICC profile"""
|
||||
filename = os.path.join(DATA_ROOT, 'input/nonregression/text_GBR.jp2')
|
||||
filename = opj_data_file('input/nonregression/text_GBR.jp2')
|
||||
with warnings.catch_warnings():
|
||||
# brand is 'jp2 ', but has any icc profile.
|
||||
warnings.simplefilter("ignore")
|
||||
|
|
@ -356,11 +350,11 @@ class TestPrinting(unittest.TestCase):
|
|||
expected = '\n'.join(lines)
|
||||
self.assertEqual(actual, expected)
|
||||
|
||||
@unittest.skipIf(DATA_ROOT is None,
|
||||
@unittest.skipIf(OPJ_DATA_ROOT is None,
|
||||
"OPJ_DATA_ROOT environment variable not set")
|
||||
def test_crg(self):
|
||||
"""verify printing of CRG segment"""
|
||||
filename = os.path.join(DATA_ROOT, 'input/conformance/p0_03.j2k')
|
||||
filename = opj_data_file('input/conformance/p0_03.j2k')
|
||||
j = glymur.Jp2k(filename)
|
||||
codestream = j.get_codestream()
|
||||
with patch('sys.stdout', new=StringIO()) as fake_out:
|
||||
|
|
@ -371,11 +365,11 @@ class TestPrinting(unittest.TestCase):
|
|||
expected = '\n'.join(lines)
|
||||
self.assertEqual(actual, expected)
|
||||
|
||||
@unittest.skipIf(DATA_ROOT is None,
|
||||
@unittest.skipIf(OPJ_DATA_ROOT is None,
|
||||
"OPJ_DATA_ROOT environment variable not set")
|
||||
def test_rgn(self):
|
||||
"""verify printing of RGN segment"""
|
||||
filename = os.path.join(DATA_ROOT, 'input/conformance/p0_03.j2k')
|
||||
filename = opj_data_file('input/conformance/p0_03.j2k')
|
||||
j = glymur.Jp2k(filename)
|
||||
codestream = j.get_codestream(header_only=False)
|
||||
with patch('sys.stdout', new=StringIO()) as fake_out:
|
||||
|
|
@ -388,11 +382,11 @@ class TestPrinting(unittest.TestCase):
|
|||
expected = '\n'.join(lines)
|
||||
self.assertEqual(actual, expected)
|
||||
|
||||
@unittest.skipIf(DATA_ROOT is None,
|
||||
@unittest.skipIf(OPJ_DATA_ROOT is None,
|
||||
"OPJ_DATA_ROOT environment variable not set")
|
||||
def test_sop(self):
|
||||
"""verify printing of SOP segment"""
|
||||
filename = os.path.join(DATA_ROOT, 'input/conformance/p0_03.j2k')
|
||||
filename = opj_data_file('input/conformance/p0_03.j2k')
|
||||
j = glymur.Jp2k(filename)
|
||||
codestream = j.get_codestream(header_only=False)
|
||||
with patch('sys.stdout', new=StringIO()) as fake_out:
|
||||
|
|
@ -403,11 +397,11 @@ class TestPrinting(unittest.TestCase):
|
|||
expected = '\n'.join(lines)
|
||||
self.assertEqual(actual, expected)
|
||||
|
||||
@unittest.skipIf(DATA_ROOT is None,
|
||||
@unittest.skipIf(OPJ_DATA_ROOT is None,
|
||||
"OPJ_DATA_ROOT environment variable not set")
|
||||
def test_cme(self):
|
||||
"""Test printing a CME or comment marker segment."""
|
||||
filename = os.path.join(DATA_ROOT, 'input/conformance/p0_02.j2k')
|
||||
filename = opj_data_file('input/conformance/p0_02.j2k')
|
||||
j = glymur.Jp2k(filename)
|
||||
codestream = j.get_codestream()
|
||||
# 2nd to last segment in the main header
|
||||
|
|
@ -431,11 +425,11 @@ class TestPrinting(unittest.TestCase):
|
|||
expected = '\n'.join(lines)
|
||||
self.assertEqual(actual, expected)
|
||||
|
||||
@unittest.skipIf(DATA_ROOT is None,
|
||||
@unittest.skipIf(OPJ_DATA_ROOT is None,
|
||||
"OPJ_DATA_ROOT environment variable not set")
|
||||
def test_plt_segment(self):
|
||||
"""verify printing of PLT segment"""
|
||||
filename = os.path.join(DATA_ROOT, 'input/conformance/p0_07.j2k')
|
||||
filename = opj_data_file('input/conformance/p0_07.j2k')
|
||||
j = glymur.Jp2k(filename)
|
||||
codestream = j.get_codestream(header_only=False)
|
||||
with patch('sys.stdout', new=StringIO()) as fake_out:
|
||||
|
|
@ -450,11 +444,11 @@ class TestPrinting(unittest.TestCase):
|
|||
expected = '\n'.join(lines)
|
||||
self.assertEqual(actual, expected)
|
||||
|
||||
@unittest.skipIf(DATA_ROOT is None,
|
||||
@unittest.skipIf(OPJ_DATA_ROOT is None,
|
||||
"OPJ_DATA_ROOT environment variable not set")
|
||||
def test_pod_segment(self):
|
||||
"""verify printing of POD segment"""
|
||||
filename = os.path.join(DATA_ROOT, 'input/conformance/p0_13.j2k')
|
||||
filename = opj_data_file('input/conformance/p0_13.j2k')
|
||||
j = glymur.Jp2k(filename)
|
||||
codestream = j.get_codestream()
|
||||
with patch('sys.stdout', new=StringIO()) as fake_out:
|
||||
|
|
@ -480,11 +474,11 @@ class TestPrinting(unittest.TestCase):
|
|||
expected = '\n'.join(lines)
|
||||
self.assertEqual(actual, expected)
|
||||
|
||||
@unittest.skipIf(DATA_ROOT is None,
|
||||
@unittest.skipIf(OPJ_DATA_ROOT is None,
|
||||
"OPJ_DATA_ROOT environment variable not set")
|
||||
def test_ppm_segment(self):
|
||||
"""verify printing of PPM segment"""
|
||||
filename = os.path.join(DATA_ROOT, 'input/conformance/p1_03.j2k')
|
||||
filename = opj_data_file('input/conformance/p1_03.j2k')
|
||||
j = glymur.Jp2k(filename)
|
||||
codestream = j.get_codestream()
|
||||
with patch('sys.stdout', new=StringIO()) as fake_out:
|
||||
|
|
@ -498,11 +492,11 @@ class TestPrinting(unittest.TestCase):
|
|||
expected = '\n'.join(lines)
|
||||
self.assertEqual(actual, expected)
|
||||
|
||||
@unittest.skipIf(DATA_ROOT is None,
|
||||
@unittest.skipIf(OPJ_DATA_ROOT is None,
|
||||
"OPJ_DATA_ROOT environment variable not set")
|
||||
def test_ppt_segment(self):
|
||||
"""verify printing of ppt segment"""
|
||||
filename = os.path.join(DATA_ROOT, 'input/conformance/p1_06.j2k')
|
||||
filename = opj_data_file('input/conformance/p1_06.j2k')
|
||||
j = glymur.Jp2k(filename)
|
||||
codestream = j.get_codestream(header_only=False)
|
||||
with patch('sys.stdout', new=StringIO()) as fake_out:
|
||||
|
|
@ -610,11 +604,11 @@ class TestPrinting(unittest.TestCase):
|
|||
expected = '\n'.join(lines)
|
||||
self.assertEqual(actual, expected)
|
||||
|
||||
@unittest.skipIf(DATA_ROOT is None,
|
||||
@unittest.skipIf(OPJ_DATA_ROOT is None,
|
||||
"OPJ_DATA_ROOT environment variable not set")
|
||||
def test_tlm_segment(self):
|
||||
"""verify printing of TLM segment"""
|
||||
filename = os.path.join(DATA_ROOT, 'input/conformance/p0_15.j2k')
|
||||
filename = opj_data_file('input/conformance/p0_15.j2k')
|
||||
j = glymur.Jp2k(filename)
|
||||
codestream = j.get_codestream()
|
||||
with patch('sys.stdout', new=StringIO()) as fake_out:
|
||||
|
|
@ -704,11 +698,11 @@ class TestPrinting(unittest.TestCase):
|
|||
|
||||
@unittest.skipIf(sys.hexversion < 0x02070000,
|
||||
"Differences in XML printing between 2.6 and 2.7")
|
||||
@unittest.skipIf(DATA_ROOT is None,
|
||||
@unittest.skipIf(OPJ_DATA_ROOT is None,
|
||||
"OPJ_DATA_ROOT environment variable not set")
|
||||
def test_xml(self):
|
||||
"""verify printing of XML box"""
|
||||
filename = os.path.join(DATA_ROOT, 'input/conformance/file1.jp2')
|
||||
filename = opj_data_file('input/conformance/file1.jp2')
|
||||
j = glymur.Jp2k(filename)
|
||||
with patch('sys.stdout', new=StringIO()) as fake_out:
|
||||
print(j.box[2])
|
||||
|
|
@ -735,11 +729,11 @@ class TestPrinting(unittest.TestCase):
|
|||
expected = '\n'.join(lines)
|
||||
self.assertEqual(actual, expected)
|
||||
|
||||
@unittest.skipIf(DATA_ROOT is None,
|
||||
@unittest.skipIf(OPJ_DATA_ROOT is None,
|
||||
"OPJ_DATA_ROOT environment variable not set")
|
||||
def test_channel_definition(self):
|
||||
"""verify printing of cdef box"""
|
||||
filename = os.path.join(DATA_ROOT, 'input/conformance/file2.jp2')
|
||||
filename = opj_data_file('input/conformance/file2.jp2')
|
||||
j = glymur.Jp2k(filename)
|
||||
with patch('sys.stdout', new=StringIO()) as fake_out:
|
||||
print(j.box[2].box[2])
|
||||
|
|
@ -751,11 +745,11 @@ class TestPrinting(unittest.TestCase):
|
|||
expected = '\n'.join(lines)
|
||||
self.assertEqual(actual, expected)
|
||||
|
||||
@unittest.skipIf(DATA_ROOT is None,
|
||||
@unittest.skipIf(OPJ_DATA_ROOT is None,
|
||||
"OPJ_DATA_ROOT environment variable not set")
|
||||
def test_component_mapping(self):
|
||||
"""verify printing of cmap box"""
|
||||
filename = os.path.join(DATA_ROOT, 'input/conformance/file9.jp2')
|
||||
filename = opj_data_file('input/conformance/file9.jp2')
|
||||
j = glymur.Jp2k(filename)
|
||||
with patch('sys.stdout', new=StringIO()) as fake_out:
|
||||
print(j.box[2].box[2])
|
||||
|
|
@ -767,11 +761,11 @@ class TestPrinting(unittest.TestCase):
|
|||
expected = '\n'.join(lines)
|
||||
self.assertEqual(actual, expected)
|
||||
|
||||
@unittest.skipIf(DATA_ROOT is None,
|
||||
@unittest.skipIf(OPJ_DATA_ROOT is None,
|
||||
"OPJ_DATA_ROOT environment variable not set")
|
||||
def test_palette7(self):
|
||||
"""verify printing of pclr box"""
|
||||
filename = os.path.join(DATA_ROOT, 'input/conformance/file9.jp2')
|
||||
filename = opj_data_file('input/conformance/file9.jp2')
|
||||
j = glymur.Jp2k(filename)
|
||||
with patch('sys.stdout', new=StringIO()) as fake_out:
|
||||
print(j.box[2].box[1])
|
||||
|
|
@ -781,11 +775,11 @@ class TestPrinting(unittest.TestCase):
|
|||
expected = '\n'.join(lines)
|
||||
self.assertEqual(actual, expected)
|
||||
|
||||
@unittest.skipIf(DATA_ROOT is None,
|
||||
@unittest.skipIf(OPJ_DATA_ROOT is None,
|
||||
"OPJ_DATA_ROOT environment variable not set")
|
||||
def test_rreq(self):
|
||||
"""verify printing of reader requirements box"""
|
||||
filename = os.path.join(DATA_ROOT, 'input/conformance/file7.jp2')
|
||||
filename = opj_data_file('input/conformance/file7.jp2')
|
||||
j = glymur.Jp2k(filename)
|
||||
with patch('sys.stdout', new=StringIO()) as fake_out:
|
||||
print(j.box[2])
|
||||
|
|
@ -805,11 +799,11 @@ class TestPrinting(unittest.TestCase):
|
|||
expected = '\n'.join(lines)
|
||||
self.assertEqual(actual, expected)
|
||||
|
||||
@unittest.skipIf(DATA_ROOT is None,
|
||||
@unittest.skipIf(OPJ_DATA_ROOT is None,
|
||||
"OPJ_DATA_ROOT environment variable not set")
|
||||
def test_differing_subsamples(self):
|
||||
"""verify printing of SIZ with different subsampling... Issue 86."""
|
||||
filename = os.path.join(DATA_ROOT, 'input/conformance/p0_05.j2k')
|
||||
filename = opj_data_file('input/conformance/p0_05.j2k')
|
||||
j = glymur.Jp2k(filename)
|
||||
codestream = j.get_codestream()
|
||||
with patch('sys.stdout', new=StringIO()) as fake_out:
|
||||
|
|
@ -828,11 +822,11 @@ class TestPrinting(unittest.TestCase):
|
|||
expected = '\n'.join(lines)
|
||||
self.assertEqual(actual, expected)
|
||||
|
||||
@unittest.skipIf(DATA_ROOT is None,
|
||||
@unittest.skipIf(OPJ_DATA_ROOT is None,
|
||||
"OPJ_DATA_ROOT environment variable not set")
|
||||
def test_palette_box(self):
|
||||
"""Verify that palette (pclr) boxes are printed without error."""
|
||||
filename = os.path.join(DATA_ROOT, 'input/conformance/file9.jp2')
|
||||
filename = opj_data_file('input/conformance/file9.jp2')
|
||||
j = glymur.Jp2k(filename)
|
||||
with patch('sys.stdout', new=StringIO()) as fake_out:
|
||||
print(j.box[2].box[1])
|
||||
|
|
@ -921,13 +915,13 @@ class TestPrinting(unittest.TestCase):
|
|||
|
||||
@unittest.skipIf(sys.hexversion < 0x03000000,
|
||||
"Ordered dicts not printing well in 2.7")
|
||||
@unittest.skipIf(DATA_ROOT is None,
|
||||
@unittest.skipIf(OPJ_DATA_ROOT is None,
|
||||
"OPJ_DATA_ROOT environment variable not set")
|
||||
def test_jpx_approx_icc_profile(self):
|
||||
"""verify jpx with approx field equal to zero"""
|
||||
# ICC profiles may be used in JP2, but the approximation field should
|
||||
# be zero unless we have jpx. This file does both.
|
||||
filename = os.path.join(DATA_ROOT, 'input/nonregression/text_GBR.jp2')
|
||||
filename = opj_data_file('input/nonregression/text_GBR.jp2')
|
||||
with warnings.catch_warnings():
|
||||
# brand is 'jp2 ', but has any icc profile.
|
||||
warnings.simplefilter("ignore")
|
||||
|
|
@ -966,11 +960,11 @@ class TestPrinting(unittest.TestCase):
|
|||
expected = '\n'.join(lines)
|
||||
self.assertEqual(actual, expected)
|
||||
|
||||
@unittest.skipIf(DATA_ROOT is None,
|
||||
@unittest.skipIf(OPJ_DATA_ROOT is None,
|
||||
"OPJ_DATA_ROOT environment variable not set")
|
||||
def test_uuid(self):
|
||||
"""verify printing of UUID box"""
|
||||
filename = os.path.join(DATA_ROOT, 'input/nonregression/text_GBR.jp2')
|
||||
filename = opj_data_file('input/nonregression/text_GBR.jp2')
|
||||
with warnings.catch_warnings():
|
||||
# brand is 'jp2 ', but has any icc profile.
|
||||
warnings.simplefilter("ignore")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue