| | import unittest |
| | import os |
| | import shutil |
| | from pyhwp.html_converter import HwpToHtmlConverter |
| |
|
| | class TestHwpToHtml(unittest.TestCase): |
| | def setUp(self): |
| | self.test_dir = 'test_output' |
| | if not os.path.exists(self.test_dir): |
| | os.mkdir(self.test_dir) |
| | |
| | |
| | self.dummy_hwp = 'dummy.hwp' |
| | with open(self.dummy_hwp, 'w') as f: |
| | f.write('dummy content') |
| |
|
| | def tearDown(self): |
| | if os.path.exists(self.test_dir): |
| | shutil.rmtree(self.test_dir) |
| | if os.path.exists(self.dummy_hwp): |
| | os.remove(self.dummy_hwp) |
| |
|
| | def test_instantiation(self): |
| | converter = HwpToHtmlConverter(self.dummy_hwp) |
| | self.assertIsNotNone(converter) |
| | self.assertEqual(converter.hwp_file, self.dummy_hwp) |
| |
|
| | def test_convert_file_not_found(self): |
| | converter = HwpToHtmlConverter('non_existent.hwp') |
| | with self.assertRaises(FileNotFoundError): |
| | converter.convert('output.html') |
| |
|
| | if __name__ == '__main__': |
| | unittest.main() |
| |
|