From 8e0a642ed29815e447368dd280c5733d50b62b95 Mon Sep 17 00:00:00 2001 From: Ruben Verweij Date: Tue, 15 Oct 2019 09:44:32 +0200 Subject: [PATCH] Fixes issue #25, adds unit tests and release 3.2.1 --- docs | 2 +- nd2reader/__init__.py | 2 +- setup.py | 2 +- sphinx/conf.py | 4 ++-- tests/test_reader.py | 25 +++++++++++++++++++++++++ 5 files changed, 30 insertions(+), 5 deletions(-) diff --git a/docs b/docs index e8e0d21..f700c23 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit e8e0d21ccc8121fc30e1296a05dadb8aa9e22efa +Subproject commit f700c239f8f9d7d1f99a3c10d9f67e2b3b8ef307 diff --git a/nd2reader/__init__.py b/nd2reader/__init__.py index 699ae3f..58ce376 100644 --- a/nd2reader/__init__.py +++ b/nd2reader/__init__.py @@ -1,4 +1,4 @@ from nd2reader.reader import ND2Reader from nd2reader.legacy import Nd2 -__version__ = '3.2.0' +__version__ = '3.2.1' diff --git a/setup.py b/setup.py index ff68ccc..2feef03 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,6 @@ from setuptools import setup -VERSION = '3.2.0' +VERSION = '3.2.1' if __name__ == '__main__': setup( diff --git a/sphinx/conf.py b/sphinx/conf.py index 5fed6d9..11fb81d 100644 --- a/sphinx/conf.py +++ b/sphinx/conf.py @@ -44,9 +44,9 @@ author = 'Ruben Verweij' # built documents. # # The short X.Y version. -version = '3.2.0' +version = '3.2.1' # The full version, including alpha/beta/rc tags. -release = '3.2.0' +release = '3.2.1' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/tests/test_reader.py b/tests/test_reader.py index 0e4d735..27980b9 100644 --- a/tests/test_reader.py +++ b/tests/test_reader.py @@ -1,6 +1,8 @@ import unittest import numpy as np +import struct +from pims import Frame from nd2reader.artificial import ArtificialND2 from nd2reader.exceptions import EmptyFileError from nd2reader.reader import ND2Reader @@ -41,3 +43,26 @@ class TestReader(unittest.TestCase): with ND2Reader('test_data/test_nd2_reader.nd2') as reader: timesteps = reader.timesteps self.assertEquals(len(timesteps), 0) + + def test_get_frame_2D(self): + # Best test we can do for now: + # test everything up to the actual unpacking of the frame data + with ArtificialND2('test_data/test_nd2_reader.nd2') as _: + with ND2Reader('test_data/test_nd2_reader.nd2') as reader: + + with self.assertRaises(struct.error) as exception: + frame = reader.get_frame_2D(c=0, t=0, z=0, x=0, y=0, v=0) + + self.assertEqual(str(exception.exception), "unpack requires a buffer of 8 bytes") + + def test_get_frame_vczyx(self): + # Best test we can do for now: + # test everything up to the actual unpacking of the frame data + with ArtificialND2('test_data/test_nd2_reader.nd2') as _: + with ND2Reader('test_data/test_nd2_reader.nd2') as reader: + + with self.assertRaises(struct.error) as exception: + frame = reader.get_frame_vczyx(c=0, t=0, z=0, x=0, y=0, v=0) + + self.assertEqual(str(exception.exception), "unpack requires a buffer of 8 bytes") +