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
1.0 KiB

8 years ago
  1. import unittest
  2. from os import path
  3. import numpy as np
  4. from nd2reader.artificial import ArtificialND2
  5. from nd2reader.reader import ND2Reader
  6. class TestReader(unittest.TestCase):
  7. def create_test_nd2(self):
  8. with ArtificialND2(self.test_file) as artificial:
  9. artificial.close()
  10. def setUp(self):
  11. dir_path = path.dirname(path.realpath(__file__))
  12. self.test_file = path.join(dir_path, 'test_data/test.nd2')
  13. def test_can_open_test_file(self):
  14. self.create_test_nd2()
  15. with ND2Reader(self.test_file) as reader:
  16. self.assertEqual(reader.filename, self.test_file)
  17. self.assertEqual(reader.pixel_type, np.float64)
  18. self.assertEqual(reader.sizes['x'], 0)
  19. self.assertEqual(reader.sizes['y'], 0)
  20. self.assertEqual(reader.sizes['z'], 1)
  21. self.assertEqual(reader.sizes['c'], 0)
  22. self.assertEqual(reader.sizes['t'], 1)
  23. def test_extension(self):
  24. self.assertTrue('nd2' in ND2Reader.class_exts())