diff options
Diffstat (limited to 'silx/io/test/test_specfile.py')
-rw-r--r-- | silx/io/test/test_specfile.py | 32 |
1 files changed, 12 insertions, 20 deletions
diff --git a/silx/io/test/test_specfile.py b/silx/io/test/test_specfile.py index 0aef2e2..9236fee 100644 --- a/silx/io/test/test_specfile.py +++ b/silx/io/test/test_specfile.py @@ -25,9 +25,9 @@ __authors__ = ["P. Knobel", "V.A. Sole"] __license__ = "MIT" -__date__ = "03/08/2017" +__date__ = "17/01/2018" + -import gc import locale import logging import numpy @@ -36,7 +36,7 @@ import sys import tempfile import unittest -from silx.test import utils +from silx.utils import testutils from ..specfile import SpecFile, Scan from .. import specfile @@ -136,14 +136,14 @@ class TestSpecFile(unittest.TestCase): @classmethod def setUpClass(cls): fd, cls.fname1 = tempfile.mkstemp(text=False) - if sys.version < '3.0': + if sys.version_info < (3, ): os.write(fd, sftext) else: os.write(fd, bytes(sftext, 'ascii')) os.close(fd) fd2, cls.fname2 = tempfile.mkstemp(text=False) - if sys.version < '3.0': + if sys.version_info < (3, ): os.write(fd2, sftext[370:923]) else: os.write(fd2, bytes(sftext[370:923], 'ascii')) @@ -151,7 +151,7 @@ class TestSpecFile(unittest.TestCase): fd3, cls.fname3 = tempfile.mkstemp(text=False) txt = sftext[371:923] - if sys.version < '3.0': + if sys.version_info < (3, ): os.write(fd3, txt) else: os.write(fd3, bytes(txt, 'ascii')) @@ -177,16 +177,9 @@ class TestSpecFile(unittest.TestCase): self.scan1_no_fhdr_crash = self.sf_no_fhdr_crash[0] def tearDown(self): - del self.sf - del self.sf_no_fhdr - del self.scan1 - del self.scan1_2 - del self.scan25 - del self.scan1_no_fhdr - del self.sf_no_fhdr_crash - del self.scan1_no_fhdr_crash - del self.empty_scan - gc.collect() + self.sf.close() + self.sf_no_fhdr.close() + self.sf_no_fhdr_crash.close() def test_open(self): self.assertIsInstance(self.sf, SpecFile) @@ -376,7 +369,7 @@ class TestSpecFile(unittest.TestCase): self.assertEqual(self.scan25.mca.channels, []) - @utils.test_logging(specfile._logger.name, warning=1) + @testutils.test_logging(specfile._logger.name, warning=1) def test_empty_scan(self): """Test reading a scan with no data points""" self.assertEqual(len(self.empty_scan.labels), @@ -389,7 +382,7 @@ class TestSFLocale(unittest.TestCase): @classmethod def setUpClass(cls): fd, cls.fname = tempfile.mkstemp(text=False) - if sys.version < '3.0': + if sys.version_info < (3, ): os.write(fd, sftext) else: os.write(fd, bytes(sftext, 'ascii')) @@ -399,13 +392,12 @@ class TestSFLocale(unittest.TestCase): def tearDownClass(cls): os.unlink(cls.fname) locale.setlocale(locale.LC_NUMERIC, loc) # restore saved locale - gc.collect() def crunch_data(self): self.sf3 = SpecFile(self.fname) self.assertAlmostEqual(self.sf3[0].data_line(1)[2], 1.56) - del self.sf3 + self.sf3.close() @unittest.skipIf(not try_DE, "de_DE.utf8 locale not installed") def test_locale_de_DE(self): |