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 52 53 54 55
|
# ----------------------------------------------------------------------------
# Copyright (c) 2013--, scikit-bio development team.
#
# Distributed under the terms of the Modified BSD License.
#
# The full license is in the file COPYING.txt, distributed with this software.
# ----------------------------------------------------------------------------
import unittest
from skbio._base import SkbioObject, ElasticLines
class TestSkbioObject(unittest.TestCase):
def test_no_instantiation(self):
class Foo(SkbioObject):
pass
with self.assertRaises(TypeError):
Foo()
class TestElasticLines(unittest.TestCase):
def setUp(self):
self.el = ElasticLines()
def test_empty(self):
self.assertEqual(self.el.to_str(), '')
def test_add_line(self):
self.el.add_line('foo')
self.assertEqual(self.el.to_str(), 'foo')
def test_add_lines(self):
self.el = ElasticLines()
self.el.add_lines(['alice', 'bob', 'carol'])
self.assertEqual(self.el.to_str(), 'alice\nbob\ncarol')
def test_add_separator(self):
self.el.add_separator()
self.assertEqual(self.el.to_str(), '')
self.el.add_line('foo')
self.assertEqual(self.el.to_str(), '---\nfoo')
self.el.add_separator()
self.el.add_lines(['bar', 'bazzzz'])
self.el.add_separator()
self.assertEqual(self.el.to_str(),
'------\nfoo\n------\nbar\nbazzzz\n------')
if __name__ == '__main__':
unittest.main()
|