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.
 
 
 

30 lines
972 B

import unittest
from os import path
from nd2reader.artificial import ArtificialND2
from nd2reader.exceptions import InvalidVersionError
from nd2reader.parser import Parser
class TestParser(unittest.TestCase):
def create_test_nd2(self):
with ArtificialND2(self.test_file) as artificial:
artificial.close()
def setUp(self):
dir_path = path.dirname(path.realpath(__file__))
self.test_file = path.join(dir_path, 'test_data/test.nd2')
self.create_test_nd2()
def test_can_open_test_file(self):
self.create_test_nd2()
with open(self.test_file, 'rb') as fh:
parser = Parser(fh)
self.assertTrue(parser.supported)
def test_cannot_open_wrong_version(self):
with ArtificialND2(self.test_file, version=('a', 'b')) as artificial:
artificial.close()
with open(self.test_file, 'rb') as fh:
self.assertRaises(InvalidVersionError, Parser, fh)