You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

38 lines
1.9 KiB

import unittest
import warnings
from zolfa.nd2reader.legacy import Nd2
from zolfa.nd2reader.reader import ND2Reader
from zolfa.nd2reader.artificial import ArtificialND2
class TestLegacy(unittest.TestCase):
def test_init(self):
with ArtificialND2('test_data/legacy.nd2'):
with warnings.catch_warnings(record=True) as w:
# Cause all warnings to always be triggered.
warnings.simplefilter("always")
with Nd2('test_data/legacy.nd2') as reader:
self.assertIsInstance(reader.reader, ND2Reader)
self.assertTrue(issubclass(w[0].category, DeprecationWarning))
self.assertEquals(str(w[0].message), "The 'Nd2' class is deprecated, please consider using the new" +
" ND2Reader interface which uses pims.")
def test_misc(self):
with ArtificialND2('test_data/legacy.nd2'):
with Nd2('test_data/legacy.nd2') as reader:
representation = "\n".join(["<Deprecated ND2 %s>" % reader.reader.filename,
"Created: Unknown",
"Image size: %sx%s (HxW)" % (reader.height, reader.width),
"Frames: %s" % len(reader.frames),
"Channels: %s" % ", ".join(["%s" % str(channel) for channel
in reader.channels]),
"Fields of View: %s" % len(reader.fields_of_view),
"Z-Levels: %s" % len(reader.z_levels)
])
self.assertEquals(representation, str(reader))
# not implemented yet
self.assertEquals(reader.pixel_microns, None)
self.assertEquals(len(reader), 1)