Fixed test skipping when no OPJ_DATA_ROOT present. #185

This commit is contained in:
John Evans 2014-03-13 21:39:24 -04:00
commit 86ac1c4ae5
3 changed files with 30 additions and 15 deletions

View file

@ -287,6 +287,8 @@ class TestBadButRecoverableXmlFile(unittest.TestCase):
b'<test>this is a test</test>')
@unittest.skipIf(OPJ_DATA_ROOT is None,
"OPJ_DATA_ROOT environment variable not set")
class TestXML_OpjDataRoot(unittest.TestCase):
"""Test suite for XML boxes, requires OPJ_DATA_ROOT."""

View file

@ -109,21 +109,6 @@ class TestJp2k(unittest.TestCase):
rgb_from_idx[r, c] = palette[idx[r, c]]
np.testing.assert_array_equal(rgb, rgb_from_idx)
def test_no_cxform_cmap(self):
"""Bands as physically ordered, not as physically intended"""
# This file has the components physically reversed. The cmap box
# tells the decoder how to order them, but this flag prevents that.
filename = opj_data_file('input/conformance/file2.jp2')
j = Jp2k(filename)
ycbcr = j.read()
crcby = j.read(no_cxform=True)
expected = np.zeros(ycbcr.shape, ycbcr.dtype)
for k in range(crcby.shape[2]):
expected[:,:,crcby.shape[2] - k - 1] = crcby[:,:,k]
np.testing.assert_array_equal(ycbcr, expected)
def test_file_not_present(self):
"""Should error out if reading from a file that does not exist"""
# Verify that we error out appropriately if not given an existing file
@ -813,6 +798,21 @@ class TestJp2kOpjDataRoot(unittest.TestCase):
with self.assertRaises(RuntimeError):
j.read()
def test_no_cxform_cmap(self):
"""Bands as physically ordered, not as physically intended"""
# This file has the components physically reversed. The cmap box
# tells the decoder how to order them, but this flag prevents that.
filename = opj_data_file('input/conformance/file2.jp2')
j = Jp2k(filename)
ycbcr = j.read()
crcby = j.read(no_cxform=True)
expected = np.zeros(ycbcr.shape, ycbcr.dtype)
for k in range(crcby.shape[2]):
expected[:,:,crcby.shape[2] - k - 1] = crcby[:,:,k]
np.testing.assert_array_equal(ycbcr, expected)
if __name__ == "__main__":

View file

@ -965,6 +965,19 @@ class TestPrintingOpjDataRoot(unittest.TestCase):
actual = fake_out.getvalue().strip()
self.assertEqual(actual, fixtures.issue_183_colr)
def test_bom(self):
"""Byte order markers are illegal in UTF-8. Issue 185"""
filename = opj_data_file(os.path.join('input',
'nonregression',
'issue171.jp2'))
with warnings.catch_warnings():
warnings.simplefilter("ignore")
jp2 = Jp2k(filename)
with patch('sys.stdout', new=StringIO()) as fake_out:
# No need to verify, it's enough that we don't error out.
print(jp2)
self.assertTrue(True)
if __name__ == "__main__":
unittest.main()