1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
|
# ----------------------------------------------------------------------------
# Copyright (c) 2013--, scikit-bio development team.
#
# Distributed under the terms of the Modified BSD License.
#
# The full license is in the file LICENSE.txt, distributed with this software.
# ----------------------------------------------------------------------------
import unittest
from skbio.io._iosources import IOSource, Compressor
class TestIOSource(unittest.TestCase):
def setUp(self):
self.file = 'somepath'
self.options = {'a': 1, 'b': 2}
self.source = IOSource(self.file, self.options)
def test_attributes(self):
self.assertEqual(self.source.file, self.file)
self.assertEqual(self.source.options, self.options)
def test_can_read(self):
self.assertEqual(self.source.can_read(), False)
def test_can_write(self):
self.assertEqual(self.source.can_write(), False)
def test_get_reader(self):
with self.assertRaises(NotImplementedError):
self.source.get_reader()
def test_get_writer(self):
with self.assertRaises(NotImplementedError):
self.source.get_writer()
class TestCompressor(TestIOSource):
def setUp(self):
super(TestCompressor, self).setUp()
self.compressor = Compressor(self.file, self.options)
def test_can_write(self):
self.assertEqual(self.compressor.can_write(), True)
if __name__ == "__main__":
unittest.main()
|