|
| 1 | +import unittest |
| 2 | +import sys |
| 3 | +import os |
| 4 | +import odml |
| 5 | + |
| 6 | +try: |
| 7 | + from StringIO import StringIO |
| 8 | +except ImportError: |
| 9 | + from io import StringIO |
| 10 | + |
| 11 | + |
| 12 | +class TestTypes(unittest.TestCase): |
| 13 | + # TODO :- Write tests for JSONParser once it's completed. |
| 14 | + |
| 15 | + def setUp(self): |
| 16 | + self.file = 'doc/example_odMLs/THGTTG.odml' |
| 17 | + # Do not allow anything to be printed on STDOUT |
| 18 | + self.captured_stdout = StringIO() |
| 19 | + sys.stdout = self.captured_stdout |
| 20 | + |
| 21 | + def test_load_save(self): |
| 22 | + doc = odml.load(self.file) |
| 23 | + self.assertTrue(isinstance(doc, odml.doc.BaseDocument)) |
| 24 | + odml.save(doc, self.file + '_copy') |
| 25 | + os.remove(self.file + '_copy') |
| 26 | + |
| 27 | + def test_display(self): |
| 28 | + doc = odml.load(self.file) |
| 29 | + odml.display(doc) |
| 30 | + |
| 31 | + def test_invalid_parser(self): |
| 32 | + with self.assertRaises(NotImplementedError): |
| 33 | + odml.load(self.file, 'html') |
| 34 | + |
| 35 | + doc = odml.load(self.file) |
| 36 | + with self.assertRaises(NotImplementedError): |
| 37 | + odml.save(doc, self.file + '_copy_html', 'html') |
| 38 | + |
| 39 | + # odml.display not implemented |
| 40 | + # with self.assertRaises(NotImplementedError): |
| 41 | + # odml.display(doc, 'html') |
0 commit comments