def test_is_item(self): self.assertFalse(OrDefinitionItem.is_item("term")) self.assertFalse(OrDefinitionItem.is_item("term ")) self.assertTrue(OrDefinitionItem.is_item("term :")) self.assertTrue(OrDefinitionItem.is_item("term : ")) self.assertTrue(OrDefinitionItem.is_item("term : classifier")) self.assertFalse(OrDefinitionItem.is_item(":term : classifier")) self.assertFalse(OrDefinitionItem.is_item("term : classifier:")) # special cases header_with_object = 'component : class.component.instance' self.assertTrue(OrDefinitionItem.is_item(header_with_object)) header_with_trait = 'properies : Dict(Str, Any)' self.assertTrue(OrDefinitionItem.is_item(header_with_trait)) header_with_or = 'item : ModelIndex or None' self.assertTrue(OrDefinitionItem.is_item(header_with_or))
def test_parse(self): item = OrDefinitionItem.parse(['term', ' Definition.']) self.assertEqual(item, OrDefinitionItem('term', [], ['Definition.'])) item = OrDefinitionItem.parse([ 'term', ' Definition, paragraph 1.', '', ' Definition, paragraph 2.']) self.assertEqual( item, OrDefinitionItem( 'term', [], [ 'Definition, paragraph 1.', '', 'Definition, paragraph 2.'])) item = OrDefinitionItem.parse(['term :', ' Definition.']) self.assertEqual(item, OrDefinitionItem('term', [], ['Definition.'])) item = OrDefinitionItem.parse(['term : classifier', ' Definition.']) self.assertEqual( item, OrDefinitionItem('term', ['classifier'], ['Definition.'])) item = OrDefinitionItem.parse( ['term : classifier or classifier', ' Definition.']) self.assertEqual( item, OrDefinitionItem( 'term', ['classifier', 'classifier'], ['Definition.'])) item = OrDefinitionItem.parse( ['term : classifier', ' Block.', ' Definition.']) self.assertEqual( item, OrDefinitionItem( 'term', ['classifier'], ['Block.', ' Definition.']))