diff --git a/glymur/test/fixtures.py b/glymur/test/fixtures.py index eec9e22..4c99ade 100644 --- a/glymur/test/fixtures.py +++ b/glymur/test/fixtures.py @@ -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 diff --git a/glymur/test/test_icc.py b/glymur/test/test_icc.py index bf589a5..8668999 100644 --- a/glymur/test/test_icc.py +++ b/glymur/test/test_icc.py @@ -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 diff --git a/glymur/test/test_jp2k.py b/glymur/test/test_jp2k.py index ea19199..699fef7 100644 --- a/glymur/test/test_jp2k.py +++ b/glymur/test/test_jp2k.py @@ -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() diff --git a/glymur/test/test_opj_suite.py b/glymur/test/test_opj_suite.py index c622f44..93e9745 100644 --- a/glymur/test/test_opj_suite.py +++ b/glymur/test/test_opj_suite.py @@ -30,7 +30,6 @@ suite. # unittest2 is python2.6 only (pylint/python-2.7) # pylint: disable=F0401 -import os import re import sys @@ -46,22 +45,13 @@ import numpy as np from glymur import Jp2k import glymur -from .fixtures import OPENJPEG_VERSION -from .fixtures import OPENJP2_IS_V2_OFFICIAL -from .fixtures import mse, peak_tolerance, read_pgx - - -try: - data_root = os.environ['OPJ_DATA_ROOT'] -except KeyError: - data_root = None -except: - raise +from .fixtures import OPENJPEG_VERSION, OPENJP2_IS_V2_OFFICIAL, OPJ_DATA_ROOT +from .fixtures import mse, peak_tolerance, read_pgx, opj_data_file @unittest.skipIf(glymur.lib.openjp2.OPENJP2 is None, "Missing openjp2 library.") -@unittest.skipIf(data_root is None, +@unittest.skipIf(OPJ_DATA_ROOT is None, "OPJ_DATA_ROOT environment variable not set") class TestSuite(unittest.TestCase): @@ -72,78 +62,74 @@ class TestSuite(unittest.TestCase): pass def test_ETS_C0P0_p0_01_j2k(self): - jfile = os.path.join(data_root, 'input/conformance/p0_01.j2k') + jfile = opj_data_file('input/conformance/p0_01.j2k') jp2k = Jp2k(jfile) jpdata = jp2k.read(rlevel=0) - pgxfile = os.path.join(data_root, 'baseline/conformance/c0p0_01.pgx') + pgxfile = opj_data_file('baseline/conformance/c0p0_01.pgx') pgxdata = read_pgx(pgxfile) np.testing.assert_array_equal(jpdata, pgxdata) def test_ETS_C0P0_p0_02_j2k(self): - jfile = os.path.join(data_root, 'input/conformance/p0_02.j2k') + jfile = opj_data_file('input/conformance/p0_02.j2k') jp2k = Jp2k(jfile) with warnings.catch_warnings(): # Invalid marker ID. warnings.simplefilter("ignore") jpdata = jp2k.read(rlevel=0) - pgxfile = os.path.join(data_root, 'baseline/conformance/c0p0_02.pgx') + pgxfile = opj_data_file('baseline/conformance/c0p0_02.pgx') pgxdata = read_pgx(pgxfile) np.testing.assert_array_equal(jpdata, pgxdata) @unittest.skip("Known failure in OPENJPEG test suite.") def test_ETS_C0P0_p0_03_j2k(self): - jfile = os.path.join(data_root, 'input/conformance/p0_03.j2k') + jfile = opj_data_file('input/conformance/p0_03.j2k') jp2k = Jp2k(jfile) jpdata = jp2k.read(rlevel=0) - pgxfile = os.path.join(data_root, 'baseline/conformance/c0p0_03r0.pgx') + pgxfile = opj_data_file('baseline/conformance/c0p0_03r0.pgx') pgxdata = read_pgx(pgxfile) np.testing.assert_array_equal(jpdata, pgxdata) def test_ETS_C0P0_p0_03_j2k_r1(self): - jfile = os.path.join(data_root, 'input/conformance/p0_03.j2k') + jfile = opj_data_file('input/conformance/p0_03.j2k') jp2k = Jp2k(jfile) jpdata = jp2k.read(rlevel=1) - pgxfile = os.path.join(data_root, - 'baseline/conformance/c0p0_03r1.pgx') + pgxfile = opj_data_file('baseline/conformance/c0p0_03r1.pgx') pgxdata = read_pgx(pgxfile) np.testing.assert_array_equal(jpdata, pgxdata) @unittest.skip("Known failure in OPENJPEG test suite.") def test_ETS_C0P0_p0_04_j2k(self): - jfile = os.path.join(data_root, 'input/conformance/p0_04.j2k') + jfile = opj_data_file('input/conformance/p0_04.j2k') jp2k = Jp2k(jfile) jpdata = jp2k.read(rlevel=3) - pgxfile = os.path.join(data_root, - 'baseline/conformance/c0p0_04.pgx') + pgxfile = opj_data_file('baseline/conformance/c0p0_04.pgx') pgxdata = read_pgx(pgxfile) self.assertTrue(peak_tolerance(jpdata[:, :, 2], pgxdata) < 33) self.assertTrue(mse(jpdata[:, :, 2], pgxdata) < 55.8) def test_ETS_C0P0_p0_05_j2k(self): - jfile = os.path.join(data_root, 'input/conformance/p0_05.j2k') + jfile = opj_data_file('input/conformance/p0_05.j2k') jp2k = Jp2k(jfile) jpdata = jp2k.read_bands(rlevel=3) - pgxfile = os.path.join(data_root, - 'baseline/conformance/c0p0_05.pgx') + pgxfile = opj_data_file('baseline/conformance/c0p0_05.pgx') pgxdata = read_pgx(pgxfile) self.assertTrue(peak_tolerance(jpdata[0], pgxdata) < 54) self.assertTrue(mse(jpdata[0], pgxdata) < 68) @unittest.skip("8-bit pgx data vs 12-bit j2k data") def test_ETS_C0P0_p0_06_j2k(self): - jfile = os.path.join(data_root, 'input/conformance/p0_06.j2k') + jfile = opj_data_file('input/conformance/p0_06.j2k') jp2k = Jp2k(jfile) jpdata = jp2k.read_bands(rlevel=3) - pgxfile = os.path.join(data_root, - 'baseline/conformance/c0p0_06.pgx') + pgxfile = opj_data_file('baseline/conformance/c0p0_06.pgx') pgxdata = read_pgx(pgxfile) tol = peak_tolerance(jpdata[0], pgxdata) self.assertTrue(tol < 109) @@ -152,12 +138,11 @@ class TestSuite(unittest.TestCase): @unittest.skip("Known failure in OPENJPEG test suite.") def test_ETS_C0P0_p0_07_j2k(self): - jfile = os.path.join(data_root, 'input/conformance/p0_07.j2k') + jfile = opj_data_file('input/conformance/p0_07.j2k') jp2k = Jp2k(jfile) jpdata = jp2k.read() - pgxfile = os.path.join(data_root, - 'baseline/conformance/c0p0_07.pgx') + pgxfile = opj_data_file('baseline/conformance/c0p0_07.pgx') pgxdata = read_pgx(pgxfile) self.assertTrue(peak_tolerance(jpdata[:, :, 0], pgxdata) < 10) @@ -165,24 +150,22 @@ class TestSuite(unittest.TestCase): @unittest.skip("8-bit pgx data vs 12-bit j2k data") def test_ETS_C0P0_p0_08_j2k(self): - jfile = os.path.join(data_root, 'input/conformance/p0_08.j2k') + jfile = opj_data_file('input/conformance/p0_08.j2k') jp2k = Jp2k(jfile) jpdata = jp2k.read(rlevel=5) - pgxfile = os.path.join(data_root, - 'baseline/conformance/c0p0_08.pgx') + pgxfile = opj_data_file('baseline/conformance/c0p0_08.pgx') pgxdata = read_pgx(pgxfile) self.assertTrue(peak_tolerance(jpdata[:, :, 0], pgxdata) < 7) self.assertTrue(mse(jpdata[:, :, 0], pgxdata) < 6.72) def test_ETS_C0P0_p0_09_j2k(self): - jfile = os.path.join(data_root, 'input/conformance/p0_09.j2k') + jfile = opj_data_file('input/conformance/p0_09.j2k') jp2k = Jp2k(jfile) jpdata = jp2k.read(rlevel=2) - pgxfile = os.path.join(data_root, - 'baseline/conformance/c0p0_09.pgx') + pgxfile = opj_data_file('baseline/conformance/c0p0_09.pgx') pgxdata = read_pgx(pgxfile) self.assertTrue(peak_tolerance(jpdata, pgxdata) < 4) @@ -190,129 +173,118 @@ class TestSuite(unittest.TestCase): @unittest.skip("Known failure in OPENJPEG test suite.") def test_ETS_C0P0_p0_10_j2k(self): - jfile = os.path.join(data_root, 'input/conformance/p0_10.j2k') + jfile = opj_data_file('input/conformance/p0_10.j2k') jp2k = Jp2k(jfile) jpdata = jp2k.read(rlevel=0) - pgxfile = os.path.join(data_root, - 'baseline/conformance/c0p0_10.pgx') + pgxfile = opj_data_file('baseline/conformance/c0p0_10.pgx') pgxdata = read_pgx(pgxfile) self.assertTrue(peak_tolerance(jpdata[:, :, 0], pgxdata) < 10) self.assertTrue(mse(jpdata[:, :, 0], pgxdata) < 2.84) def test_ETS_C0P0_p0_11_j2k(self): - jfile = os.path.join(data_root, 'input/conformance/p0_11.j2k') + jfile = opj_data_file('input/conformance/p0_11.j2k') jp2k = Jp2k(jfile) jpdata = jp2k.read(rlevel=0) - pgxfile = os.path.join(data_root, - 'baseline/conformance/c0p0_11.pgx') + pgxfile = opj_data_file('baseline/conformance/c0p0_11.pgx') pgxdata = read_pgx(pgxfile) np.testing.assert_array_equal(jpdata, pgxdata) @unittest.skip("fprintf stderr output in r2343.") def test_ETS_C0P0_p0_12_j2k(self): - jfile = os.path.join(data_root, 'input/conformance/p0_12.j2k') + jfile = opj_data_file('input/conformance/p0_12.j2k') jp2k = Jp2k(jfile) jpdata = jp2k.read(rlevel=0) - pgxfile = os.path.join(data_root, - 'baseline/conformance/c0p0_12.pgx') + pgxfile = opj_data_file('baseline/conformance/c0p0_12.pgx') pgxdata = read_pgx(pgxfile) np.testing.assert_array_equal(jpdata, pgxdata) @unittest.skip("Known failure in OPENJPEG test suite.") def test_ETS_C0P0_p0_13_j2k(self): - jfile = os.path.join(data_root, 'input/conformance/p0_13.j2k') + jfile = opj_data_file('input/conformance/p0_13.j2k') jp2k = Jp2k(jfile) jpdata = jp2k.read(rlevel=0) - pgxfile = os.path.join(data_root, - 'baseline/conformance/c0p0_13.pgx') + pgxfile = opj_data_file('baseline/conformance/c0p0_13.pgx') pgxdata = read_pgx(pgxfile) np.testing.assert_array_equal(jpdata[:, :, 0], pgxdata) @unittest.skip("Known failure in OPENJPEG test suite.") def test_ETS_C0P0_p0_14_j2k(self): - jfile = os.path.join(data_root, 'input/conformance/p0_14.j2k') + jfile = opj_data_file('input/conformance/p0_14.j2k') jp2k = Jp2k(jfile) jpdata = jp2k.read(rlevel=2) - pgxfile = os.path.join(data_root, - 'baseline/conformance/c0p0_14.pgx') + pgxfile = opj_data_file('baseline/conformance/c0p0_14.pgx') pgxdata = read_pgx(pgxfile) np.testing.assert_array_equal(jpdata[:, :, 0], pgxdata) @unittest.skip("Known failure in OPENJPEG test suite.") def test_ETS_C0P0_p0_15_j2k(self): - jfile = os.path.join(data_root, 'input/conformance/p0_15.j2k') + jfile = opj_data_file('input/conformance/p0_15.j2k') jp2k = Jp2k(jfile) jpdata = jp2k.read(rlevel=0) - pgxfile = os.path.join(data_root, - 'baseline/conformance/c0p0_15r0.pgx') + pgxfile = opj_data_file('baseline/conformance/c0p0_15r0.pgx') pgxdata = read_pgx(pgxfile) np.testing.assert_array_equal(jpdata, pgxdata) def test_ETS_C0P0_p0_15_j2k_r1(self): - jfile = os.path.join(data_root, 'input/conformance/p0_15.j2k') + jfile = opj_data_file('input/conformance/p0_15.j2k') jp2k = Jp2k(jfile) jpdata = jp2k.read(rlevel=1) - pgxfile = os.path.join(data_root, - 'baseline/conformance/c0p0_15r1.pgx') + pgxfile = opj_data_file('baseline/conformance/c0p0_15r1.pgx') pgxdata = read_pgx(pgxfile) np.testing.assert_array_equal(jpdata, pgxdata) def test_ETS_C0P0_p0_16_j2k(self): - jfile = os.path.join(data_root, 'input/conformance/p0_16.j2k') + jfile = opj_data_file('input/conformance/p0_16.j2k') jp2k = Jp2k(jfile) jpdata = jp2k.read(rlevel=0) - pgxfile = os.path.join(data_root, - 'baseline/conformance/c0p0_16.pgx') + pgxfile = opj_data_file('baseline/conformance/c0p0_16.pgx') pgxdata = read_pgx(pgxfile) np.testing.assert_array_equal(jpdata, pgxdata) def test_ETS_C0P1_p1_01_j2k(self): - jfile = os.path.join(data_root, 'input/conformance/p1_01.j2k') + jfile = opj_data_file('input/conformance/p1_01.j2k') jp2k = Jp2k(jfile) jpdata = jp2k.read(rlevel=0) - pgxfile = os.path.join(data_root, - 'baseline/conformance/c0p1_01.pgx') + pgxfile = opj_data_file('baseline/conformance/c0p1_01.pgx') pgxdata = read_pgx(pgxfile) np.testing.assert_array_equal(jpdata, pgxdata) @unittest.skip("Known failure in OPENJPEG test suite operation.") def test_ETS_C0P1_p1_02_j2k(self): - jfile = os.path.join(data_root, 'input/conformance/p1_02.j2k') + jfile = opj_data_file('input/conformance/p1_02.j2k') jp2k = Jp2k(jfile) jpdata = jp2k.read(rlevel=3) - pgxfile = os.path.join(data_root, - 'baseline/conformance/c0p1_02.pgx') + pgxfile = opj_data_file('baseline/conformance/c0p1_02.pgx') pgxdata = read_pgx(pgxfile) self.assertTrue(peak_tolerance(jpdata[:, :, 0], pgxdata) < 35) self.assertTrue(mse(jpdata[:, :, 0], pgxdata) < 74) def test_ETS_C0P1_p1_03_j2k(self): - jfile = os.path.join(data_root, 'input/conformance/p1_03.j2k') + jfile = opj_data_file('input/conformance/p1_03.j2k') jp2k = Jp2k(jfile) jpdata = jp2k.read_bands(rlevel=3) - pgxfile = os.path.join(data_root, - 'baseline/conformance/c0p1_03.pgx') + pgxfile = opj_data_file('baseline/conformance/c0p1_03.pgx') pgxdata = read_pgx(pgxfile) self.assertTrue(peak_tolerance(jpdata[0], pgxdata) < 28) @@ -320,12 +292,11 @@ class TestSuite(unittest.TestCase): @unittest.skip("Known failure in OPENJPEG test suite operation.") def test_ETS_C0P1_p1_04_j2k(self): - jfile = os.path.join(data_root, 'input/conformance/p1_04.j2k') + jfile = opj_data_file('input/conformance/p1_04.j2k') jp2k = Jp2k(jfile) jpdata = jp2k.read(rlevel=0) - pgxfile = os.path.join(data_root, - 'baseline/conformance/c0p1_04r0.pgx') + pgxfile = opj_data_file('baseline/conformance/c0p1_04r0.pgx') pgxdata = read_pgx(pgxfile) print(peak_tolerance(jpdata, pgxdata)) @@ -334,12 +305,11 @@ class TestSuite(unittest.TestCase): @unittest.skip("Known failure in OPENJPEG test suite, precision issue.") def test_ETS_C0P1_p1_04_j2k_r3(self): - jfile = os.path.join(data_root, 'input/conformance/p1_04.j2k') + jfile = opj_data_file('input/conformance/p1_04.j2k') jp2k = Jp2k(jfile) jpdata = jp2k.read(rlevel=3) - pgxfile = os.path.join(data_root, - 'baseline/conformance/c0p1_04r3.pgx') + pgxfile = opj_data_file('baseline/conformance/c0p1_04r3.pgx') pgxdata = read_pgx(pgxfile) print(peak_tolerance(jpdata, pgxdata)) @@ -348,12 +318,11 @@ class TestSuite(unittest.TestCase): @unittest.skip("Known failure in OPENJPEG test suite operation.") def test_ETS_C0P1_p1_05_j2k(self): - jfile = os.path.join(data_root, 'input/conformance/p1_05.j2k') + jfile = opj_data_file('input/conformance/p1_05.j2k') jp2k = Jp2k(jfile) jpdata = jp2k.read(rlevel=4) - pgxfile = os.path.join(data_root, - 'baseline/conformance/c0p1_05.pgx') + pgxfile = opj_data_file('baseline/conformance/c0p1_05.pgx') pgxdata = read_pgx(pgxfile) print(peak_tolerance(jpdata[:, :, 0], pgxdata)) @@ -363,12 +332,11 @@ class TestSuite(unittest.TestCase): @unittest.skip("Known failure in OPENJPEG test suite operation.") def test_ETS_C0P1_p1_06_j2k(self): - jfile = os.path.join(data_root, 'input/conformance/p1_06.j2k') + jfile = opj_data_file('input/conformance/p1_06.j2k') jp2k = Jp2k(jfile) jpdata = jp2k.read(rlevel=1) - pgxfile = os.path.join(data_root, - 'baseline/conformance/c0p1_06.pgx') + pgxfile = opj_data_file('baseline/conformance/c0p1_06.pgx') pgxdata = read_pgx(pgxfile) print(peak_tolerance(jpdata[:, :, 0], pgxdata)) @@ -378,388 +346,387 @@ class TestSuite(unittest.TestCase): @unittest.skip("fprintf stderr output in r2345.") def test_ETS_C0P1_p1_07_j2k(self): - jfile = os.path.join(data_root, 'input/conformance/p1_07.j2k') + jfile = opj_data_file('input/conformance/p1_07.j2k') jp2k = Jp2k(jfile) jpdata = jp2k.read_bands(rlevel=0) - pgxfile = os.path.join(data_root, - 'baseline/conformance/c0p1_07.pgx') + pgxfile = opj_data_file('baseline/conformance/c0p1_07.pgx') pgxdata = read_pgx(pgxfile) np.testing.assert_array_equal(jpdata[0], pgxdata) def test_ETS_C1P0_p0_01_j2k(self): - jfile = os.path.join(data_root, 'input/conformance/p0_01.j2k') + jfile = opj_data_file('input/conformance/p0_01.j2k') jp2k = Jp2k(jfile) jpdata = jp2k.read(rlevel=0) - pgxfile = os.path.join(data_root, 'baseline/conformance/c1p0_01_0.pgx') + pgxfile = opj_data_file('baseline/conformance/c1p0_01_0.pgx') pgxdata = read_pgx(pgxfile) np.testing.assert_array_equal(jpdata, pgxdata) def test_ETS_C1P0_p0_02_j2k(self): - jfile = os.path.join(data_root, 'input/conformance/p0_02.j2k') + jfile = opj_data_file('input/conformance/p0_02.j2k') jp2k = Jp2k(jfile) jpdata = jp2k.read(rlevel=0) - pgxfile = os.path.join(data_root, 'baseline/conformance/c1p0_02_0.pgx') + pgxfile = opj_data_file('baseline/conformance/c1p0_02_0.pgx') pgxdata = read_pgx(pgxfile) np.testing.assert_array_equal(jpdata, pgxdata) def test_ETS_C1P0_p0_03_j2k(self): - jfile = os.path.join(data_root, 'input/conformance/p0_03.j2k') + jfile = opj_data_file('input/conformance/p0_03.j2k') jp2k = Jp2k(jfile) jpdata = jp2k.read(rlevel=0) - pgxfile = os.path.join(data_root, 'baseline/conformance/c1p0_03_0.pgx') + pgxfile = opj_data_file('baseline/conformance/c1p0_03_0.pgx') pgxdata = read_pgx(pgxfile) np.testing.assert_array_equal(jpdata, pgxdata) def test_ETS_C1P0_p0_04_j2k(self): - jfile = os.path.join(data_root, 'input/conformance/p0_04.j2k') + jfile = opj_data_file('input/conformance/p0_04.j2k') jp2k = Jp2k(jfile) jpdata = jp2k.read(rlevel=0) - pgxfile = os.path.join(data_root, 'baseline/conformance/c1p0_04_0.pgx') + pgxfile = opj_data_file('baseline/conformance/c1p0_04_0.pgx') pgxdata = read_pgx(pgxfile) self.assertTrue(peak_tolerance(jpdata[:, :, 0], pgxdata) < 5) self.assertTrue(mse(jpdata[:, :, 0], pgxdata) < 0.776) - pgxfile = os.path.join(data_root, 'baseline/conformance/c1p0_04_1.pgx') + pgxfile = opj_data_file('baseline/conformance/c1p0_04_1.pgx') pgxdata = read_pgx(pgxfile) self.assertTrue(peak_tolerance(jpdata[:, :, 1], pgxdata) < 4) self.assertTrue(mse(jpdata[:, :, 1], pgxdata) < 0.626) - pgxfile = os.path.join(data_root, 'baseline/conformance/c1p0_04_2.pgx') + pgxfile = opj_data_file('baseline/conformance/c1p0_04_2.pgx') pgxdata = read_pgx(pgxfile) self.assertTrue(peak_tolerance(jpdata[:, :, 2], pgxdata) < 6) self.assertTrue(mse(jpdata[:, :, 2], pgxdata) < 1.07) def test_ETS_C1P0_p0_05_j2k(self): - jfile = os.path.join(data_root, 'input/conformance/p0_05.j2k') + jfile = opj_data_file('input/conformance/p0_05.j2k') jp2k = Jp2k(jfile) jpdata = jp2k.read_bands() - pgxfile = os.path.join(data_root, 'baseline/conformance/c1p0_05_0.pgx') + pgxfile = opj_data_file('baseline/conformance/c1p0_05_0.pgx') pgxdata = read_pgx(pgxfile) self.assertTrue(peak_tolerance(jpdata[0], pgxdata) < 2) self.assertTrue(mse(jpdata[0], pgxdata) < 0.302) - pgxfile = os.path.join(data_root, 'baseline/conformance/c1p0_05_1.pgx') + pgxfile = opj_data_file('baseline/conformance/c1p0_05_1.pgx') pgxdata = read_pgx(pgxfile) self.assertTrue(peak_tolerance(jpdata[1], pgxdata) < 2) self.assertTrue(mse(jpdata[1], pgxdata) < 0.307) - pgxfile = os.path.join(data_root, 'baseline/conformance/c1p0_05_2.pgx') + pgxfile = opj_data_file('baseline/conformance/c1p0_05_2.pgx') pgxdata = read_pgx(pgxfile) self.assertTrue(peak_tolerance(jpdata[2], pgxdata) < 2) self.assertTrue(mse(jpdata[2], pgxdata) < 0.269) - pgxfile = os.path.join(data_root, 'baseline/conformance/c1p0_05_3.pgx') + pgxfile = opj_data_file('baseline/conformance/c1p0_05_3.pgx') pgxdata = read_pgx(pgxfile) self.assertTrue(peak_tolerance(jpdata[3], pgxdata) == 0) self.assertTrue(mse(jpdata[3], pgxdata) == 0) def test_ETS_C1P0_p0_06_j2k(self): - jfile = os.path.join(data_root, 'input/conformance/p0_06.j2k') + jfile = opj_data_file('input/conformance/p0_06.j2k') jp2k = Jp2k(jfile) jpdata = jp2k.read_bands() - pgxfile = os.path.join(data_root, 'baseline/conformance/c1p0_06_0.pgx') + pgxfile = opj_data_file('baseline/conformance/c1p0_06_0.pgx') pgxdata = read_pgx(pgxfile) self.assertTrue(peak_tolerance(jpdata[0], pgxdata) < 635) self.assertTrue(mse(jpdata[0], pgxdata) < 11287) - pgxfile = os.path.join(data_root, 'baseline/conformance/c1p0_06_1.pgx') + pgxfile = opj_data_file('baseline/conformance/c1p0_06_1.pgx') pgxdata = read_pgx(pgxfile) self.assertTrue(peak_tolerance(jpdata[1], pgxdata) < 403) self.assertTrue(mse(jpdata[1], pgxdata) < 6124) - pgxfile = os.path.join(data_root, 'baseline/conformance/c1p0_06_2.pgx') + pgxfile = opj_data_file('baseline/conformance/c1p0_06_2.pgx') pgxdata = read_pgx(pgxfile) self.assertTrue(peak_tolerance(jpdata[2], pgxdata) < 378) self.assertTrue(mse(jpdata[2], pgxdata) < 3968) - pgxfile = os.path.join(data_root, 'baseline/conformance/c1p0_06_3.pgx') + pgxfile = opj_data_file('baseline/conformance/c1p0_06_3.pgx') pgxdata = read_pgx(pgxfile) self.assertTrue(peak_tolerance(jpdata[3], pgxdata) == 0) self.assertTrue(mse(jpdata[3], pgxdata) == 0) @unittest.skip("Known failure in OPENJPEG test suite operation.") def test_ETS_C1P0_p0_07_j2k(self): - jfile = os.path.join(data_root, 'input/conformance/p0_07.j2k') + jfile = opj_data_file('input/conformance/p0_07.j2k') jp2k = Jp2k(jfile) jpdata = jp2k.read() - pgxfile = os.path.join(data_root, 'baseline/conformance/c1p0_07_0.pgx') + pgxfile = opj_data_file('baseline/conformance/c1p0_07_0.pgx') pgxdata = read_pgx(pgxfile) np.testing.assert_array_equal(jpdata[:, :, 0], pgxdata) - pgxfile = os.path.join(data_root, 'baseline/conformance/c1p0_07_1.pgx') + pgxfile = opj_data_file('baseline/conformance/c1p0_07_1.pgx') pgxdata = read_pgx(pgxfile) np.testing.assert_array_equal(jpdata[:, : 1], pgxdata) - pgxfile = os.path.join(data_root, 'baseline/conformance/c1p0_07_2.pgx') + pgxfile = opj_data_file('baseline/conformance/c1p0_07_2.pgx') pgxdata = read_pgx(pgxfile) np.testing.assert_array_equal(jpdata[:, : 2], pgxdata) def test_ETS_C1P0_p0_08_j2k(self): - jfile = os.path.join(data_root, 'input/conformance/p0_08.j2k') + jfile = opj_data_file('input/conformance/p0_08.j2k') jp2k = Jp2k(jfile) jpdata = jp2k.read(rlevel=1) - pgxfile = os.path.join(data_root, 'baseline/conformance/c1p0_08_0.pgx') + pgxfile = opj_data_file('baseline/conformance/c1p0_08_0.pgx') pgxdata = read_pgx(pgxfile) np.testing.assert_array_equal(jpdata[:, :, 0], pgxdata) - pgxfile = os.path.join(data_root, 'baseline/conformance/c1p0_08_1.pgx') + pgxfile = opj_data_file('baseline/conformance/c1p0_08_1.pgx') pgxdata = read_pgx(pgxfile) np.testing.assert_array_equal(jpdata[:, :, 1], pgxdata) - pgxfile = os.path.join(data_root, 'baseline/conformance/c1p0_08_2.pgx') + pgxfile = opj_data_file('baseline/conformance/c1p0_08_2.pgx') pgxdata = read_pgx(pgxfile) np.testing.assert_array_equal(jpdata[:, :, 2], pgxdata) def test_ETS_C1P0_p0_09_j2k(self): - jfile = os.path.join(data_root, 'input/conformance/p0_09.j2k') + jfile = opj_data_file('input/conformance/p0_09.j2k') jp2k = Jp2k(jfile) jpdata = jp2k.read(rlevel=0) - pgxfile = os.path.join(data_root, 'baseline/conformance/c1p0_09_0.pgx') + pgxfile = opj_data_file('baseline/conformance/c1p0_09_0.pgx') pgxdata = read_pgx(pgxfile) np.testing.assert_array_equal(jpdata, pgxdata) def test_ETS_C1P0_p0_10_j2k(self): - jfile = os.path.join(data_root, 'input/conformance/p0_10.j2k') + jfile = opj_data_file('input/conformance/p0_10.j2k') jp2k = Jp2k(jfile) jpdata = jp2k.read(rlevel=0) - pgxfile = os.path.join(data_root, 'baseline/conformance/c1p0_10_0.pgx') + pgxfile = opj_data_file('baseline/conformance/c1p0_10_0.pgx') pgxdata = read_pgx(pgxfile) np.testing.assert_array_equal(jpdata[:, :, 0], pgxdata) - pgxfile = os.path.join(data_root, 'baseline/conformance/c1p0_10_1.pgx') + pgxfile = opj_data_file('baseline/conformance/c1p0_10_1.pgx') pgxdata = read_pgx(pgxfile) np.testing.assert_array_equal(jpdata[:, :, 1], pgxdata) - pgxfile = os.path.join(data_root, 'baseline/conformance/c1p0_10_2.pgx') + pgxfile = opj_data_file('baseline/conformance/c1p0_10_2.pgx') pgxdata = read_pgx(pgxfile) np.testing.assert_array_equal(jpdata[:, :, 2], pgxdata) def test_ETS_C1P0_p0_11_j2k(self): - jfile = os.path.join(data_root, 'input/conformance/p0_11.j2k') + jfile = opj_data_file('input/conformance/p0_11.j2k') jp2k = Jp2k(jfile) jpdata = jp2k.read(rlevel=0) - pgxfile = os.path.join(data_root, 'baseline/conformance/c1p0_11_0.pgx') + pgxfile = opj_data_file('baseline/conformance/c1p0_11_0.pgx') pgxdata = read_pgx(pgxfile) np.testing.assert_array_equal(jpdata, pgxdata) @unittest.skip("fprintf stderr output in r2343.") def test_ETS_C1P0_p0_12_j2k(self): - jfile = os.path.join(data_root, 'input/conformance/p0_12.j2k') + jfile = opj_data_file('input/conformance/p0_12.j2k') jp2k = Jp2k(jfile) jpdata = jp2k.read(rlevel=0) - pgxfile = os.path.join(data_root, 'baseline/conformance/c1p0_12_0.pgx') + pgxfile = opj_data_file('baseline/conformance/c1p0_12_0.pgx') pgxdata = read_pgx(pgxfile) np.testing.assert_array_equal(jpdata, pgxdata) @unittest.skip("fprintf stderr output in r2343.") def test_ETS_C1P0_p0_13_j2k(self): - jfile = os.path.join(data_root, 'input/conformance/p0_13.j2k') + jfile = opj_data_file('input/conformance/p0_13.j2k') jp2k = Jp2k(jfile) jpdata = jp2k.read(rlevel=0) - pgxfile = os.path.join(data_root, 'baseline/conformance/c1p0_13_0.pgx') + pgxfile = opj_data_file('baseline/conformance/c1p0_13_0.pgx') pgxdata = read_pgx(pgxfile) np.testing.assert_array_equal(jpdata[:, :, 0], pgxdata) - pgxfile = os.path.join(data_root, 'baseline/conformance/c1p0_13_1.pgx') + pgxfile = opj_data_file('baseline/conformance/c1p0_13_1.pgx') pgxdata = read_pgx(pgxfile) np.testing.assert_array_equal(jpdata[:, :, 1], pgxdata) - pgxfile = os.path.join(data_root, 'baseline/conformance/c1p0_13_2.pgx') + pgxfile = opj_data_file('baseline/conformance/c1p0_13_2.pgx') pgxdata = read_pgx(pgxfile) np.testing.assert_array_equal(jpdata[:, :, 2], pgxdata) - pgxfile = os.path.join(data_root, 'baseline/conformance/c1p0_13_3.pgx') + pgxfile = opj_data_file('baseline/conformance/c1p0_13_3.pgx') pgxdata = read_pgx(pgxfile) np.testing.assert_array_equal(jpdata[:, :, 3], pgxdata) def test_ETS_C1P0_p0_14_j2k(self): - jfile = os.path.join(data_root, 'input/conformance/p0_14.j2k') + jfile = opj_data_file('input/conformance/p0_14.j2k') jp2k = Jp2k(jfile) jpdata = jp2k.read(rlevel=0) - pgxfile = os.path.join(data_root, 'baseline/conformance/c1p0_14_0.pgx') + pgxfile = opj_data_file('baseline/conformance/c1p0_14_0.pgx') pgxdata = read_pgx(pgxfile) np.testing.assert_array_equal(jpdata[:, :, 0], pgxdata) - pgxfile = os.path.join(data_root, 'baseline/conformance/c1p0_14_1.pgx') + pgxfile = opj_data_file('baseline/conformance/c1p0_14_1.pgx') pgxdata = read_pgx(pgxfile) np.testing.assert_array_equal(jpdata[:, :, 1], pgxdata) - pgxfile = os.path.join(data_root, 'baseline/conformance/c1p0_14_2.pgx') + pgxfile = opj_data_file('baseline/conformance/c1p0_14_2.pgx') pgxdata = read_pgx(pgxfile) np.testing.assert_array_equal(jpdata[:, :, 2], pgxdata) def test_ETS_C1P0_p0_15_j2k(self): - jfile = os.path.join(data_root, 'input/conformance/p0_15.j2k') + jfile = opj_data_file('input/conformance/p0_15.j2k') jp2k = Jp2k(jfile) jpdata = jp2k.read(rlevel=0) - pgxfile = os.path.join(data_root, 'baseline/conformance/c1p0_15_0.pgx') + pgxfile = opj_data_file('baseline/conformance/c1p0_15_0.pgx') pgxdata = read_pgx(pgxfile) np.testing.assert_array_equal(jpdata, pgxdata) def test_ETS_C1P0_p0_16_j2k(self): - jfile = os.path.join(data_root, 'input/conformance/p0_16.j2k') + jfile = opj_data_file('input/conformance/p0_16.j2k') jp2k = Jp2k(jfile) jpdata = jp2k.read(rlevel=0) - pgxfile = os.path.join(data_root, 'baseline/conformance/c1p0_16_0.pgx') + pgxfile = opj_data_file('baseline/conformance/c1p0_16_0.pgx') pgxdata = read_pgx(pgxfile) np.testing.assert_array_equal(jpdata, pgxdata) def test_ETS_C1P1_p1_01_j2k(self): - jfile = os.path.join(data_root, 'input/conformance/p1_01.j2k') + jfile = opj_data_file('input/conformance/p1_01.j2k') jp2k = Jp2k(jfile) jpdata = jp2k.read(rlevel=0) - pgxfile = os.path.join(data_root, 'baseline/conformance/c1p1_01_0.pgx') + pgxfile = opj_data_file('baseline/conformance/c1p1_01_0.pgx') pgxdata = read_pgx(pgxfile) np.testing.assert_array_equal(jpdata, pgxdata) def test_ETS_C1P1_p1_02_j2k(self): - jfile = os.path.join(data_root, 'input/conformance/p1_02.j2k') + jfile = opj_data_file('input/conformance/p1_02.j2k') jp2k = Jp2k(jfile) jpdata = jp2k.read(rlevel=0) - pgxfile = os.path.join(data_root, 'baseline/conformance/c1p1_02_0.pgx') + pgxfile = opj_data_file('baseline/conformance/c1p1_02_0.pgx') pgxdata = read_pgx(pgxfile) self.assertTrue(peak_tolerance(jpdata[:, :, 0], pgxdata) < 5) self.assertTrue(mse(jpdata[:, :, 0], pgxdata) < 0.765) - pgxfile = os.path.join(data_root, 'baseline/conformance/c1p1_02_1.pgx') + pgxfile = opj_data_file('baseline/conformance/c1p1_02_1.pgx') pgxdata = read_pgx(pgxfile) self.assertTrue(peak_tolerance(jpdata[:, :, 1], pgxdata) < 4) self.assertTrue(mse(jpdata[:, :, 1], pgxdata) < 0.616) - pgxfile = os.path.join(data_root, 'baseline/conformance/c1p1_02_2.pgx') + pgxfile = opj_data_file('baseline/conformance/c1p1_02_2.pgx') pgxdata = read_pgx(pgxfile) self.assertTrue(peak_tolerance(jpdata[:, :, 2], pgxdata) < 6) self.assertTrue(mse(jpdata[:, :, 2], pgxdata) < 1.051) def test_ETS_C1P1_p1_03_j2k(self): - jfile = os.path.join(data_root, 'input/conformance/p1_03.j2k') + jfile = opj_data_file('input/conformance/p1_03.j2k') jp2k = Jp2k(jfile) jpdata = jp2k.read_bands() - pgxfile = os.path.join(data_root, 'baseline/conformance/c1p1_03_0.pgx') + pgxfile = opj_data_file('baseline/conformance/c1p1_03_0.pgx') pgxdata = read_pgx(pgxfile) self.assertTrue(peak_tolerance(jpdata[0], pgxdata) < 2) self.assertTrue(mse(jpdata[0], pgxdata) < 0.3) - pgxfile = os.path.join(data_root, 'baseline/conformance/c1p1_03_1.pgx') + pgxfile = opj_data_file('baseline/conformance/c1p1_03_1.pgx') pgxdata = read_pgx(pgxfile) self.assertTrue(peak_tolerance(jpdata[1], pgxdata) < 2) self.assertTrue(mse(jpdata[1], pgxdata) < 0.21) - pgxfile = os.path.join(data_root, 'baseline/conformance/c1p1_03_2.pgx') + pgxfile = opj_data_file('baseline/conformance/c1p1_03_2.pgx') pgxdata = read_pgx(pgxfile) self.assertTrue(peak_tolerance(jpdata[2], pgxdata) <= 1) self.assertTrue(mse(jpdata[2], pgxdata) < 0.2) - pgxfile = os.path.join(data_root, 'baseline/conformance/c1p1_03_3.pgx') + pgxfile = opj_data_file('baseline/conformance/c1p1_03_3.pgx') pgxdata = read_pgx(pgxfile) np.testing.assert_array_equal(jpdata[3], pgxdata) def test_ETS_C1P1_p1_04_j2k(self): - jfile = os.path.join(data_root, 'input/conformance/p1_04.j2k') + jfile = opj_data_file('input/conformance/p1_04.j2k') jp2k = Jp2k(jfile) jpdata = jp2k.read() - pgxfile = os.path.join(data_root, 'baseline/conformance/c1p1_04_0.pgx') + pgxfile = opj_data_file('baseline/conformance/c1p1_04_0.pgx') pgxdata = read_pgx(pgxfile) self.assertTrue(peak_tolerance(jpdata, pgxdata) < 624) self.assertTrue(mse(jpdata, pgxdata) < 3080) @unittest.skip("fprintf stderr output in r2343.") def test_ETS_C1P1_p1_05_j2k(self): - jfile = os.path.join(data_root, 'input/conformance/p1_05.j2k') + jfile = opj_data_file('input/conformance/p1_05.j2k') jp2k = Jp2k(jfile) jpdata = jp2k.read() - pgxfile = os.path.join(data_root, 'baseline/conformance/c1p1_05_0.pgx') + pgxfile = opj_data_file('baseline/conformance/c1p1_05_0.pgx') pgxdata = read_pgx(pgxfile) self.assertTrue(peak_tolerance(jpdata[:, :, 0], pgxdata) < 40) self.assertTrue(mse(jpdata[:, :, 0], pgxdata) < 8.458) - pgxfile = os.path.join(data_root, 'baseline/conformance/c1p1_05_1.pgx') + pgxfile = opj_data_file('baseline/conformance/c1p1_05_1.pgx') pgxdata = read_pgx(pgxfile) self.assertTrue(peak_tolerance(jpdata[:, :, 1], pgxdata) < 40) self.assertTrue(mse(jpdata[:, :, 1], pgxdata) < 9.816) - pgxfile = os.path.join(data_root, 'baseline/conformance/c1p1_05_2.pgx') + pgxfile = opj_data_file('baseline/conformance/c1p1_05_2.pgx') pgxdata = read_pgx(pgxfile) self.assertTrue(peak_tolerance(jpdata[:, :, 2], pgxdata) < 40) self.assertTrue(mse(jpdata[:, :, 2], pgxdata) < 10.154) @unittest.skip("fprintf stderr output in r2343.") def test_ETS_C1P1_p1_06_j2k(self): - jfile = os.path.join(data_root, 'input/conformance/p1_06.j2k') + jfile = opj_data_file('input/conformance/p1_06.j2k') jp2k = Jp2k(jfile) jpdata = jp2k.read() - pgxfile = os.path.join(data_root, 'baseline/conformance/c1p1_06_0.pgx') + pgxfile = opj_data_file('baseline/conformance/c1p1_06_0.pgx') pgxdata = read_pgx(pgxfile) self.assertTrue(peak_tolerance(jpdata[:, :, 0], pgxdata) < 2) self.assertTrue(mse(jpdata[:, :, 0], pgxdata) < 0.6) - pgxfile = os.path.join(data_root, 'baseline/conformance/c1p1_06_1.pgx') + pgxfile = opj_data_file('baseline/conformance/c1p1_06_1.pgx') pgxdata = read_pgx(pgxfile) self.assertTrue(peak_tolerance(jpdata[:, :, 1], pgxdata) < 2) self.assertTrue(mse(jpdata[:, :, 1], pgxdata) < 0.6) - pgxfile = os.path.join(data_root, 'baseline/conformance/c1p1_06_2.pgx') + pgxfile = opj_data_file('baseline/conformance/c1p1_06_2.pgx') pgxdata = read_pgx(pgxfile) self.assertTrue(peak_tolerance(jpdata[:, :, 2], pgxdata) < 2) self.assertTrue(mse(jpdata[:, :, 2], pgxdata) < 0.6) @unittest.skip("fprintf stderr output in r2343.") def test_ETS_C1P1_p1_07_j2k(self): - jfile = os.path.join(data_root, 'input/conformance/p1_07.j2k') + jfile = opj_data_file('input/conformance/p1_07.j2k') jp2k = Jp2k(jfile) jpdata = jp2k.read_bands() - pgxfile = os.path.join(data_root, 'baseline/conformance/c1p1_07_0.pgx') + pgxfile = opj_data_file('baseline/conformance/c1p1_07_0.pgx') pgxdata = read_pgx(pgxfile) self.assertTrue(peak_tolerance(jpdata[0], pgxdata) <= 0) self.assertTrue(mse(jpdata[0], pgxdata) <= 0) - pgxfile = os.path.join(data_root, 'baseline/conformance/c1p1_07_1.pgx') + pgxfile = opj_data_file('baseline/conformance/c1p1_07_1.pgx') pgxdata = read_pgx(pgxfile) self.assertTrue(peak_tolerance(jpdata[1], pgxdata) <= 0) self.assertTrue(mse(jpdata[1], pgxdata) <= 0) def test_ETS_JP2_file1(self): - jfile = os.path.join(data_root, 'input/conformance/file1.jp2') + jfile = opj_data_file('input/conformance/file1.jp2') jp2k = Jp2k(jfile) jpdata = jp2k.read() self.assertEqual(jpdata.shape, (512, 768, 3)) def test_ETS_JP2_file2(self): - jfile = os.path.join(data_root, 'input/conformance/file2.jp2') + jfile = opj_data_file('input/conformance/file2.jp2') jp2k = Jp2k(jfile) jpdata = jp2k.read() self.assertEqual(jpdata.shape, (640, 480, 3)) def test_ETS_JP2_file3(self): - jfile = os.path.join(data_root, 'input/conformance/file3.jp2') + jfile = opj_data_file('input/conformance/file3.jp2') jp2k = Jp2k(jfile) jpdata = jp2k.read_bands() self.assertEqual(jpdata[0].shape, (640, 480)) @@ -767,59 +734,56 @@ class TestSuite(unittest.TestCase): self.assertEqual(jpdata[2].shape, (320, 240)) def test_ETS_JP2_file4(self): - jfile = os.path.join(data_root, 'input/conformance/file4.jp2') + jfile = opj_data_file('input/conformance/file4.jp2') jp2k = Jp2k(jfile) jpdata = jp2k.read() self.assertEqual(jpdata.shape, (512, 768)) def test_ETS_JP2_file5(self): - jfile = os.path.join(data_root, 'input/conformance/file5.jp2') + jfile = opj_data_file('input/conformance/file5.jp2') jp2k = Jp2k(jfile) jpdata = jp2k.read() self.assertEqual(jpdata.shape, (512, 768, 3)) def test_ETS_JP2_file6(self): - jfile = os.path.join(data_root, 'input/conformance/file6.jp2') + jfile = opj_data_file('input/conformance/file6.jp2') jp2k = Jp2k(jfile) jpdata = jp2k.read() self.assertEqual(jpdata.shape, (512, 768)) def test_ETS_JP2_file7(self): - jfile = os.path.join(data_root, 'input/conformance/file7.jp2') + jfile = opj_data_file('input/conformance/file7.jp2') jp2k = Jp2k(jfile) jpdata = jp2k.read() self.assertEqual(jpdata.shape, (640, 480, 3)) def test_ETS_JP2_file8(self): - jfile = os.path.join(data_root, 'input/conformance/file8.jp2') + jfile = opj_data_file('input/conformance/file8.jp2') jp2k = Jp2k(jfile) jpdata = jp2k.read() self.assertEqual(jpdata.shape, (400, 700)) def test_ETS_JP2_file9(self): - jfile = os.path.join(data_root, 'input/conformance/file9.jp2') + jfile = opj_data_file('input/conformance/file9.jp2') jp2k = Jp2k(jfile) jpdata = jp2k.read() self.assertEqual(jpdata.shape, (512, 768, 3)) def test_NR_DEC_Bretagne2_j2k_1_decode(self): - jfile = os.path.join(data_root, - 'input/nonregression/Bretagne2.j2k') + jfile = opj_data_file('input/nonregression/Bretagne2.j2k') jp2 = Jp2k(jfile) jp2.read() self.assertTrue(True) def test_NR_DEC__00042_j2k_2_decode(self): - jfile = os.path.join(data_root, - 'input/nonregression/_00042.j2k') + jfile = opj_data_file('input/nonregression/_00042.j2k') jp2 = Jp2k(jfile) jp2.read() self.assertTrue(True) @unittest.skip("fprintf stderr output in r2343.") def test_NR_DEC_123_j2c_3_decode(self): - jfile = os.path.join(data_root, - 'input/nonregression/123.j2c') + jfile = opj_data_file('input/nonregression/123.j2c') jp2 = Jp2k(jfile) jp2.read() self.assertTrue(True) @@ -827,8 +791,7 @@ class TestSuite(unittest.TestCase): @unittest.skipIf(sys.hexversion < 0x03020000, "Uses features introduced in 3.2.") def test_NR_DEC_broken_jp2_4_decode(self): - jfile = os.path.join(data_root, - 'input/nonregression/broken.jp2') + jfile = opj_data_file('input/nonregression/broken.jp2') with self.assertWarns(UserWarning): # colr box has bad length. jp2 = Jp2k(jfile) @@ -838,7 +801,7 @@ class TestSuite(unittest.TestCase): def test_NR_DEC_broken2_jp2_5_decode(self): # Null pointer access - jfile = os.path.join(data_root, 'input/nonregression/broken2.jp2') + jfile = opj_data_file('input/nonregression/broken2.jp2') with self.assertRaises(IOError): with warnings.catch_warnings(): # Invalid marker ID. @@ -849,7 +812,7 @@ class TestSuite(unittest.TestCase): @unittest.skipIf(sys.hexversion < 0x03020000, "Uses features introduced in 3.2.") def test_NR_DEC_broken3_jp2_6_decode(self): - jfile = os.path.join(data_root, 'input/nonregression/broken3.jp2') + jfile = opj_data_file('input/nonregression/broken3.jp2') with self.assertWarns(UserWarning): # colr box has bad length. j = Jp2k(jfile) @@ -858,7 +821,7 @@ class TestSuite(unittest.TestCase): j.read() def test_NR_DEC_broken4_jp2_7_decode(self): - jfile = os.path.join(data_root, 'input/nonregression/broken4.jp2') + jfile = opj_data_file('input/nonregression/broken4.jp2') with self.assertRaises(IOError): with warnings.catch_warnings(): # invalid number of subbands, bad marker ID @@ -868,105 +831,97 @@ class TestSuite(unittest.TestCase): @unittest.skip("fprintf stderr output in r2343.") def test_NR_DEC_bug_j2c_8_decode(self): - jfile = os.path.join(data_root, 'input/nonregression/bug.j2c') + jfile = opj_data_file('input/nonregression/bug.j2c') Jp2k(jfile).read() self.assertTrue(True) def test_NR_DEC_buxI_j2k_9_decode(self): - jfile = os.path.join(data_root, 'input/nonregression/buxI.j2k') + jfile = opj_data_file('input/nonregression/buxI.j2k') Jp2k(jfile).read() self.assertTrue(True) def test_NR_DEC_buxR_j2k_10_decode(self): - jfile = os.path.join(data_root, 'input/nonregression/buxR.j2k') + jfile = opj_data_file('input/nonregression/buxR.j2k') Jp2k(jfile).read() self.assertTrue(True) def test_NR_DEC_Cannotreaddatawithnosizeknown_j2k_11_decode(self): relpath = 'input/nonregression/Cannotreaddatawithnosizeknown.j2k' - jfile = os.path.join(data_root, relpath) + jfile = opj_data_file(relpath) Jp2k(jfile).read() self.assertTrue(True) def test_NR_DEC_cthead1_j2k_12_decode(self): - jfile = os.path.join(data_root, 'input/nonregression/cthead1.j2k') + jfile = opj_data_file('input/nonregression/cthead1.j2k') Jp2k(jfile).read() self.assertTrue(True) def test_NR_DEC_CT_Phillips_JPEG2K_Decompr_Problem_j2k_13_decode(self): relpath = 'input/nonregression/CT_Phillips_JPEG2K_Decompr_Problem.j2k' - jfile = os.path.join(data_root, relpath) + jfile = opj_data_file(relpath) Jp2k(jfile).read() self.assertTrue(True) @unittest.skip("fprintf stderr output in r2343.") def test_NR_DEC_illegalcolortransform_j2k_14_decode(self): # Stream too short, expected SOT. - jfile = os.path.join(data_root, - 'input/nonregression/illegalcolortransform.j2k') + jfile = opj_data_file('input/nonregression/illegalcolortransform.j2k') Jp2k(jfile).read() self.assertTrue(True) def test_NR_DEC_j2k32_j2k_15_decode(self): - jfile = os.path.join(data_root, 'input/nonregression/j2k32.j2k') + jfile = opj_data_file('input/nonregression/j2k32.j2k') Jp2k(jfile).read() self.assertTrue(True) def test_NR_DEC_kakadu_v4_4_openjpegv2_broken_j2k_16_decode(self): relpath = 'input/nonregression/kakadu_v4-4_openjpegv2_broken.j2k' - jfile = os.path.join(data_root, relpath) + jfile = opj_data_file(relpath) Jp2k(jfile).read() self.assertTrue(True) def test_NR_DEC_MarkerIsNotCompliant_j2k_17_decode(self): - jfile = os.path.join(data_root, - 'input/nonregression/MarkerIsNotCompliant.j2k') + jfile = opj_data_file('input/nonregression/MarkerIsNotCompliant.j2k') Jp2k(jfile).read() self.assertTrue(True) def test_NR_DEC_Marrin_jp2_18_decode(self): - jfile = os.path.join(data_root, - 'input/nonregression/Marrin.jp2') + jfile = opj_data_file('input/nonregression/Marrin.jp2') Jp2k(jfile).read() self.assertTrue(True) def test_NR_DEC_merged_jp2_19_decode(self): - jfile = os.path.join(data_root, - 'input/nonregression/merged.jp2') + jfile = opj_data_file('input/nonregression/merged.jp2') Jp2k(jfile).read_bands() self.assertTrue(True) def test_NR_DEC_movie_00000_j2k_20_decode(self): - jfile = os.path.join(data_root, - 'input/nonregression/movie_00000.j2k') + jfile = opj_data_file('input/nonregression/movie_00000.j2k') Jp2k(jfile).read() self.assertTrue(True) def test_NR_DEC_movie_00001_j2k_21_decode(self): - jfile = os.path.join(data_root, 'input/nonregression/movie_00001.j2k') + jfile = opj_data_file('input/nonregression/movie_00001.j2k') Jp2k(jfile).read() self.assertTrue(True) def test_NR_DEC_movie_00002_j2k_22_decode(self): - jfile = os.path.join(data_root, 'input/nonregression/movie_00002.j2k') + jfile = opj_data_file('input/nonregression/movie_00002.j2k') Jp2k(jfile).read() self.assertTrue(True) def test_NR_DEC_orb_blue_lin_j2k_j2k_23_decode(self): - jfile = os.path.join(data_root, - 'input/nonregression/orb-blue10-lin-j2k.j2k') + jfile = opj_data_file('input/nonregression/orb-blue10-lin-j2k.j2k') Jp2k(jfile).read() self.assertTrue(True) def test_NR_DEC_orb_blue_win_j2k_j2k_24_decode(self): - jfile = os.path.join(data_root, - 'input/nonregression/orb-blue10-win-j2k.j2k') + jfile = opj_data_file('input/nonregression/orb-blue10-win-j2k.j2k') Jp2k(jfile).read() self.assertTrue(True) def test_NR_DEC_orb_blue_lin_jp2_25_decode(self): - jfile = os.path.join(data_root, - 'input/nonregression/orb-blue10-lin-jp2.jp2') + jfile = opj_data_file('input/nonregression/orb-blue10-lin-jp2.jp2') with warnings.catch_warnings(): # This file has an invalid ICC profile warnings.simplefilter("ignore") @@ -974,28 +929,24 @@ class TestSuite(unittest.TestCase): self.assertTrue(True) def test_NR_DEC_orb_blue_win_jp2_26_decode(self): - jfile = os.path.join(data_root, - 'input/nonregression/orb-blue10-win-jp2.jp2') + jfile = opj_data_file('input/nonregression/orb-blue10-win-jp2.jp2') Jp2k(jfile).read() self.assertTrue(True) def test_NR_DEC_relax_jp2_27_decode(self): - jfile = os.path.join(data_root, - 'input/nonregression/relax.jp2') + jfile = opj_data_file('input/nonregression/relax.jp2') Jp2k(jfile).read() self.assertTrue(True) def test_NR_DEC_test_lossless_j2k_28_decode(self): - jfile = os.path.join(data_root, - 'input/nonregression/test_lossless.j2k') + jfile = opj_data_file('input/nonregression/test_lossless.j2k') Jp2k(jfile).read() self.assertTrue(True) @unittest.skipIf(OPENJP2_IS_V2_OFFICIAL, "Test known to fail in v2.0.0 official") def test_NR_DEC_text_GBR_jp2_29_decode(self): - jfile = os.path.join(data_root, - 'input/nonregression/text_GBR.jp2') + jfile = opj_data_file('input/nonregression/text_GBR.jp2') with warnings.catch_warnings(): # brand is 'jp2 ', but has any icc profile. warnings.simplefilter("ignore") @@ -1004,38 +955,33 @@ class TestSuite(unittest.TestCase): self.assertTrue(True) def test_NR_DEC_pacs_ge_j2k_30_decode(self): - jfile = os.path.join(data_root, - 'input/nonregression/pacs.ge.j2k') + jfile = opj_data_file('input/nonregression/pacs.ge.j2k') Jp2k(jfile).read() self.assertTrue(True) @unittest.skipIf(OPENJP2_IS_V2_OFFICIAL, "Test known to fail in v2.0.0 official") def test_NR_DEC_kodak_2layers_lrcp_j2c_31_decode(self): - jfile = os.path.join(data_root, - 'input/nonregression/kodak_2layers_lrcp.j2c') + jfile = opj_data_file('input/nonregression/kodak_2layers_lrcp.j2c') Jp2k(jfile).read() self.assertTrue(True) @unittest.skipIf(OPENJP2_IS_V2_OFFICIAL, "Test known to fail in v2.0.0 official") def test_NR_DEC_kodak_2layers_lrcp_j2c_32_decode(self): - jfile = os.path.join(data_root, - 'input/nonregression/kodak_2layers_lrcp.j2c') + jfile = opj_data_file('input/nonregression/kodak_2layers_lrcp.j2c') Jp2k(jfile).read(layer=2) self.assertTrue(True) def test_NR_DEC_issue104_jpxstream_jp2_33_decode(self): - jfile = os.path.join(data_root, - 'input/nonregression/issue104_jpxstream.jp2') + jfile = opj_data_file('input/nonregression/issue104_jpxstream.jp2') Jp2k(jfile).read() self.assertTrue(True) @unittest.skipIf(OPENJP2_IS_V2_OFFICIAL, "Test known to fail in v2.0.0 official") def test_NR_DEC_mem_b2ace68c_1381_jp2_34_decode(self): - jfile = os.path.join(data_root, - 'input/nonregression/mem-b2ace68c-1381.jp2') + jfile = opj_data_file('input/nonregression/mem-b2ace68c-1381.jp2') with warnings.catch_warnings(): # This file has a bad pclr box, we test for this elsewhere. warnings.simplefilter("ignore") @@ -1046,14 +992,13 @@ class TestSuite(unittest.TestCase): @unittest.skipIf(OPENJP2_IS_V2_OFFICIAL, "Test known to fail in v2.0.0 official") def test_NR_DEC_mem_b2b86b74_2753_jp2_35_decode(self): - jfile = os.path.join(data_root, - 'input/nonregression/mem-b2b86b74-2753.jp2') + jfile = opj_data_file('input/nonregression/mem-b2b86b74-2753.jp2') Jp2k(jfile).read() self.assertTrue(True) def test_NR_DEC_gdal_fuzzer_unchecked_num_resolutions_jp2_36_decode(self): f = 'input/nonregression/gdal_fuzzer_unchecked_numresolutions.jp2' - jfile = os.path.join(data_root, f) + jfile = opj_data_file(f) with warnings.catch_warnings(): # Invalid number of resolutions. warnings.simplefilter("ignore") @@ -1067,7 +1012,7 @@ class TestSuite(unittest.TestCase): lst = ('input', 'nonregression', 'gdal_fuzzer_assert_in_opj_j2k_read_SQcd_SQcc.patch.jp2') - jfile = os.path.join(data_root, '/'.join(lst)) + jfile = opj_data_file('/'.join(lst)) with warnings.catch_warnings(): # Invalid component number. warnings.simplefilter("ignore") @@ -1079,7 +1024,7 @@ class TestSuite(unittest.TestCase): "Test not in done in v2.0.0 official") 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 = os.path.join(data_root, relpath) + jfile = opj_data_file(relpath) with warnings.catch_warnings(): # Invalid number of tiles. warnings.simplefilter("ignore") @@ -1091,7 +1036,7 @@ class TestSuite(unittest.TestCase): "Test not in done in v2.0.0 official") 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 = os.path.join(data_root, relpath) + jfile = opj_data_file(relpath) with warnings.catch_warnings(): # Invalid subsampling value warnings.simplefilter("ignore") @@ -1099,7 +1044,7 @@ class TestSuite(unittest.TestCase): Jp2k(jfile).read() def test_NR_DEC_file_409752_jp2_40_decode(self): - jfile = os.path.join(data_root, 'input/nonregression/file409752.jp2') + jfile = opj_data_file('input/nonregression/file409752.jp2') with self.assertRaises(RuntimeError): Jp2k(jfile).read() @@ -1111,69 +1056,68 @@ class TestSuite(unittest.TestCase): # Has an 'XML ' box instead of 'xml '. Yes that is pedantic, but it # really does deserve a warning. relpath = 'input/nonregression/issue188_beach_64bitsbox.jp2' - jfile = os.path.join(data_root, relpath) + jfile = opj_data_file(relpath) with self.assertWarns(UserWarning): Jp2k(jfile).read() @unittest.skipIf(OPENJP2_IS_V2_OFFICIAL, "Test not in done in v2.0.0 official") def test_NR_DEC_issue206_image_000_jp2_42_decode(self): - jfile = os.path.join(data_root, - 'input/nonregression/issue206_image-000.jp2') + jfile = opj_data_file('input/nonregression/issue206_image-000.jp2') Jp2k(jfile).read() self.assertTrue(True) def test_NR_DEC_p1_04_j2k_43_decode(self): - jfile = os.path.join(data_root, 'input/conformance/p1_04.j2k') + jfile = opj_data_file('input/conformance/p1_04.j2k') jp2k = Jp2k(jfile) ssdata = jp2k.read(area=(0, 0, 1024, 1024)) odata = jp2k.read() np.testing.assert_array_equal(ssdata, odata) def test_NR_DEC_p1_04_j2k_44_decode(self): - jfile = os.path.join(data_root, 'input/conformance/p1_04.j2k') + jfile = opj_data_file('input/conformance/p1_04.j2k') jp2k = Jp2k(jfile) ssdata = jp2k.read(area=(640, 512, 768, 640)) odata = jp2k.read() np.testing.assert_array_equal(ssdata, odata[640:768, 512:640]) def test_NR_DEC_p1_04_j2k_45_decode(self): - jfile = os.path.join(data_root, 'input/conformance/p1_04.j2k') + jfile = opj_data_file('input/conformance/p1_04.j2k') jp2k = Jp2k(jfile) ssdata = jp2k.read(area=(896, 896, 1024, 1024)) odata = jp2k.read() np.testing.assert_array_equal(ssdata, odata[896:1024, 896:1024]) def test_NR_DEC_p1_04_j2k_46_decode(self): - jfile = os.path.join(data_root, 'input/conformance/p1_04.j2k') + jfile = opj_data_file('input/conformance/p1_04.j2k') jp2k = Jp2k(jfile) ssdata = jp2k.read(area=(500, 100, 800, 300)) odata = jp2k.read() np.testing.assert_array_equal(ssdata, odata[500:800, 100:300]) def test_NR_DEC_p1_04_j2k_47_decode(self): - jfile = os.path.join(data_root, 'input/conformance/p1_04.j2k') + jfile = opj_data_file('input/conformance/p1_04.j2k') jp2k = Jp2k(jfile) ssdata = jp2k.read(area=(520, 260, 600, 360)) odata = jp2k.read() np.testing.assert_array_equal(ssdata, odata[520:600, 260:360]) def test_NR_DEC_p1_04_j2k_48_decode(self): - jfile = os.path.join(data_root, 'input/conformance/p1_04.j2k') + jfile = opj_data_file('input/conformance/p1_04.j2k') jp2k = Jp2k(jfile) ssdata = jp2k.read(area=(520, 260, 660, 360)) odata = jp2k.read() np.testing.assert_array_equal(ssdata, odata[520:660, 260:360]) def test_NR_DEC_p1_04_j2k_49_decode(self): - jfile = os.path.join(data_root, 'input/conformance/p1_04.j2k') + jfile = opj_data_file('input/conformance/p1_04.j2k') jp2k = Jp2k(jfile) ssdata = jp2k.read(area=(520, 360, 600, 400)) odata = jp2k.read() np.testing.assert_array_equal(ssdata, odata[520:600, 360:400]) def test_NR_DEC_p1_04_j2k_50_decode(self): - jfile = os.path.join(data_root, 'input/conformance/p1_04.j2k') + jfile = opj_data_file('input/conformance/p1_04.j2k') jp2k = Jp2k(jfile) ssdata = jp2k.read(area=(0, 0, 1024, 1024), rlevel=2) odata = jp2k.read(rlevel=2) @@ -1181,70 +1125,70 @@ class TestSuite(unittest.TestCase): np.testing.assert_array_equal(ssdata, odata[0:256, 0:256]) def test_NR_DEC_p1_04_j2k_51_decode(self): - jfile = os.path.join(data_root, 'input/conformance/p1_04.j2k') + jfile = opj_data_file('input/conformance/p1_04.j2k') jp2k = Jp2k(jfile) ssdata = jp2k.read(area=(640, 512, 768, 640), rlevel=2) odata = jp2k.read(rlevel=2) np.testing.assert_array_equal(ssdata, odata[160:192, 128:160]) def test_NR_DEC_p1_04_j2k_52_decode(self): - jfile = os.path.join(data_root, 'input/conformance/p1_04.j2k') + jfile = opj_data_file('input/conformance/p1_04.j2k') jp2k = Jp2k(jfile) ssdata = jp2k.read(area=(896, 896, 1024, 1024), rlevel=2) odata = jp2k.read(rlevel=2) np.testing.assert_array_equal(ssdata, odata[224:352, 224:352]) def test_NR_DEC_p1_04_j2k_53_decode(self): - jfile = os.path.join(data_root, 'input/conformance/p1_04.j2k') + jfile = opj_data_file('input/conformance/p1_04.j2k') jp2k = Jp2k(jfile) ssdata = jp2k.read(area=(500, 100, 800, 300), rlevel=2) odata = jp2k.read(rlevel=2) np.testing.assert_array_equal(ssdata, odata[125:200, 25:75]) def test_NR_DEC_p1_04_j2k_54_decode(self): - jfile = os.path.join(data_root, 'input/conformance/p1_04.j2k') + jfile = opj_data_file('input/conformance/p1_04.j2k') jp2k = Jp2k(jfile) ssdata = jp2k.read(area=(520, 260, 600, 360), rlevel=2) odata = jp2k.read(rlevel=2) np.testing.assert_array_equal(ssdata, odata[130:150, 65:90]) def test_NR_DEC_p1_04_j2k_55_decode(self): - jfile = os.path.join(data_root, 'input/conformance/p1_04.j2k') + jfile = opj_data_file('input/conformance/p1_04.j2k') jp2k = Jp2k(jfile) ssdata = jp2k.read(area=(520, 260, 660, 360), rlevel=2) odata = jp2k.read(rlevel=2) np.testing.assert_array_equal(ssdata, odata[130:165, 65:90]) def test_NR_DEC_p1_04_j2k_56_decode(self): - jfile = os.path.join(data_root, 'input/conformance/p1_04.j2k') + jfile = opj_data_file('input/conformance/p1_04.j2k') jp2k = Jp2k(jfile) ssdata = jp2k.read(area=(520, 360, 600, 400), rlevel=2) odata = jp2k.read(rlevel=2) np.testing.assert_array_equal(ssdata, odata[130:150, 90:100]) def test_NR_DEC_p1_04_j2k_57_decode(self): - jfile = os.path.join(data_root, 'input/conformance/p1_04.j2k') + jfile = opj_data_file('input/conformance/p1_04.j2k') jp2k = Jp2k(jfile) tdata = jp2k.read(tile=63) # last tile odata = jp2k.read() np.testing.assert_array_equal(tdata, odata[896:1024, 896:1024]) def test_NR_DEC_p1_04_j2k_58_decode(self): - jfile = os.path.join(data_root, 'input/conformance/p1_04.j2k') + jfile = opj_data_file('input/conformance/p1_04.j2k') jp2k = Jp2k(jfile) tdata = jp2k.read(tile=63, rlevel=2) # last tile odata = jp2k.read(rlevel=2) np.testing.assert_array_equal(tdata, odata[224:256, 224:256]) def test_NR_DEC_p1_04_j2k_59_decode(self): - jfile = os.path.join(data_root, 'input/conformance/p1_04.j2k') + jfile = opj_data_file('input/conformance/p1_04.j2k') jp2k = Jp2k(jfile) tdata = jp2k.read(tile=12) # 2nd row, 5th column odata = jp2k.read() np.testing.assert_array_equal(tdata, odata[128:256, 512:640]) def test_NR_DEC_p1_04_j2k_60_decode(self): - jfile = os.path.join(data_root, 'input/conformance/p1_04.j2k') + jfile = opj_data_file('input/conformance/p1_04.j2k') jp2k = Jp2k(jfile) tdata = jp2k.read(tile=12, rlevel=1) # 2nd row, 5th column odata = jp2k.read(rlevel=1) @@ -1252,7 +1196,7 @@ class TestSuite(unittest.TestCase): @unittest.skip("fprintf stderr output in r2343.") def test_NR_DEC_p1_06_j2k_61_decode(self): - jfile = os.path.join(data_root, 'input/conformance/p1_06.j2k') + jfile = opj_data_file('input/conformance/p1_06.j2k') jp2k = Jp2k(jfile) ssdata = jp2k.read(area=(0, 0, 12, 12)) odata = jp2k.read() @@ -1260,7 +1204,7 @@ class TestSuite(unittest.TestCase): @unittest.skip("fprintf stderr output in r2343.") def test_NR_DEC_p1_06_j2k_62_decode(self): - jfile = os.path.join(data_root, 'input/conformance/p1_06.j2k') + jfile = opj_data_file('input/conformance/p1_06.j2k') jp2k = Jp2k(jfile) ssdata = jp2k.read(area=(1, 8, 8, 11)) odata = jp2k.read() @@ -1268,7 +1212,7 @@ class TestSuite(unittest.TestCase): @unittest.skip("fprintf stderr output in r2343.") def test_NR_DEC_p1_06_j2k_63_decode(self): - jfile = os.path.join(data_root, 'input/conformance/p1_06.j2k') + jfile = opj_data_file('input/conformance/p1_06.j2k') jp2k = Jp2k(jfile) ssdata = jp2k.read(area=(9, 9, 12, 12)) odata = jp2k.read() @@ -1276,7 +1220,7 @@ class TestSuite(unittest.TestCase): @unittest.skip("fprintf stderr output in r2343.") def test_NR_DEC_p1_06_j2k_64_decode(self): - jfile = os.path.join(data_root, 'input/conformance/p1_06.j2k') + jfile = opj_data_file('input/conformance/p1_06.j2k') jp2k = Jp2k(jfile) ssdata = jp2k.read(area=(10, 4, 12, 10)) odata = jp2k.read() @@ -1284,7 +1228,7 @@ class TestSuite(unittest.TestCase): @unittest.skip("fprintf stderr output in r2343.") def test_NR_DEC_p1_06_j2k_65_decode(self): - jfile = os.path.join(data_root, 'input/conformance/p1_06.j2k') + jfile = opj_data_file('input/conformance/p1_06.j2k') jp2k = Jp2k(jfile) ssdata = jp2k.read(area=(3, 3, 9, 9)) odata = jp2k.read() @@ -1292,7 +1236,7 @@ class TestSuite(unittest.TestCase): @unittest.skip("fprintf stderr output in r2343.") def test_NR_DEC_p1_06_j2k_66_decode(self): - jfile = os.path.join(data_root, 'input/conformance/p1_06.j2k') + jfile = opj_data_file('input/conformance/p1_06.j2k') jp2k = Jp2k(jfile) ssdata = jp2k.read(area=(4, 4, 7, 7)) odata = jp2k.read() @@ -1300,7 +1244,7 @@ class TestSuite(unittest.TestCase): @unittest.skip("fprintf stderr output in r2343.") def test_NR_DEC_p1_06_j2k_67_decode(self): - jfile = os.path.join(data_root, 'input/conformance/p1_06.j2k') + jfile = opj_data_file('input/conformance/p1_06.j2k') jp2k = Jp2k(jfile) ssdata = jp2k.read(area=(4, 4, 5, 5)) odata = jp2k.read() @@ -1308,7 +1252,7 @@ class TestSuite(unittest.TestCase): @unittest.skip("fprintf stderr output in r2343.") def test_NR_DEC_p1_06_j2k_68_decode(self): - jfile = os.path.join(data_root, 'input/conformance/p1_06.j2k') + jfile = opj_data_file('input/conformance/p1_06.j2k') jp2k = Jp2k(jfile) ssdata = jp2k.read(area=(0, 0, 12, 12), rlevel=1) odata = jp2k.read(rlevel=1) @@ -1316,51 +1260,51 @@ class TestSuite(unittest.TestCase): @unittest.skip("fprintf stderr output in r2343.") def test_NR_DEC_p1_06_j2k_69_decode(self): - jfile = os.path.join(data_root, 'input/conformance/p1_06.j2k') + jfile = opj_data_file('input/conformance/p1_06.j2k') jp2k = Jp2k(jfile) ssdata = jp2k.read(area=(1, 8, 8, 11), rlevel=1) self.assertEqual(ssdata.shape, (3, 2, 3)) def test_NR_DEC_p1_06_j2k_70_decode(self): - jfile = os.path.join(data_root, 'input/conformance/p1_06.j2k') + jfile = opj_data_file('input/conformance/p1_06.j2k') jp2k = Jp2k(jfile) ssdata = jp2k.read(area=(9, 9, 12, 12), rlevel=1) self.assertEqual(ssdata.shape, (1, 1, 3)) def test_NR_DEC_p1_06_j2k_71_decode(self): - jfile = os.path.join(data_root, 'input/conformance/p1_06.j2k') + jfile = opj_data_file('input/conformance/p1_06.j2k') jp2k = Jp2k(jfile) ssdata = jp2k.read(area=(10, 4, 12, 10), rlevel=1) self.assertEqual(ssdata.shape, (1, 3, 3)) def test_NR_DEC_p1_06_j2k_72_decode(self): - jfile = os.path.join(data_root, 'input/conformance/p1_06.j2k') + jfile = opj_data_file('input/conformance/p1_06.j2k') jp2k = Jp2k(jfile) ssdata = jp2k.read(area=(3, 3, 9, 9), rlevel=1) self.assertEqual(ssdata.shape, (3, 3, 3)) def test_NR_DEC_p1_06_j2k_73_decode(self): - jfile = os.path.join(data_root, 'input/conformance/p1_06.j2k') + jfile = opj_data_file('input/conformance/p1_06.j2k') jp2k = Jp2k(jfile) ssdata = jp2k.read(area=(4, 4, 7, 7), rlevel=1) self.assertEqual(ssdata.shape, (2, 2, 3)) def test_NR_DEC_p1_06_j2k_74_decode(self): - jfile = os.path.join(data_root, 'input/conformance/p1_06.j2k') + jfile = opj_data_file('input/conformance/p1_06.j2k') jp2k = Jp2k(jfile) ssdata = jp2k.read(area=(4, 4, 5, 5), rlevel=1) self.assertEqual(ssdata.shape, (1, 1, 3)) def test_NR_DEC_p1_06_j2k_75_decode(self): # Image size would be 0 x 0. - jfile = os.path.join(data_root, 'input/conformance/p1_06.j2k') + jfile = opj_data_file('input/conformance/p1_06.j2k') jp2k = Jp2k(jfile) with self.assertRaises((IOError, OSError)): jp2k.read(area=(9, 9, 12, 12), rlevel=2) @unittest.skip("fprintf stderr output in r2343.") def test_NR_DEC_p1_06_j2k_76_decode(self): - jfile = os.path.join(data_root, 'input/conformance/p1_06.j2k') + jfile = opj_data_file('input/conformance/p1_06.j2k') jp2k = Jp2k(jfile) fulldata = jp2k.read() tiledata = jp2k.read(tile=0) @@ -1368,7 +1312,7 @@ class TestSuite(unittest.TestCase): @unittest.skip("fprintf stderr output in r2343.") def test_NR_DEC_p1_06_j2k_77_decode(self): - jfile = os.path.join(data_root, 'input/conformance/p1_06.j2k') + jfile = opj_data_file('input/conformance/p1_06.j2k') jp2k = Jp2k(jfile) fulldata = jp2k.read() tiledata = jp2k.read(tile=5) @@ -1376,7 +1320,7 @@ class TestSuite(unittest.TestCase): @unittest.skip("fprintf stderr output in r2343.") def test_NR_DEC_p1_06_j2k_78_decode(self): - jfile = os.path.join(data_root, 'input/conformance/p1_06.j2k') + jfile = opj_data_file('input/conformance/p1_06.j2k') jp2k = Jp2k(jfile) fulldata = jp2k.read() with warnings.catch_warnings(): @@ -1386,7 +1330,7 @@ class TestSuite(unittest.TestCase): @unittest.skip("fprintf stderr output in r2343.") def test_NR_DEC_p1_06_j2k_79_decode(self): - jfile = os.path.join(data_root, 'input/conformance/p1_06.j2k') + jfile = opj_data_file('input/conformance/p1_06.j2k') jp2k = Jp2k(jfile) fulldata = jp2k.read() with warnings.catch_warnings(): @@ -1397,7 +1341,7 @@ class TestSuite(unittest.TestCase): @unittest.skip("fprintf stderr output in r2343.") def test_NR_DEC_p1_06_j2k_80_decode(self): # Just read the data, don't bother verifying. - jfile = os.path.join(data_root, 'input/conformance/p1_06.j2k') + jfile = opj_data_file('input/conformance/p1_06.j2k') jp2k = Jp2k(jfile) with warnings.catch_warnings(): warnings.simplefilter("ignore") @@ -1406,7 +1350,7 @@ class TestSuite(unittest.TestCase): @unittest.skip("fprintf stderr output in r2343.") def test_NR_DEC_p1_06_j2k_81_decode(self): # Just read the data, don't bother verifying. - jfile = os.path.join(data_root, 'input/conformance/p1_06.j2k') + jfile = opj_data_file('input/conformance/p1_06.j2k') jp2k = Jp2k(jfile) with warnings.catch_warnings(): warnings.simplefilter("ignore") @@ -1415,7 +1359,7 @@ class TestSuite(unittest.TestCase): @unittest.skip("fprintf stderr output in r2343.") def test_NR_DEC_p1_06_j2k_82_decode(self): # Just read the data, don't bother verifying. - jfile = os.path.join(data_root, 'input/conformance/p1_06.j2k') + jfile = opj_data_file('input/conformance/p1_06.j2k') jp2k = Jp2k(jfile) with warnings.catch_warnings(): warnings.simplefilter("ignore") @@ -1424,7 +1368,7 @@ class TestSuite(unittest.TestCase): @unittest.skip("fprintf stderr output in r2343.") def test_NR_DEC_p1_06_j2k_83_decode(self): # tile size is 3x3. Reducing two levels results in no data. - jfile = os.path.join(data_root, 'input/conformance/p1_06.j2k') + jfile = opj_data_file('input/conformance/p1_06.j2k') jp2k = Jp2k(jfile) with warnings.catch_warnings(): warnings.simplefilter("ignore") @@ -1434,96 +1378,96 @@ class TestSuite(unittest.TestCase): @unittest.skip("fprintf stderr output in r2343.") def test_NR_DEC_p1_06_j2k_84_decode(self): # Just read the data, don't bother verifying. - jfile = os.path.join(data_root, 'input/conformance/p1_06.j2k') + jfile = opj_data_file('input/conformance/p1_06.j2k') jp2k = Jp2k(jfile) jp2k.read(rlevel=4) def test_NR_DEC_p0_04_j2k_85_decode(self): - jfile = os.path.join(data_root, 'input/conformance/p0_04.j2k') + jfile = opj_data_file('input/conformance/p0_04.j2k') jp2k = Jp2k(jfile) ssdata = jp2k.read(area=(0, 0, 256, 256)) fulldata = jp2k.read() np.testing.assert_array_equal(fulldata[0:256, 0:256], ssdata) def test_NR_DEC_p0_04_j2k_86_decode(self): - jfile = os.path.join(data_root, 'input/conformance/p0_04.j2k') + jfile = opj_data_file('input/conformance/p0_04.j2k') jp2k = Jp2k(jfile) ssdata = jp2k.read(area=(0, 128, 128, 256)) fulldata = jp2k.read() np.testing.assert_array_equal(fulldata[0:128, 128:256], ssdata) def test_NR_DEC_p0_04_j2k_87_decode(self): - jfile = os.path.join(data_root, 'input/conformance/p0_04.j2k') + jfile = opj_data_file('input/conformance/p0_04.j2k') jp2k = Jp2k(jfile) ssdata = jp2k.read(area=(10, 50, 200, 120)) fulldata = jp2k.read() np.testing.assert_array_equal(fulldata[10:200, 50:120], ssdata) def test_NR_DEC_p0_04_j2k_88_decode(self): - jfile = os.path.join(data_root, 'input/conformance/p0_04.j2k') + jfile = opj_data_file('input/conformance/p0_04.j2k') jp2k = Jp2k(jfile) ssdata = jp2k.read(area=(150, 10, 210, 190)) fulldata = jp2k.read() np.testing.assert_array_equal(fulldata[150:210, 10:190], ssdata) def test_NR_DEC_p0_04_j2k_89_decode(self): - jfile = os.path.join(data_root, 'input/conformance/p0_04.j2k') + jfile = opj_data_file('input/conformance/p0_04.j2k') jp2k = Jp2k(jfile) ssdata = jp2k.read(area=(80, 100, 150, 200)) fulldata = jp2k.read() np.testing.assert_array_equal(fulldata[80:150, 100:200], ssdata) def test_NR_DEC_p0_04_j2k_90_decode(self): - jfile = os.path.join(data_root, 'input/conformance/p0_04.j2k') + jfile = opj_data_file('input/conformance/p0_04.j2k') jp2k = Jp2k(jfile) ssdata = jp2k.read(area=(20, 150, 50, 200)) fulldata = jp2k.read() np.testing.assert_array_equal(fulldata[20:50, 150:200], ssdata) def test_NR_DEC_p0_04_j2k_91_decode(self): - jfile = os.path.join(data_root, 'input/conformance/p0_04.j2k') + jfile = opj_data_file('input/conformance/p0_04.j2k') jp2k = Jp2k(jfile) ssdata = jp2k.read(area=(0, 0, 256, 256), rlevel=2) fulldata = jp2k.read(rlevel=2) np.testing.assert_array_equal(fulldata[0:64, 0:64], ssdata) def test_NR_DEC_p0_04_j2k_92_decode(self): - jfile = os.path.join(data_root, 'input/conformance/p0_04.j2k') + jfile = opj_data_file('input/conformance/p0_04.j2k') jp2k = Jp2k(jfile) ssdata = jp2k.read(area=(0, 128, 128, 256), rlevel=2) fulldata = jp2k.read(rlevel=2) np.testing.assert_array_equal(fulldata[0:32, 32:64], ssdata) def test_NR_DEC_p0_04_j2k_93_decode(self): - jfile = os.path.join(data_root, 'input/conformance/p0_04.j2k') + jfile = opj_data_file('input/conformance/p0_04.j2k') jp2k = Jp2k(jfile) ssdata = jp2k.read(area=(10, 50, 200, 120), rlevel=2) fulldata = jp2k.read(rlevel=2) np.testing.assert_array_equal(fulldata[3:50, 13:30], ssdata) def test_NR_DEC_p0_04_j2k_94_decode(self): - jfile = os.path.join(data_root, 'input/conformance/p0_04.j2k') + jfile = opj_data_file('input/conformance/p0_04.j2k') jp2k = Jp2k(jfile) ssdata = jp2k.read(area=(150, 10, 210, 190), rlevel=2) fulldata = jp2k.read(rlevel=2) np.testing.assert_array_equal(fulldata[38:53, 3:48], ssdata) def test_NR_DEC_p0_04_j2k_95_decode(self): - jfile = os.path.join(data_root, 'input/conformance/p0_04.j2k') + jfile = opj_data_file('input/conformance/p0_04.j2k') jp2k = Jp2k(jfile) ssdata = jp2k.read(area=(80, 100, 150, 200), rlevel=2) fulldata = jp2k.read(rlevel=2) np.testing.assert_array_equal(fulldata[20:38, 25:50], ssdata) def test_NR_DEC_p0_04_j2k_96_decode(self): - jfile = os.path.join(data_root, 'input/conformance/p0_04.j2k') + jfile = opj_data_file('input/conformance/p0_04.j2k') jp2k = Jp2k(jfile) ssdata = jp2k.read(area=(20, 150, 50, 200), rlevel=2) fulldata = jp2k.read(rlevel=2) np.testing.assert_array_equal(fulldata[5:13, 38:50], ssdata) -@unittest.skipIf(data_root is None, +@unittest.skipIf(OPJ_DATA_ROOT is None, "OPJ_DATA_ROOT environment variable not set") class TestSuiteDump(unittest.TestCase): @@ -1534,7 +1478,7 @@ class TestSuiteDump(unittest.TestCase): pass def test_NR_p0_01_dump(self): - jfile = os.path.join(data_root, 'input/conformance/p0_01.j2k') + jfile = opj_data_file('input/conformance/p0_01.j2k') c = Jp2k(jfile).get_codestream(header_only=False) # Segment IDs. @@ -1601,7 +1545,7 @@ class TestSuiteDump(unittest.TestCase): self.assertEqual(c.segment[4].tnsot, 1) def test_NR_p0_02_dump(self): - jfile = os.path.join(data_root, 'input/conformance/p0_02.j2k') + jfile = opj_data_file('input/conformance/p0_02.j2k') c = Jp2k(jfile).get_codestream(header_only=False) # SIZ: Image and tile size @@ -1707,7 +1651,7 @@ class TestSuiteDump(unittest.TestCase): self.assertEqual(c.segment[-1].marker_id, 'EOC') def test_NR_p0_03_dump(self): - jfile = os.path.join(data_root, 'input/conformance/p0_03.j2k') + jfile = opj_data_file('input/conformance/p0_03.j2k') c = Jp2k(jfile).get_codestream(header_only=False) # SIZ: Image and tile size @@ -1824,7 +1768,7 @@ class TestSuiteDump(unittest.TestCase): self.assertEqual(c.segment[13].marker_id, 'SOD') def test_NR_p0_04_dump(self): - jfile = os.path.join(data_root, 'input/conformance/p0_04.j2k') + jfile = opj_data_file('input/conformance/p0_04.j2k') c = Jp2k(jfile).get_codestream(header_only=False) # SIZ: Image and tile size @@ -1932,7 +1876,7 @@ class TestSuiteDump(unittest.TestCase): self.assertEqual(c.segment[8].marker_id, 'SOD') def test_NR_p0_05_dump(self): - jfile = os.path.join(data_root, 'input/conformance/p0_05.j2k') + jfile = opj_data_file('input/conformance/p0_05.j2k') c = Jp2k(jfile).get_codestream(header_only=False) # SIZ: Image and tile size @@ -2076,7 +2020,7 @@ class TestSuiteDump(unittest.TestCase): self.assertEqual(c.segment[11].marker_id, 'SOD') def test_NR_p0_06_dump(self): - jfile = os.path.join(data_root, 'input/conformance/p0_06.j2k') + jfile = opj_data_file('input/conformance/p0_06.j2k') c = Jp2k(jfile).get_codestream(header_only=False) # SIZ: Image and tile size @@ -2213,7 +2157,7 @@ class TestSuiteDump(unittest.TestCase): self.assertEqual(c.segment[11].marker_id, 'SOD') def test_NR_p0_07_dump(self): - jfile = os.path.join(data_root, 'input/conformance/p0_07.j2k') + jfile = opj_data_file('input/conformance/p0_07.j2k') c = Jp2k(jfile).get_codestream(header_only=False) # SIZ: Image and tile size @@ -2298,7 +2242,7 @@ class TestSuiteDump(unittest.TestCase): self.assertEqual(c.segment[8].marker_id, 'SOD') def test_NR_p0_08_dump(self): - jfile = os.path.join(data_root, 'input/conformance/p0_08.j2k') + jfile = opj_data_file('input/conformance/p0_08.j2k') c = Jp2k(jfile).get_codestream(header_only=False) # SIZ: Image and tile size @@ -2451,7 +2395,7 @@ class TestSuiteDump(unittest.TestCase): self.assertEqual(c.segment[10].tnsot, 1) # unknown def test_NR_p0_09_dump(self): - jfile = os.path.join(data_root, 'input/conformance/p0_09.j2k') + jfile = opj_data_file('input/conformance/p0_09.j2k') c = Jp2k(jfile).get_codestream(header_only=False) # SIZ: Image and tile size @@ -2531,7 +2475,7 @@ class TestSuiteDump(unittest.TestCase): self.assertEqual(c.segment[7].marker_id, 'EOC') def test_NR_p0_10_dump(self): - jfile = os.path.join(data_root, 'input/conformance/p0_10.j2k') + jfile = opj_data_file('input/conformance/p0_10.j2k') c = Jp2k(jfile).get_codestream(header_only=False) # SIZ: Image and tile size @@ -2672,7 +2616,7 @@ class TestSuiteDump(unittest.TestCase): self.assertEqual(c.segment[22].marker_id, 'EOC') def test_NR_p0_11_dump(self): - jfile = os.path.join(data_root, 'input/conformance/p0_11.j2k') + jfile = opj_data_file('input/conformance/p0_11.j2k') c = Jp2k(jfile).get_codestream(header_only=False) # SIZ: Image and tile size @@ -2753,7 +2697,7 @@ class TestSuiteDump(unittest.TestCase): self.assertEqual(c.segment[-1].marker_id, 'EOC') def test_NR_p0_12_dump(self): - jfile = os.path.join(data_root, 'input/conformance/p0_12.j2k') + jfile = opj_data_file('input/conformance/p0_12.j2k') c = Jp2k(jfile).get_codestream(header_only=False) # SIZ: Image and tile size @@ -2835,7 +2779,7 @@ class TestSuiteDump(unittest.TestCase): self.assertEqual(c.segment[-1].marker_id, 'EOC') def test_NR_p0_13_dump(self): - jfile = os.path.join(data_root, 'input/conformance/p0_13.j2k') + jfile = opj_data_file('input/conformance/p0_13.j2k') c = Jp2k(jfile).get_codestream(header_only=False) # SIZ: Image and tile size @@ -2961,7 +2905,7 @@ class TestSuiteDump(unittest.TestCase): self.assertEqual(c.segment[12].marker_id, 'EOC') def test_NR_p0_14_dump(self): - jfile = os.path.join(data_root, 'input/conformance/p0_14.j2k') + jfile = opj_data_file('input/conformance/p0_14.j2k') c = Jp2k(jfile).get_codestream(header_only=False) # SIZ: Image and tile size @@ -3037,7 +2981,7 @@ class TestSuiteDump(unittest.TestCase): self.assertEqual(c.segment[7].marker_id, 'EOC') def test_NR_p0_15_dump(self): - jfile = os.path.join(data_root, 'input/conformance/p0_15.j2k') + jfile = opj_data_file('input/conformance/p0_15.j2k') c = Jp2k(jfile).get_codestream(header_only=False) # SIZ: Image and tile size @@ -3191,7 +3135,7 @@ class TestSuiteDump(unittest.TestCase): self.assertEqual(c.segment[85].marker_id, 'EOC') def test_NR_p0_16_dump(self): - jfile = os.path.join(data_root, 'input/conformance/p0_16.j2k') + jfile = opj_data_file('input/conformance/p0_16.j2k') c = Jp2k(jfile).get_codestream(header_only=False) # SIZ: Image and tile size @@ -3259,7 +3203,7 @@ class TestSuiteDump(unittest.TestCase): self.assertEqual(c.segment[6].marker_id, 'EOC') def test_NR_p1_01_dump(self): - jfile = os.path.join(data_root, 'input/conformance/p1_01.j2k') + jfile = opj_data_file('input/conformance/p1_01.j2k') c = Jp2k(jfile).get_codestream(header_only=False) # SIZ: Image and tile size @@ -3359,7 +3303,7 @@ class TestSuiteDump(unittest.TestCase): self.assertEqual(c.segment[-1].marker_id, 'EOC') def test_NR_p1_02_dump(self): - jfile = os.path.join(data_root, 'input/conformance/p1_02.j2k') + jfile = opj_data_file('input/conformance/p1_02.j2k') c = Jp2k(jfile).get_codestream(header_only=False) # SIZ: Image and tile size @@ -3473,7 +3417,7 @@ class TestSuiteDump(unittest.TestCase): self.assertEqual(c.segment[10].marker_id, 'EOC') def test_NR_p1_03_dump(self): - jfile = os.path.join(data_root, 'input/conformance/p1_03.j2k') + jfile = opj_data_file('input/conformance/p1_03.j2k') c = Jp2k(jfile).get_codestream(header_only=False) # SIZ: Image and tile size @@ -3620,7 +3564,7 @@ class TestSuiteDump(unittest.TestCase): self.assertEqual(c.segment[13].marker_id, 'EOC') def test_NR_p1_04_dump(self): - jfile = os.path.join(data_root, 'input/conformance/p1_04.j2k') + jfile = opj_data_file('input/conformance/p1_04.j2k') c = Jp2k(jfile).get_codestream(header_only=False) # SIZ: Image and tile size @@ -3747,7 +3691,7 @@ class TestSuiteDump(unittest.TestCase): self.assertEqual(c.segment[-1].marker_id, 'EOC') def test_NR_p1_05_dump(self): - jfile = os.path.join(data_root, 'input/conformance/p1_05.j2k') + jfile = opj_data_file('input/conformance/p1_05.j2k') c = Jp2k(jfile).get_codestream(header_only=False) # SIZ: Image and tile size @@ -3835,7 +3779,7 @@ class TestSuiteDump(unittest.TestCase): self.assertEqual(c.segment[-1].marker_id, 'EOC') def test_NR_p1_06_dump(self): - jfile = os.path.join(data_root, 'input/conformance/p1_06.j2k') + jfile = opj_data_file('input/conformance/p1_06.j2k') c = Jp2k(jfile).get_codestream(header_only=False) # SIZ: Image and tile size @@ -3928,7 +3872,7 @@ class TestSuiteDump(unittest.TestCase): self.assertEqual(c.segment[-1].marker_id, 'EOC') def test_NR_p1_07_dump(self): - jfile = os.path.join(data_root, 'input/conformance/p1_07.j2k') + jfile = opj_data_file('input/conformance/p1_07.j2k') c = Jp2k(jfile).get_codestream(header_only=False) # SIZ: Image and tile size @@ -4021,7 +3965,7 @@ class TestSuiteDump(unittest.TestCase): self.assertEqual(c.segment[-1].marker_id, 'EOC') def test_NR_file1_dump(self): - jfile = os.path.join(data_root, 'input/conformance/file1.jp2') + jfile = opj_data_file('input/conformance/file1.jp2') jp2 = Jp2k(jfile) ids = [box.box_id for box in jp2.box] @@ -4071,7 +4015,7 @@ class TestSuiteDump(unittest.TestCase): '{http://www.jpeg.org/jpx/1.0/xml}EVENT']) def test_NR_file2_dump(self): - jfile = os.path.join(data_root, 'input/conformance/file2.jp2') + jfile = opj_data_file('input/conformance/file2.jp2') jp2 = Jp2k(jfile) ids = [box.box_id for box in jp2.box] @@ -4118,7 +4062,7 @@ class TestSuiteDump(unittest.TestCase): # Cr components being subsampled 2x in both the horizontal and # vertical directions. The components are stored in the standard # order. - jfile = os.path.join(data_root, 'input/conformance/file3.jp2') + jfile = opj_data_file('input/conformance/file3.jp2') jp2 = Jp2k(jfile) ids = [box.box_id for box in jp2.box] @@ -4165,7 +4109,7 @@ class TestSuiteDump(unittest.TestCase): def test_NR_file4_dump(self): # One 8-bit component in the sRGB-grey colourspace. - jfile = os.path.join(data_root, 'input/conformance/file4.jp2') + jfile = opj_data_file('input/conformance/file4.jp2') jp2 = Jp2k(jfile) ids = [box.box_id for box in jp2.box] @@ -4207,7 +4151,7 @@ class TestSuiteDump(unittest.TestCase): # the RCT. The colourspace is specified using both a Restricted ICC # profile and using the JPX-defined enumerated code for the ROMM-RGB # colourspace. - jfile = os.path.join(data_root, 'input/conformance/file5.jp2') + jfile = opj_data_file('input/conformance/file5.jp2') jp2 = Jp2k(jfile) ids = [box.box_id for box in jp2.box] @@ -4256,7 +4200,7 @@ class TestSuiteDump(unittest.TestCase): glymur.core.ROMM_RGB) def test_NR_file6_dump(self): - jfile = os.path.join(data_root, 'input/conformance/file6.jp2') + jfile = opj_data_file('input/conformance/file6.jp2') jp2 = Jp2k(jfile) ids = [box.box_id for box in jp2.box] @@ -4300,7 +4244,7 @@ class TestSuiteDump(unittest.TestCase): # the RCT. The colourspace is specified using both a Restricted ICC # profile and using the JPX-defined enumerated code for the e-sRGB # colourspace. - jfile = os.path.join(data_root, 'input/conformance/file7.jp2') + jfile = opj_data_file('input/conformance/file7.jp2') jp2 = Jp2k(jfile) ids = [box.box_id for box in jp2.box] @@ -4356,7 +4300,7 @@ class TestSuiteDump(unittest.TestCase): 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. - jfile = os.path.join(data_root, 'input/conformance/file8.jp2') + jfile = opj_data_file('input/conformance/file8.jp2') jp2 = Jp2k(jfile) ids = [box.box_id for box in jp2.box] @@ -4410,7 +4354,7 @@ class TestSuiteDump(unittest.TestCase): def test_NR_file9_dump(self): # Colormap - jfile = os.path.join(data_root, 'input/conformance/file9.jp2') + jfile = opj_data_file('input/conformance/file9.jp2') jp2 = Jp2k(jfile) ids = [box.box_id for box in jp2.box] @@ -4469,7 +4413,7 @@ class TestSuiteDump(unittest.TestCase): def test_NR_00042_j2k_dump(self): # Profile 3. - jfile = os.path.join(data_root, 'input/nonregression/_00042.j2k') + jfile = opj_data_file('input/nonregression/_00042.j2k') jp2k = Jp2k(jfile) c = jp2k.get_codestream(header_only=False) @@ -4622,7 +4566,7 @@ class TestSuiteDump(unittest.TestCase): def test_Bretagne2_j2k_dump(self): # Profile 3. - jfile = os.path.join(data_root, 'input/nonregression/Bretagne2.j2k') + jfile = opj_data_file('input/nonregression/Bretagne2.j2k') jp2k = Jp2k(jfile) c = jp2k.get_codestream(header_only=False) @@ -4679,7 +4623,7 @@ class TestSuiteDump(unittest.TestCase): self.assertEqual(ids, expected) def test_NR_buxI_j2k_dump(self): - jfile = os.path.join(data_root, 'input/nonregression/buxI.j2k') + jfile = opj_data_file('input/nonregression/buxI.j2k') jp2k = Jp2k(jfile) c = jp2k.get_codestream(header_only=False) @@ -4732,7 +4676,7 @@ class TestSuiteDump(unittest.TestCase): self.assertEqual(ids, expected) def test_NR_buxR_j2k_dump(self): - jfile = os.path.join(data_root, 'input/nonregression/buxR.j2k') + jfile = opj_data_file('input/nonregression/buxR.j2k') jp2k = Jp2k(jfile) c = jp2k.get_codestream(header_only=False) @@ -4789,7 +4733,7 @@ class TestSuiteDump(unittest.TestCase): 'Cannotreaddatawithnosizeknown.j2k'] path = '/'.join(lst) - jfile = os.path.join(data_root, path) + jfile = opj_data_file(path) jp2k = Jp2k(jfile) c = jp2k.get_codestream() @@ -4850,9 +4794,8 @@ class TestSuiteDump(unittest.TestCase): self.assertEqual(c.segment[3].exponent, [16] + [17, 17, 18] * 11) def test_NR_CT_Phillips_JPEG2K_Decompr_Problem_dump(self): - jfile = os.path.join(data_root, - 'input/nonregression/' - + 'CT_Phillips_JPEG2K_Decompr_Problem.j2k') + jfile = opj_data_file('input/nonregression/' + + 'CT_Phillips_JPEG2K_Decompr_Problem.j2k') jp2k = Jp2k(jfile) c = jp2k.get_codestream() @@ -4922,8 +4865,7 @@ class TestSuiteDump(unittest.TestCase): self.assertEqual(c.segment[4].ccme.decode('latin-1'), "Kakadu-3.2") def test_NR_cthead1_dump(self): - jfile = os.path.join(data_root, - 'input/nonregression/cthead1.j2k') + jfile = opj_data_file('input/nonregression/cthead1.j2k') jp2k = Jp2k(jfile) c = jp2k.get_codestream() @@ -4998,8 +4940,7 @@ class TestSuiteDump(unittest.TestCase): @unittest.skip("fprintf stderr output in r2343.") def test_NR_illegalcolortransform_dump(self): - jfile = os.path.join(data_root, - 'input/nonregression/illegalcolortransform.j2k') + jfile = opj_data_file('input/nonregression/illegalcolortransform.j2k') jp2k = Jp2k(jfile) c = jp2k.get_codestream() @@ -5060,7 +5001,7 @@ class TestSuiteDump(unittest.TestCase): self.assertEqual(c.segment[3].exponent, [16] + [17, 17, 18] * 11) def test_NR_j2k32_dump(self): - jfile = os.path.join(data_root, 'input/nonregression/j2k32.j2k') + jfile = opj_data_file('input/nonregression/j2k32.j2k') jp2k = Jp2k(jfile) c = jp2k.get_codestream() @@ -5127,9 +5068,8 @@ class TestSuiteDump(unittest.TestCase): self.assertEqual(len(c.segment[4].ccme), 36) def test_NR_kakadu_v4_4_openjpegv2_broken_dump(self): - jfile = os.path.join(data_root, - 'input/nonregression/' - + 'kakadu_v4-4_openjpegv2_broken.j2k') + jfile = opj_data_file('input/nonregression/' + + 'kakadu_v4-4_openjpegv2_broken.j2k') jp2k = Jp2k(jfile) c = jp2k.get_codestream() @@ -5213,8 +5153,7 @@ class TestSuiteDump(unittest.TestCase): self.assertEqual(c.segment[5].ccme.decode('latin-1'), expected) def test_NR_MarkerIsNotCompliant_j2k_dump(self): - jfile = os.path.join(data_root, - 'input/nonregression/MarkerIsNotCompliant.j2k') + jfile = opj_data_file('input/nonregression/MarkerIsNotCompliant.j2k') jp2k = Jp2k(jfile) c = jp2k.get_codestream() @@ -5273,8 +5212,7 @@ class TestSuiteDump(unittest.TestCase): 17, 18, 17, 17, 18, 17, 17, 18]) def test_NR_movie_00000(self): - jfile = os.path.join(data_root, - 'input/nonregression/movie_00000.j2k') + jfile = opj_data_file('input/nonregression/movie_00000.j2k') jp2k = Jp2k(jfile) c = jp2k.get_codestream() @@ -5331,8 +5269,7 @@ class TestSuiteDump(unittest.TestCase): [8, 9, 9, 10, 9, 9, 10, 9, 9, 10, 9, 9, 10, 9, 9, 10]) def test_NR_movie_00001(self): - jfile = os.path.join(data_root, - 'input/nonregression/movie_00001.j2k') + jfile = opj_data_file('input/nonregression/movie_00001.j2k') jp2k = Jp2k(jfile) c = jp2k.get_codestream() @@ -5389,8 +5326,7 @@ class TestSuiteDump(unittest.TestCase): [8, 9, 9, 10, 9, 9, 10, 9, 9, 10, 9, 9, 10, 9, 9, 10]) def test_NR_movie_00002(self): - jfile = os.path.join(data_root, - 'input/nonregression/movie_00002.j2k') + jfile = opj_data_file('input/nonregression/movie_00002.j2k') jp2k = Jp2k(jfile) c = jp2k.get_codestream() @@ -5447,8 +5383,7 @@ class TestSuiteDump(unittest.TestCase): [8, 9, 9, 10, 9, 9, 10, 9, 9, 10, 9, 9, 10, 9, 9, 10]) def test_NR_orb_blue10_lin_j2k_dump(self): - jfile = os.path.join(data_root, - 'input/nonregression/orb-blue10-lin-j2k.j2k') + jfile = opj_data_file('input/nonregression/orb-blue10-lin-j2k.j2k') jp2k = Jp2k(jfile) c = jp2k.get_codestream() @@ -5508,8 +5443,7 @@ class TestSuiteDump(unittest.TestCase): [8, 9, 9, 10, 9, 9, 10, 9, 9, 10, 9, 9, 10, 9, 9, 10]) def test_NR_orb_blue10_win_j2k_dump(self): - jfile = os.path.join(data_root, - 'input/nonregression/orb-blue10-win-j2k.j2k') + jfile = opj_data_file('input/nonregression/orb-blue10-win-j2k.j2k') jp2k = Jp2k(jfile) c = jp2k.get_codestream() @@ -5569,7 +5503,7 @@ class TestSuiteDump(unittest.TestCase): [8, 9, 9, 10, 9, 9, 10, 9, 9, 10, 9, 9, 10, 9, 9, 10]) def test_NR_pacs_ge_j2k_dump(self): - jfile = os.path.join(data_root, 'input/nonregression/pacs.ge.j2k') + jfile = opj_data_file('input/nonregression/pacs.ge.j2k') jp2k = Jp2k(jfile) c = jp2k.get_codestream() @@ -5637,8 +5571,7 @@ class TestSuiteDump(unittest.TestCase): "Kakadu-2.0.2") def test_NR_test_lossless_j2k_dump(self): - jfile = os.path.join(data_root, - 'input/nonregression/test_lossless.j2k') + jfile = opj_data_file('input/nonregression/test_lossless.j2k') jp2k = Jp2k(jfile) c = jp2k.get_codestream() @@ -5707,7 +5640,7 @@ class TestSuiteDump(unittest.TestCase): "ClearCanvas DICOM OpenJPEG") def test_NR_123_j2c_dump(self): - jfile = os.path.join(data_root, 'input/nonregression/123.j2c') + jfile = opj_data_file('input/nonregression/123.j2c') jp2k = Jp2k(jfile) c = jp2k.get_codestream() @@ -5769,7 +5702,7 @@ class TestSuiteDump(unittest.TestCase): [16] + [17, 17, 18] * 11) def test_NR_bug_j2c_dump(self): - jfile = os.path.join(data_root, 'input/nonregression/bug.j2c') + jfile = opj_data_file('input/nonregression/bug.j2c') jp2k = Jp2k(jfile) c = jp2k.get_codestream() @@ -5831,8 +5764,7 @@ class TestSuiteDump(unittest.TestCase): [16] + [17, 17, 18] * 11) def test_NR_kodak_2layers_lrcp_j2c_dump(self): - jfile = os.path.join(data_root, - 'input/nonregression/kodak_2layers_lrcp.j2c') + jfile = opj_data_file('input/nonregression/kodak_2layers_lrcp.j2c') jp2k = Jp2k(jfile) c = jp2k.get_codestream() @@ -5905,8 +5837,7 @@ class TestSuiteDump(unittest.TestCase): @unittest.skipIf(sys.hexversion < 0x03020000, "Uses features introduced in 3.2.") def test_NR_broken_jp2_dump(self): - jfile = os.path.join(data_root, - 'input/nonregression/broken.jp2') + jfile = opj_data_file('input/nonregression/broken.jp2') with self.assertWarns(UserWarning): # colr box has bad length. jp2 = Jp2k(jfile) @@ -6033,7 +5964,7 @@ class TestSuiteDump(unittest.TestCase): "Uses features introduced in 3.2, 'assertWarns'.") def test_NR_broken2_jp2_dump(self): # Invalid marker ID on codestream. - jfile = os.path.join(data_root, 'input/nonregression/broken2.jp2') + jfile = opj_data_file('input/nonregression/broken2.jp2') with self.assertWarns(UserWarning): jp2 = Jp2k(jfile) @@ -6042,8 +5973,7 @@ class TestSuiteDump(unittest.TestCase): @unittest.skipIf(sys.hexversion < 0x03020000, "Uses features introduced in 3.2.") def test_NR_broken3_jp2_dump(self): - jfile = os.path.join(data_root, - 'input/nonregression/broken3.jp2') + jfile = opj_data_file('input/nonregression/broken3.jp2') with self.assertWarns(UserWarning): # colr box has bad length. jp2 = Jp2k(jfile) @@ -6170,15 +6100,14 @@ class TestSuiteDump(unittest.TestCase): "Uses features introduced in 3.2, 'assertWarns'") def test_NR_broken4_jp2_dump(self): # Has an invalid marker in the main header - jfile = os.path.join(data_root, 'input/nonregression/broken4.jp2') + jfile = opj_data_file('input/nonregression/broken4.jp2') with self.assertWarns(UserWarning): jp2 = Jp2k(jfile) self.assertEqual(jp2.box[-1].main_header.segment[-1].marker_id, 'QCC') def test_NR_file409752(self): - jfile = os.path.join(data_root, - 'input/nonregression/file409752.jp2') + jfile = opj_data_file('input/nonregression/file409752.jp2') jp2 = Jp2k(jfile) ids = [box.box_id for box in jp2.box] @@ -6279,7 +6208,7 @@ class TestSuiteDump(unittest.TestCase): def test_NR_gdal_fuzzer_assert_in_opj_j2k_read_SQcd_SQcc_patch_jp2(self): lst = ['input', 'nonregression', 'gdal_fuzzer_assert_in_opj_j2k_read_SQcd_SQcc.patch.jp2'] - jfile = os.path.join(data_root, '/'.join(lst)) + jfile = opj_data_file('/'.join(lst)) with self.assertWarns(UserWarning): Jp2k(jfile) @@ -6287,7 +6216,7 @@ class TestSuiteDump(unittest.TestCase): "Uses features introduced in 3.2.") def test_NR_gdal_fuzzer_check_comp_dx_dy_jp2_dump(self): lst = ['input', 'nonregression', 'gdal_fuzzer_check_comp_dx_dy.jp2'] - jfile = os.path.join(data_root, '/'.join(lst)) + jfile = opj_data_file('/'.join(lst)) with self.assertWarns(UserWarning): Jp2k(jfile) @@ -6297,7 +6226,7 @@ class TestSuiteDump(unittest.TestCase): # Has an impossible tiling setup. lst = ['input', 'nonregression', 'gdal_fuzzer_check_number_of_tiles.jp2'] - jfile = os.path.join(data_root, '/'.join(lst)) + jfile = opj_data_file('/'.join(lst)) with self.assertWarns(UserWarning): Jp2k(jfile) @@ -6307,13 +6236,12 @@ class TestSuiteDump(unittest.TestCase): # Has an invalid number of resolutions. lst = ['input', 'nonregression', 'gdal_fuzzer_unchecked_numresolutions.jp2'] - jfile = os.path.join(data_root, '/'.join(lst)) + jfile = opj_data_file('/'.join(lst)) with self.assertWarns(UserWarning): Jp2k(jfile) def test_NR_issue104_jpxstream_dump(self): - jfile = os.path.join(data_root, - 'input/nonregression/issue104_jpxstream.jp2') + jfile = opj_data_file('input/nonregression/issue104_jpxstream.jp2') jp2 = Jp2k(jfile) ids = [box.box_id for box in jp2.box] @@ -6427,7 +6355,7 @@ class TestSuiteDump(unittest.TestCase): def test_NR_issue188_beach_64bitsbox(self): lst = ['input', 'nonregression', 'issue188_beach_64bitsbox.jp2'] - jfile = os.path.join(data_root, '/'.join(lst)) + jfile = opj_data_file('/'.join(lst)) with warnings.catch_warnings(): # There's a warning for an unknown box. We explicitly test for # that down below. @@ -6525,8 +6453,7 @@ class TestSuiteDump(unittest.TestCase): self.assertEqual(c.segment[3].guard_bits, 1) def test_NR_issue206_image_000_dump(self): - jfile = os.path.join(data_root, - 'input/nonregression/issue206_image-000.jp2') + jfile = opj_data_file('input/nonregression/issue206_image-000.jp2') jp2 = Jp2k(jfile) ids = [box.box_id for box in jp2.box] @@ -6626,8 +6553,7 @@ class TestSuiteDump(unittest.TestCase): self.assertEqual(c.segment[3].exponent, [8] + [9, 9, 10] * 5) def test_NR_Marrin_jp2_dump(self): - jfile = os.path.join(data_root, - 'input/nonregression/Marrin.jp2') + jfile = opj_data_file('input/nonregression/Marrin.jp2') jp2 = Jp2k(jfile) ids = [box.box_id for box in jp2.box] @@ -6740,8 +6666,7 @@ class TestSuiteDump(unittest.TestCase): "Kakadu-v5.2.1") def test_NR_mem_b2ace68c_1381_dump(self): - jfile = os.path.join(data_root, - 'input/nonregression/mem-b2ace68c-1381.jp2') + jfile = opj_data_file('input/nonregression/mem-b2ace68c-1381.jp2') with warnings.catch_warnings(): # This file has a bad pclr box, we test for this elsewhere. warnings.simplefilter("ignore") @@ -6858,8 +6783,7 @@ class TestSuiteDump(unittest.TestCase): self.assertEqual(c.segment[3].exponent, [1] + [2, 2, 3] * 5) def test_NR_mem_b2b86b74_2753_dump(self): - jfile = os.path.join(data_root, - 'input/nonregression/mem-b2b86b74-2753.jp2') + jfile = opj_data_file('input/nonregression/mem-b2b86b74-2753.jp2') jp2 = Jp2k(jfile) ids = [box.box_id for box in jp2.box] @@ -6973,7 +6897,7 @@ class TestSuiteDump(unittest.TestCase): self.assertEqual(c.segment[3].exponent, [4] + [5, 5, 6] * 5) def test_NR_merged_dump(self): - jfile = os.path.join(data_root, 'input/nonregression/merged.jp2') + jfile = opj_data_file('input/nonregression/merged.jp2') jp2 = Jp2k(jfile) ids = [box.box_id for box in jp2.box] @@ -7077,8 +7001,7 @@ class TestSuiteDump(unittest.TestCase): self.assertEqual(c.segment[4].ppod, podvals) def test_NR_orb_blue10_lin_jp2_dump(self): - jfile = os.path.join(data_root, - 'input/nonregression/orb-blue10-lin-jp2.jp2') + jfile = opj_data_file('input/nonregression/orb-blue10-lin-jp2.jp2') with warnings.catch_warnings(): # This file has an invalid ICC profile warnings.simplefilter("ignore") @@ -7177,8 +7100,7 @@ class TestSuiteDump(unittest.TestCase): [8, 9, 9, 10, 9, 9, 10, 9, 9, 10, 9, 9, 10, 9, 9, 10]) def test_NR_orb_blue10_win_jp2_dump(self): - jfile = os.path.join(data_root, - 'input/nonregression/orb-blue10-win-jp2.jp2') + jfile = opj_data_file('input/nonregression/orb-blue10-win-jp2.jp2') with warnings.catch_warnings(): # This file has an invalid ICC profile warnings.simplefilter("ignore") @@ -7277,8 +7199,7 @@ class TestSuiteDump(unittest.TestCase): [8, 9, 9, 10, 9, 9, 10, 9, 9, 10, 9, 9, 10, 9, 9, 10]) def test_NR_text_GBR_dump(self): - jfile = os.path.join(data_root, - 'input/nonregression/text_GBR.jp2') + jfile = opj_data_file('input/nonregression/text_GBR.jp2') with warnings.catch_warnings(): # brand is 'jp2 ', but has any icc profile. warnings.simplefilter("ignore") @@ -7391,7 +7312,7 @@ class TestSuiteDump(unittest.TestCase): @unittest.skipIf(glymur.lib.openjpeg.OPENJPEG is None, "Missing openjpeg library.") -@unittest.skipIf(data_root is None, +@unittest.skipIf(OPJ_DATA_ROOT is None, "OPJ_DATA_ROOT environment variable not set") class TestSuite15(unittest.TestCase): """Suite of tests for libopenjpeg 1.5.1""" @@ -7414,16 +7335,16 @@ class TestSuite15(unittest.TestCase): pass def test_ETS_C0P0_p0_01_j2k(self): - jfile = os.path.join(data_root, 'input/conformance/p0_01.j2k') + jfile = opj_data_file('input/conformance/p0_01.j2k') jp2k = Jp2k(jfile) jpdata = jp2k.read(rlevel=0) - pgxfile = os.path.join(data_root, 'baseline/conformance/c0p0_01.pgx') + pgxfile = opj_data_file('baseline/conformance/c0p0_01.pgx') pgxdata = read_pgx(pgxfile) np.testing.assert_array_equal(jpdata, pgxdata) def test_ETS_C0P0_p0_02_j2k(self): - jfile = os.path.join(data_root, 'input/conformance/p0_02.j2k') + jfile = opj_data_file('input/conformance/p0_02.j2k') with warnings.catch_warnings(): # There's a 0xff30 marker segment. Not illegal, but we don't # really know what to do with it. Just ignore. @@ -7431,79 +7352,74 @@ class TestSuite15(unittest.TestCase): jp2k = Jp2k(jfile) jpdata = jp2k.read(rlevel=0) - pgxfile = os.path.join(data_root, 'baseline/conformance/c0p0_02.pgx') + pgxfile = opj_data_file('baseline/conformance/c0p0_02.pgx') pgxdata = read_pgx(pgxfile) np.testing.assert_array_equal(jpdata, pgxdata) def test_ETS_C0P0_p0_09_j2k(self): - jfile = os.path.join(data_root, 'input/conformance/p0_09.j2k') + jfile = opj_data_file('input/conformance/p0_09.j2k') jp2k = Jp2k(jfile) jpdata = jp2k.read(rlevel=2) - pgxfile = os.path.join(data_root, - 'baseline/conformance/c0p0_09.pgx') + pgxfile = opj_data_file('baseline/conformance/c0p0_09.pgx') pgxdata = read_pgx(pgxfile) self.assertTrue(peak_tolerance(jpdata, pgxdata) < 4) self.assertTrue(mse(jpdata, pgxdata) < 1.47) def test_ETS_C0P0_p0_11_j2k(self): - jfile = os.path.join(data_root, 'input/conformance/p0_11.j2k') + jfile = opj_data_file('input/conformance/p0_11.j2k') jp2k = Jp2k(jfile) jpdata = jp2k.read(rlevel=0) - pgxfile = os.path.join(data_root, - 'baseline/conformance/c0p0_11.pgx') + pgxfile = opj_data_file('baseline/conformance/c0p0_11.pgx') pgxdata = read_pgx(pgxfile) np.testing.assert_array_equal(jpdata, pgxdata) @unittest.skip("fprintf stderr output in r2343.") def test_ETS_C0P0_p0_12_j2k(self): - jfile = os.path.join(data_root, 'input/conformance/p0_12.j2k') + jfile = opj_data_file('input/conformance/p0_12.j2k') jp2k = Jp2k(jfile) jpdata = jp2k.read(rlevel=0) - pgxfile = os.path.join(data_root, - 'baseline/conformance/c0p0_12.pgx') + pgxfile = opj_data_file('baseline/conformance/c0p0_12.pgx') pgxdata = read_pgx(pgxfile) np.testing.assert_array_equal(jpdata, pgxdata) def test_ETS_C0P0_p0_16_j2k(self): - jfile = os.path.join(data_root, 'input/conformance/p0_16.j2k') + jfile = opj_data_file('input/conformance/p0_16.j2k') jp2k = Jp2k(jfile) jpdata = jp2k.read(rlevel=0) - pgxfile = os.path.join(data_root, - 'baseline/conformance/c0p0_16.pgx') + pgxfile = opj_data_file('baseline/conformance/c0p0_16.pgx') pgxdata = read_pgx(pgxfile) np.testing.assert_array_equal(jpdata, pgxdata) def test_ETS_C0P1_p1_01_j2k(self): - jfile = os.path.join(data_root, 'input/conformance/p1_01.j2k') + jfile = opj_data_file('input/conformance/p1_01.j2k') jp2k = Jp2k(jfile) jpdata = jp2k.read(rlevel=0) - pgxfile = os.path.join(data_root, - 'baseline/conformance/c0p1_01.pgx') + pgxfile = opj_data_file('baseline/conformance/c0p1_01.pgx') pgxdata = read_pgx(pgxfile) np.testing.assert_array_equal(jpdata, pgxdata) def test_ETS_C1P0_p0_01_j2k(self): - jfile = os.path.join(data_root, 'input/conformance/p0_01.j2k') + jfile = opj_data_file('input/conformance/p0_01.j2k') jp2k = Jp2k(jfile) jpdata = jp2k.read(rlevel=0) - pgxfile = os.path.join(data_root, 'baseline/conformance/c1p0_01_0.pgx') + pgxfile = opj_data_file('baseline/conformance/c1p0_01_0.pgx') pgxdata = read_pgx(pgxfile) np.testing.assert_array_equal(jpdata, pgxdata) def test_ETS_C1P0_p0_02_j2k(self): - jfile = os.path.join(data_root, 'input/conformance/p0_02.j2k') + jfile = opj_data_file('input/conformance/p0_02.j2k') with warnings.catch_warnings(): # There's a 0xff30 marker segment. Not illegal, but we don't # really know what to do with it. Just ignore. @@ -7511,293 +7427,293 @@ class TestSuite15(unittest.TestCase): jp2k = Jp2k(jfile) jpdata = jp2k.read(rlevel=0) - pgxfile = os.path.join(data_root, 'baseline/conformance/c1p0_02_0.pgx') + pgxfile = opj_data_file('baseline/conformance/c1p0_02_0.pgx') pgxdata = read_pgx(pgxfile) np.testing.assert_array_equal(jpdata, pgxdata) def test_ETS_C1P0_p0_03_j2k(self): - jfile = os.path.join(data_root, 'input/conformance/p0_03.j2k') + jfile = opj_data_file('input/conformance/p0_03.j2k') jp2k = Jp2k(jfile) jpdata = jp2k.read(rlevel=0) - pgxfile = os.path.join(data_root, 'baseline/conformance/c1p0_03_0.pgx') + pgxfile = opj_data_file('baseline/conformance/c1p0_03_0.pgx') pgxdata = read_pgx(pgxfile) np.testing.assert_array_equal(jpdata, pgxdata) def test_ETS_C1P0_p0_04_j2k(self): - jfile = os.path.join(data_root, 'input/conformance/p0_04.j2k') + jfile = opj_data_file('input/conformance/p0_04.j2k') jp2k = Jp2k(jfile) jpdata = jp2k.read(rlevel=0) - pgxfile = os.path.join(data_root, 'baseline/conformance/c1p0_04_0.pgx') + pgxfile = opj_data_file('baseline/conformance/c1p0_04_0.pgx') pgxdata = read_pgx(pgxfile) self.assertTrue(peak_tolerance(jpdata[:, :, 0], pgxdata) < 5) self.assertTrue(mse(jpdata[:, :, 0], pgxdata) < 0.776) - pgxfile = os.path.join(data_root, 'baseline/conformance/c1p0_04_1.pgx') + pgxfile = opj_data_file('baseline/conformance/c1p0_04_1.pgx') pgxdata = read_pgx(pgxfile) self.assertTrue(peak_tolerance(jpdata[:, :, 1], pgxdata) < 4) self.assertTrue(mse(jpdata[:, :, 1], pgxdata) < 0.626) - pgxfile = os.path.join(data_root, 'baseline/conformance/c1p0_04_2.pgx') + pgxfile = opj_data_file('baseline/conformance/c1p0_04_2.pgx') pgxdata = read_pgx(pgxfile) self.assertTrue(peak_tolerance(jpdata[:, :, 2], pgxdata) < 6) self.assertTrue(mse(jpdata[:, :, 2], pgxdata) < 1.07) def test_ETS_C1P0_p0_08_j2k(self): - jfile = os.path.join(data_root, 'input/conformance/p0_08.j2k') + jfile = opj_data_file('input/conformance/p0_08.j2k') jp2k = Jp2k(jfile) jpdata = jp2k.read(rlevel=1) - pgxfile = os.path.join(data_root, 'baseline/conformance/c1p0_08_0.pgx') + pgxfile = opj_data_file('baseline/conformance/c1p0_08_0.pgx') pgxdata = read_pgx(pgxfile) np.testing.assert_array_equal(jpdata[:, :, 0], pgxdata) - pgxfile = os.path.join(data_root, 'baseline/conformance/c1p0_08_1.pgx') + pgxfile = opj_data_file('baseline/conformance/c1p0_08_1.pgx') pgxdata = read_pgx(pgxfile) np.testing.assert_array_equal(jpdata[:, :, 1], pgxdata) - pgxfile = os.path.join(data_root, 'baseline/conformance/c1p0_08_2.pgx') + pgxfile = opj_data_file('baseline/conformance/c1p0_08_2.pgx') pgxdata = read_pgx(pgxfile) np.testing.assert_array_equal(jpdata[:, :, 2], pgxdata) def test_ETS_C1P0_p0_09_j2k(self): - jfile = os.path.join(data_root, 'input/conformance/p0_09.j2k') + jfile = opj_data_file('input/conformance/p0_09.j2k') jp2k = Jp2k(jfile) jpdata = jp2k.read(rlevel=0) - pgxfile = os.path.join(data_root, 'baseline/conformance/c1p0_09_0.pgx') + pgxfile = opj_data_file('baseline/conformance/c1p0_09_0.pgx') pgxdata = read_pgx(pgxfile) np.testing.assert_array_equal(jpdata, pgxdata) def test_ETS_C1P0_p0_10_j2k(self): - jfile = os.path.join(data_root, 'input/conformance/p0_10.j2k') + jfile = opj_data_file('input/conformance/p0_10.j2k') jp2k = Jp2k(jfile) with warnings.catch_warnings(): # This file has an invalid ICC profile warnings.simplefilter("ignore") jpdata = jp2k.read(rlevel=0) - pgxfile = os.path.join(data_root, 'baseline/conformance/c1p0_10_0.pgx') + pgxfile = opj_data_file('baseline/conformance/c1p0_10_0.pgx') pgxdata = read_pgx(pgxfile) np.testing.assert_array_equal(jpdata[:, :, 0], pgxdata) - pgxfile = os.path.join(data_root, 'baseline/conformance/c1p0_10_1.pgx') + pgxfile = opj_data_file('baseline/conformance/c1p0_10_1.pgx') pgxdata = read_pgx(pgxfile) np.testing.assert_array_equal(jpdata[:, :, 1], pgxdata) - pgxfile = os.path.join(data_root, 'baseline/conformance/c1p0_10_2.pgx') + pgxfile = opj_data_file('baseline/conformance/c1p0_10_2.pgx') pgxdata = read_pgx(pgxfile) np.testing.assert_array_equal(jpdata[:, :, 2], pgxdata) def test_ETS_C1P0_p0_11_j2k(self): - jfile = os.path.join(data_root, 'input/conformance/p0_11.j2k') + jfile = opj_data_file('input/conformance/p0_11.j2k') jp2k = Jp2k(jfile) jpdata = jp2k.read(rlevel=0) - pgxfile = os.path.join(data_root, 'baseline/conformance/c1p0_11_0.pgx') + pgxfile = opj_data_file('baseline/conformance/c1p0_11_0.pgx') pgxdata = read_pgx(pgxfile) np.testing.assert_array_equal(jpdata, pgxdata) @unittest.skip("fprintf stderr output in r2343.") def test_ETS_C1P0_p0_12_j2k(self): - jfile = os.path.join(data_root, 'input/conformance/p0_12.j2k') + jfile = opj_data_file('input/conformance/p0_12.j2k') jp2k = Jp2k(jfile) jpdata = jp2k.read(rlevel=0) - pgxfile = os.path.join(data_root, 'baseline/conformance/c1p0_12_0.pgx') + pgxfile = opj_data_file('baseline/conformance/c1p0_12_0.pgx') pgxdata = read_pgx(pgxfile) np.testing.assert_array_equal(jpdata, pgxdata) @unittest.skip("fprintf stderr output in r2343.") def test_ETS_C1P0_p0_13_j2k(self): - jfile = os.path.join(data_root, 'input/conformance/p0_13.j2k') + jfile = opj_data_file('input/conformance/p0_13.j2k') jp2k = Jp2k(jfile) jpdata = jp2k.read(rlevel=0) - pgxfile = os.path.join(data_root, 'baseline/conformance/c1p0_13_0.pgx') + pgxfile = opj_data_file('baseline/conformance/c1p0_13_0.pgx') pgxdata = read_pgx(pgxfile) np.testing.assert_array_equal(jpdata[:, :, 0], pgxdata) - pgxfile = os.path.join(data_root, 'baseline/conformance/c1p0_13_1.pgx') + pgxfile = opj_data_file('baseline/conformance/c1p0_13_1.pgx') pgxdata = read_pgx(pgxfile) np.testing.assert_array_equal(jpdata[:, :, 1], pgxdata) - pgxfile = os.path.join(data_root, 'baseline/conformance/c1p0_13_2.pgx') + pgxfile = opj_data_file('baseline/conformance/c1p0_13_2.pgx') pgxdata = read_pgx(pgxfile) np.testing.assert_array_equal(jpdata[:, :, 2], pgxdata) - pgxfile = os.path.join(data_root, 'baseline/conformance/c1p0_13_3.pgx') + pgxfile = opj_data_file('baseline/conformance/c1p0_13_3.pgx') pgxdata = read_pgx(pgxfile) np.testing.assert_array_equal(jpdata[:, :, 3], pgxdata) def test_ETS_C1P0_p0_14_j2k(self): - jfile = os.path.join(data_root, 'input/conformance/p0_14.j2k') + jfile = opj_data_file('input/conformance/p0_14.j2k') jp2k = Jp2k(jfile) jpdata = jp2k.read(rlevel=0) - pgxfile = os.path.join(data_root, 'baseline/conformance/c1p0_14_0.pgx') + pgxfile = opj_data_file('baseline/conformance/c1p0_14_0.pgx') pgxdata = read_pgx(pgxfile) np.testing.assert_array_equal(jpdata[:, :, 0], pgxdata) - pgxfile = os.path.join(data_root, 'baseline/conformance/c1p0_14_1.pgx') + pgxfile = opj_data_file('baseline/conformance/c1p0_14_1.pgx') pgxdata = read_pgx(pgxfile) np.testing.assert_array_equal(jpdata[:, :, 1], pgxdata) - pgxfile = os.path.join(data_root, 'baseline/conformance/c1p0_14_2.pgx') + pgxfile = opj_data_file('baseline/conformance/c1p0_14_2.pgx') pgxdata = read_pgx(pgxfile) np.testing.assert_array_equal(jpdata[:, :, 2], pgxdata) def test_ETS_C1P0_p0_15_j2k(self): - jfile = os.path.join(data_root, 'input/conformance/p0_15.j2k') + jfile = opj_data_file('input/conformance/p0_15.j2k') jp2k = Jp2k(jfile) jpdata = jp2k.read(rlevel=0) - pgxfile = os.path.join(data_root, 'baseline/conformance/c1p0_15_0.pgx') + pgxfile = opj_data_file('baseline/conformance/c1p0_15_0.pgx') pgxdata = read_pgx(pgxfile) np.testing.assert_array_equal(jpdata, pgxdata) def test_ETS_C1P0_p0_16_j2k(self): - jfile = os.path.join(data_root, 'input/conformance/p0_16.j2k') + jfile = opj_data_file('input/conformance/p0_16.j2k') jp2k = Jp2k(jfile) jpdata = jp2k.read(rlevel=0) - pgxfile = os.path.join(data_root, 'baseline/conformance/c1p0_16_0.pgx') + pgxfile = opj_data_file('baseline/conformance/c1p0_16_0.pgx') pgxdata = read_pgx(pgxfile) np.testing.assert_array_equal(jpdata, pgxdata) def test_ETS_C1P1_p1_01_j2k(self): - jfile = os.path.join(data_root, 'input/conformance/p1_01.j2k') + jfile = opj_data_file('input/conformance/p1_01.j2k') jp2k = Jp2k(jfile) jpdata = jp2k.read(rlevel=0) - pgxfile = os.path.join(data_root, 'baseline/conformance/c1p1_01_0.pgx') + pgxfile = opj_data_file('baseline/conformance/c1p1_01_0.pgx') pgxdata = read_pgx(pgxfile) np.testing.assert_array_equal(jpdata, pgxdata) def test_ETS_C1P1_p1_02_j2k(self): - jfile = os.path.join(data_root, 'input/conformance/p1_02.j2k') + jfile = opj_data_file('input/conformance/p1_02.j2k') jp2k = Jp2k(jfile) jpdata = jp2k.read(rlevel=0) - pgxfile = os.path.join(data_root, 'baseline/conformance/c1p1_02_0.pgx') + pgxfile = opj_data_file('baseline/conformance/c1p1_02_0.pgx') pgxdata = read_pgx(pgxfile) self.assertTrue(peak_tolerance(jpdata[:, :, 0], pgxdata) < 5) self.assertTrue(mse(jpdata[:, :, 0], pgxdata) < 0.765) - pgxfile = os.path.join(data_root, 'baseline/conformance/c1p1_02_1.pgx') + pgxfile = opj_data_file('baseline/conformance/c1p1_02_1.pgx') pgxdata = read_pgx(pgxfile) self.assertTrue(peak_tolerance(jpdata[:, :, 1], pgxdata) < 4) self.assertTrue(mse(jpdata[:, :, 1], pgxdata) < 0.616) - pgxfile = os.path.join(data_root, 'baseline/conformance/c1p1_02_2.pgx') + pgxfile = opj_data_file('baseline/conformance/c1p1_02_2.pgx') pgxdata = read_pgx(pgxfile) self.assertTrue(peak_tolerance(jpdata[:, :, 2], pgxdata) < 6) self.assertTrue(mse(jpdata[:, :, 2], pgxdata) < 1.051) def test_ETS_C1P1_p1_04_j2k(self): - jfile = os.path.join(data_root, 'input/conformance/p1_04.j2k') + jfile = opj_data_file('input/conformance/p1_04.j2k') jp2k = Jp2k(jfile) jpdata = jp2k.read() - pgxfile = os.path.join(data_root, 'baseline/conformance/c1p1_04_0.pgx') + pgxfile = opj_data_file('baseline/conformance/c1p1_04_0.pgx') pgxdata = read_pgx(pgxfile) self.assertTrue(peak_tolerance(jpdata, pgxdata) < 624) self.assertTrue(mse(jpdata, pgxdata) < 3080) @unittest.skip("fprintf stderr output in r2343.") def test_ETS_C1P1_p1_05_j2k(self): - jfile = os.path.join(data_root, 'input/conformance/p1_05.j2k') + jfile = opj_data_file('input/conformance/p1_05.j2k') jp2k = Jp2k(jfile) jpdata = jp2k.read() - pgxfile = os.path.join(data_root, 'baseline/conformance/c1p1_05_0.pgx') + pgxfile = opj_data_file('baseline/conformance/c1p1_05_0.pgx') pgxdata = read_pgx(pgxfile) self.assertTrue(peak_tolerance(jpdata[:, :, 0], pgxdata) < 40) self.assertTrue(mse(jpdata[:, :, 0], pgxdata) < 8.458) - pgxfile = os.path.join(data_root, 'baseline/conformance/c1p1_05_1.pgx') + pgxfile = opj_data_file('baseline/conformance/c1p1_05_1.pgx') pgxdata = read_pgx(pgxfile) self.assertTrue(peak_tolerance(jpdata[:, :, 1], pgxdata) < 40) self.assertTrue(mse(jpdata[:, :, 1], pgxdata) < 9.816) - pgxfile = os.path.join(data_root, 'baseline/conformance/c1p1_05_2.pgx') + pgxfile = opj_data_file('baseline/conformance/c1p1_05_2.pgx') pgxdata = read_pgx(pgxfile) self.assertTrue(peak_tolerance(jpdata[:, :, 2], pgxdata) < 40) self.assertTrue(mse(jpdata[:, :, 2], pgxdata) < 10.154) @unittest.skip("fprintf stderr output in r2343.") def test_ETS_C1P1_p1_06_j2k(self): - jfile = os.path.join(data_root, 'input/conformance/p1_06.j2k') + jfile = opj_data_file('input/conformance/p1_06.j2k') jp2k = Jp2k(jfile) jpdata = jp2k.read() - pgxfile = os.path.join(data_root, 'baseline/conformance/c1p1_06_0.pgx') + pgxfile = opj_data_file('baseline/conformance/c1p1_06_0.pgx') pgxdata = read_pgx(pgxfile) self.assertTrue(peak_tolerance(jpdata[:, :, 0], pgxdata) < 2) self.assertTrue(mse(jpdata[:, :, 0], pgxdata) < 0.6) - pgxfile = os.path.join(data_root, 'baseline/conformance/c1p1_06_1.pgx') + pgxfile = opj_data_file('baseline/conformance/c1p1_06_1.pgx') pgxdata = read_pgx(pgxfile) self.assertTrue(peak_tolerance(jpdata[:, :, 1], pgxdata) < 2) self.assertTrue(mse(jpdata[:, :, 1], pgxdata) < 0.6) - pgxfile = os.path.join(data_root, 'baseline/conformance/c1p1_06_2.pgx') + pgxfile = opj_data_file('baseline/conformance/c1p1_06_2.pgx') pgxdata = read_pgx(pgxfile) self.assertTrue(peak_tolerance(jpdata[:, :, 2], pgxdata) < 2) self.assertTrue(mse(jpdata[:, :, 2], pgxdata) < 0.6) def test_ETS_JP2_file1(self): - jfile = os.path.join(data_root, 'input/conformance/file1.jp2') + jfile = opj_data_file('input/conformance/file1.jp2') jp2k = Jp2k(jfile) jpdata = jp2k.read() self.assertEqual(jpdata.shape, (512, 768, 3)) def test_ETS_JP2_file2(self): - jfile = os.path.join(data_root, 'input/conformance/file2.jp2') + jfile = opj_data_file('input/conformance/file2.jp2') jp2k = Jp2k(jfile) jpdata = jp2k.read() self.assertEqual(jpdata.shape, (640, 480, 3)) def test_ETS_JP2_file4(self): - jfile = os.path.join(data_root, 'input/conformance/file4.jp2') + jfile = opj_data_file('input/conformance/file4.jp2') jp2k = Jp2k(jfile) jpdata = jp2k.read() self.assertEqual(jpdata.shape, (512, 768)) def test_ETS_JP2_file5(self): """ETS_JP2_file5""" - jfile = os.path.join(data_root, 'input/conformance/file5.jp2') + jfile = opj_data_file('input/conformance/file5.jp2') jp2k = Jp2k(jfile) jpdata = jp2k.read() self.assertEqual(jpdata.shape, (512, 768, 3)) def test_ETS_JP2_file6(self): """ETS_JP2_file6""" - jfile = os.path.join(data_root, 'input/conformance/file6.jp2') + jfile = opj_data_file('input/conformance/file6.jp2') jp2k = Jp2k(jfile) jpdata = jp2k.read() self.assertEqual(jpdata.shape, (512, 768)) def test_ETS_JP2_file7(self): """ETS_JP2_file7""" - jfile = os.path.join(data_root, 'input/conformance/file7.jp2') + jfile = opj_data_file('input/conformance/file7.jp2') jp2k = Jp2k(jfile) jpdata = jp2k.read() self.assertEqual(jpdata.shape, (640, 480, 3)) def test_ETS_JP2_file8(self): """ETS_JP2_file8""" - jfile = os.path.join(data_root, 'input/conformance/file8.jp2') + jfile = opj_data_file('input/conformance/file8.jp2') jp2k = Jp2k(jfile) jpdata = jp2k.read() self.assertEqual(jpdata.shape, (400, 700)) def test_ETS_JP2_file9(self): """ETS_JP2_file9""" - jfile = os.path.join(data_root, 'input/conformance/file9.jp2') + jfile = opj_data_file('input/conformance/file9.jp2') jp2k = Jp2k(jfile) jpdata = jp2k.read() if re.match(r'[01]\.3', OPENJPEG_VERSION): @@ -7808,14 +7724,14 @@ class TestSuite15(unittest.TestCase): def test_NR_DEC_Bretagne2_j2k_1_decode(self): """test_NR_DEC_Bretagne2_j2k_1_decode""" - jfile = os.path.join(data_root, 'input/nonregression/Bretagne2.j2k') + jfile = opj_data_file('input/nonregression/Bretagne2.j2k') jp2 = Jp2k(jfile) jp2.read() self.assertTrue(True) def test_NR_DEC__00042_j2k_2_decode(self): """NR_DEC__00042_j2k_2_decode""" - jfile = os.path.join(data_root, 'input/nonregression/_00042.j2k') + jfile = opj_data_file('input/nonregression/_00042.j2k') jp2 = Jp2k(jfile) jp2.read() self.assertTrue(True) @@ -7823,7 +7739,7 @@ class TestSuite15(unittest.TestCase): @unittest.skip("fprintf stderr output in r2343.") def test_NR_DEC_123_j2c_3_decode(self): """NR_DEC_123_j2c_3_decode""" - jfile = os.path.join(data_root, 'input/nonregression/123.j2c') + jfile = opj_data_file('input/nonregression/123.j2c') jp2 = Jp2k(jfile) jp2.read() self.assertTrue(True) @@ -7832,7 +7748,7 @@ class TestSuite15(unittest.TestCase): "Uses features introduced in 3.2.") def test_NR_DEC_broken_jp2_4_decode(self): """NR_DEC_broken_jp2_4_decode""" - jfile = os.path.join(data_root, 'input/nonregression/broken.jp2') + jfile = opj_data_file('input/nonregression/broken.jp2') with self.assertWarns(UserWarning): # colr box has bad length. jp2 = Jp2k(jfile) @@ -7845,7 +7761,7 @@ class TestSuite15(unittest.TestCase): def test_NR_DEC_broken2_jp2_5_decode(self): """NR_DEC_broken2_jp2_5_decode""" # Null pointer access - jfile = os.path.join(data_root, 'input/nonregression/broken2.jp2') + jfile = opj_data_file('input/nonregression/broken2.jp2') with self.assertRaises(ValueError): with warnings.catch_warnings(): # Library warning, invalid number of subbands. @@ -7857,7 +7773,7 @@ class TestSuite15(unittest.TestCase): "Uses features introduced in 3.2.") def test_NR_DEC_broken3_jp2_6_decode(self): """NR_DEC_broken3_jp2_6_decode""" - jfile = os.path.join(data_root, 'input/nonregression/broken3.jp2') + jfile = opj_data_file('input/nonregression/broken3.jp2') with self.assertWarns(UserWarning): # colr box has bad length. j = Jp2k(jfile) @@ -7870,7 +7786,7 @@ class TestSuite15(unittest.TestCase): def test_NR_DEC_broken4_jp2_7_decode(self): """NR_DEC_broken4_jp2_7_decode""" # Null pointer access - jfile = os.path.join(data_root, 'input/nonregression/broken4.jp2') + jfile = opj_data_file('input/nonregression/broken4.jp2') with self.assertRaises(ValueError): with warnings.catch_warnings(): # Library warning, invalid number of subbands. @@ -7881,60 +7797,59 @@ class TestSuite15(unittest.TestCase): @unittest.skip("fprintf stderr output in r2343.") def test_NR_DEC_bug_j2c_8_decode(self): """NR_DEC_bug_j2c_8_decode""" - jfile = os.path.join(data_root, 'input/nonregression/bug.j2c') + jfile = opj_data_file('input/nonregression/bug.j2c') Jp2k(jfile).read() self.assertTrue(True) def test_NR_DEC_buxI_j2k_9_decode(self): """NR_DEC_buxI_j2k_9_decode""" - jfile = os.path.join(data_root, 'input/nonregression/buxI.j2k') + jfile = opj_data_file('input/nonregression/buxI.j2k') Jp2k(jfile).read() self.assertTrue(True) def test_NR_DEC_buxR_j2k_10_decode(self): """NR_DEC_buxR_j2k_10_decode""" - jfile = os.path.join(data_root, 'input/nonregression/buxR.j2k') + jfile = opj_data_file('input/nonregression/buxR.j2k') Jp2k(jfile).read() self.assertTrue(True) def test_NR_DEC_Cannotreaddatawithnosizeknown_j2k_11_decode(self): """NR_DEC_Cannotreaddatawithnosizeknown_j2k_11_decode""" relpath = 'input/nonregression/Cannotreaddatawithnosizeknown.j2k' - jfile = os.path.join(data_root, relpath) + jfile = opj_data_file(relpath) Jp2k(jfile).read() self.assertTrue(True) def test_NR_DEC_cthead1_j2k_12_decode(self): """NR_DEC_cthead1_j2k_12_decode""" - jfile = os.path.join(data_root, 'input/nonregression/cthead1.j2k') + jfile = opj_data_file('input/nonregression/cthead1.j2k') Jp2k(jfile).read() self.assertTrue(True) def test_NR_DEC_CT_Phillips_JPEG2K_Decompr_Problem_j2k_13_decode(self): """NR_DEC_CT_Phillips_JPEG2K_Decompr_Problem_j2k_13_decode""" relpath = 'input/nonregression/CT_Phillips_JPEG2K_Decompr_Problem.j2k' - jfile = os.path.join(data_root, relpath) + jfile = opj_data_file(relpath) Jp2k(jfile).read() self.assertTrue(True) @unittest.skip("fprintf stderr output in r2343.") def test_NR_DEC_illegalcolortransform_j2k_14_decode(self): """Stream too short, expected SOT.""" - jfile = os.path.join(data_root, - 'input/nonregression/illegalcolortransform.j2k') + jfile = opj_data_file('input/nonregression/illegalcolortransform.j2k') Jp2k(jfile).read() self.assertTrue(True) def test_NR_DEC_j2k32_j2k_15_decode(self): """NR_DEC_j2k32_j2k_15_decode""" - jfile = os.path.join(data_root, 'input/nonregression/j2k32.j2k') + jfile = opj_data_file('input/nonregression/j2k32.j2k') Jp2k(jfile).read() self.assertTrue(True) def test_NR_DEC_kakadu_v4_4_openjpegv2_broken_j2k_16_decode(self): """NR_DEC_kakadu_v4_4_openjpegv2_broken_j2k_16_decode""" relpath = 'input/nonregression/kakadu_v4-4_openjpegv2_broken.j2k' - jfile = os.path.join(data_root, relpath) + jfile = opj_data_file(relpath) with warnings.catch_warnings(): # This file has an invalid ICC profile warnings.simplefilter("ignore") @@ -7943,55 +7858,49 @@ class TestSuite15(unittest.TestCase): def test_NR_DEC_MarkerIsNotCompliant_j2k_17_decode(self): """NR_DEC_MarkerIsNotCompliant_j2k_17_decode""" - jfile = os.path.join(data_root, - 'input/nonregression/MarkerIsNotCompliant.j2k') + jfile = opj_data_file('input/nonregression/MarkerIsNotCompliant.j2k') Jp2k(jfile).read() self.assertTrue(True) def test_NR_DEC_Marrin_jp2_18_decode(self): """NR_DEC_Marrin_jp2_18_decode""" - jfile = os.path.join(data_root, 'input/nonregression/Marrin.jp2') + jfile = opj_data_file('input/nonregression/Marrin.jp2') Jp2k(jfile).read() self.assertTrue(True) def test_NR_DEC_movie_00000_j2k_20_decode(self): """test_NR_DEC_movie_00000_j2k_20_decode""" - jfile = os.path.join(data_root, - 'input/nonregression/movie_00000.j2k') + jfile = opj_data_file('input/nonregression/movie_00000.j2k') Jp2k(jfile).read() self.assertTrue(True) def test_NR_DEC_movie_00001_j2k_21_decode(self): """NR_DEC_movie_00001_j2k_21_decode""" - jfile = os.path.join(data_root, - 'input/nonregression/movie_00001.j2k') + jfile = opj_data_file('input/nonregression/movie_00001.j2k') Jp2k(jfile).read() self.assertTrue(True) def test_NR_DEC_movie_00002_j2k_22_decode(self): """NR_DEC_movie_00002_j2k_22_decode""" - jfile = os.path.join(data_root, 'input/nonregression/movie_00002.j2k') + jfile = opj_data_file('input/nonregression/movie_00002.j2k') Jp2k(jfile).read() self.assertTrue(True) def test_NR_DEC_orb_blue_lin_j2k_j2k_23_decode(self): """NR_DEC_orb_blue_lin_j2k_j2k_23_decode""" - jfile = os.path.join(data_root, - 'input/nonregression/orb-blue10-lin-j2k.j2k') + jfile = opj_data_file('input/nonregression/orb-blue10-lin-j2k.j2k') Jp2k(jfile).read() self.assertTrue(True) def test_NR_DEC_orb_blue_win_j2k_j2k_24_decode(self): """NR_DEC_orb_blue_win_j2k_j2k_24_decode""" - jfile = os.path.join(data_root, - 'input/nonregression/orb-blue10-win-j2k.j2k') + jfile = opj_data_file('input/nonregression/orb-blue10-win-j2k.j2k') Jp2k(jfile).read() self.assertTrue(True) def test_nc_dec_orb_blue_lin_jp2_25_decode(self): """NR-DEC-orb-blue-lin.jp2-25-decode""" - jfile = os.path.join(data_root, - 'input/nonregression/orb-blue10-lin-jp2.jp2') + jfile = opj_data_file('input/nonregression/orb-blue10-lin-jp2.jp2') with warnings.catch_warnings(): # This file has an invalid ICC profile warnings.simplefilter("ignore") @@ -8000,35 +7909,31 @@ class TestSuite15(unittest.TestCase): def test_nr_dec_orb_blue_win_jp2_26_decode(self): """NR-DEC-orb-blue-win.jp2-26-decode""" - jfile = os.path.join(data_root, - 'input/nonregression/orb-blue10-win-jp2.jp2') + jfile = opj_data_file('input/nonregression/orb-blue10-win-jp2.jp2') Jp2k(jfile).read() self.assertTrue(True) def test_nr_dec_relax_jp2_27_decode(self): """NR-DEC-relax.jp2-27-decode""" - jfile = os.path.join(data_root, - 'input/nonregression/relax.jp2') + jfile = opj_data_file('input/nonregression/relax.jp2') Jp2k(jfile).read() self.assertTrue(True) def test_nr_dec_test_lossless_j2k_28_decode(self): """NR-DEC-test-lossless.j2k-28-decode""" - jfile = os.path.join(data_root, - 'input/nonregression/test_lossless.j2k') + jfile = opj_data_file('input/nonregression/test_lossless.j2k') Jp2k(jfile).read() self.assertTrue(True) def test_nr_dec_issue104_jpxstream_jp2_33_decode(self): """NR-DEC-issue104-jpxstream.jp2-33-decode""" - jfile = os.path.join(data_root, - 'input/nonregression/issue104_jpxstream.jp2') + jfile = opj_data_file('input/nonregression/issue104_jpxstream.jp2') Jp2k(jfile).read() self.assertTrue(True) def test_nr_dec_file_409752_jp2_40_decode(self): """NR-DEC-file-409752.jp2-40-decode""" - jfile = os.path.join(data_root, 'input/nonregression/file409752.jp2') + jfile = opj_data_file('input/nonregression/file409752.jp2') j = Jp2k(jfile) with self.assertRaises(RuntimeError): j.read() diff --git a/glymur/test/test_opj_suite_neg.py b/glymur/test/test_opj_suite_neg.py index e8675aa..66115a2 100644 --- a/glymur/test/test_opj_suite_neg.py +++ b/glymur/test/test_opj_suite_neg.py @@ -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) diff --git a/glymur/test/test_opj_suite_write.py b/glymur/test/test_opj_suite_write.py index e6f1575..479cb1f 100644 --- a/glymur/test/test_opj_suite_write.py +++ b/glymur/test/test_opj_suite_write.py @@ -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') diff --git a/glymur/test/test_printing.py b/glymur/test/test_printing.py index f533aa4..8591b1b 100644 --- a/glymur/test/test_printing.py +++ b/glymur/test/test_printing.py @@ -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")