From 196bb9de4716559c4dca7fc0e843ce661f526171 Mon Sep 17 00:00:00 2001 From: jevans Date: Tue, 16 Jul 2013 19:52:10 -0400 Subject: [PATCH] Closes #76. Issue was inapplicable. Patching the library handle wasn't appropriate since the tests are really concerned with reloading the entire package. imp.reload in setUpClass and tearDownClass really was the correct way to go. --- glymur/test/test_config.py | 15 ++++++--------- glymur/test/test_opj_suite.py | 2 +- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/glymur/test/test_config.py b/glymur/test/test_config.py index 7f3fb49..09370e0 100644 --- a/glymur/test/test_config.py +++ b/glymur/test/test_config.py @@ -25,6 +25,7 @@ import glymur from glymur import Jp2k from glymur.lib import openjp2 as opj2 + @unittest.skipIf(sys.hexversion < 0x03020000, "TemporaryDirectory introduced in 3.2.") @unittest.skipIf(glymur.lib.openjp2.OPENJP2 is None, @@ -33,23 +34,19 @@ class TestSuite(unittest.TestCase): @classmethod def setUpClass(cls): - # Monkey patch the package so as to ignore OPENJPEG if it exists. - cls.openjpeg = glymur.lib.openjpeg.OPENJPEG - glymur.lib.openjpeg.OPENJPEG = None + imp.reload(glymur) + imp.reload(glymur.lib.openjp2) @classmethod def tearDownClass(cls): - # Restore OPENJPEG - glymur.lib.openjpeg.OPENJPEG = cls.openjpeg - - def setUp(self): imp.reload(glymur) imp.reload(glymur.lib.openjp2) + + def setUp(self): self.jp2file = glymur.data.nemo() def tearDown(self): - imp.reload(glymur) - imp.reload(glymur.lib.openjp2) + pass def test_config_file_via_environ(self): """Verify that we can read a configuration file set via environ var.""" diff --git a/glymur/test/test_opj_suite.py b/glymur/test/test_opj_suite.py index 30c70af..ca233a2 100644 --- a/glymur/test/test_opj_suite.py +++ b/glymur/test/test_opj_suite.py @@ -216,7 +216,7 @@ class TestSuite(unittest.TestCase): 'baseline/conformance/c0p0_13.pgx') pgxdata = read_pgx(pgxfile) - np.testing.assert_array_equal(jpdata[:,:,0], pgxdata) + np.testing.assert_array_equal(jpdata[:, :, 0], pgxdata) @unittest.skip("Known failure in OPENJPEG test suite.") def test_ETS_C0P0_p0_14_j2k(self):