def test_read_character_property_duplicate_definitions(self): input_ = os.path.join(self.test_dir, 'test.txt') with open(input_, 'w') as wf: wf.write("DEFAULT 0 1 2\nDEFAULT 1 1 2") plugin = MeCabOovPlugin() with self.assertRaises(ValueError) as cm: plugin.read_character_property(input_) self.assertEqual('`DEFAULT` is already defined at line 2', cm.exception.args[0])
def test_read_character_property_with_too_few_columns(self): input_ = os.path.join(self.test_dir, 'test.txt') with open(input_, 'w') as wf: wf.write("DEFAULT 0 1\n") plugin = MeCabOovPlugin() with self.assertRaises(ValueError) as cm: plugin.read_character_property(input_) self.assertEqual('invalid format at line 1', cm.exception.args[0])
def test_read_character_property_with_undefined_type(self): input_ = os.path.join(self.test_dir, 'test.txt') with open(input_, 'w') as wf: wf.write("FOO 0 1 2\n") plugin = MeCabOovPlugin() with self.assertRaises(ValueError) as cm: plugin.read_character_property(input_) self.assertEqual('`FOO` is invalid type at line 1', cm.exception.args[0])
def test_read_character_property(self): input_ = os.path.join(self.test_dir, 'test.txt') with open(input_, 'w') as wf: wf.write("#\n \nDEFAULT 0 1 2\nALPHA 1 0 0\n0x0000...0x0002 ALPHA") plugin = MeCabOovPlugin() plugin.read_character_property(input_) self.assertFalse(plugin.categories[CategoryType.DEFAULT].is_invoke) self.assertTrue(plugin.categories[CategoryType.DEFAULT].is_group) self.assertEqual(2, plugin.categories[CategoryType.DEFAULT].length)