diff --git a/reqif/parsers/spec_object_parser.py b/reqif/parsers/spec_object_parser.py index 41e05cc..13bebc2 100644 --- a/reqif/parsers/spec_object_parser.py +++ b/reqif/parsers/spec_object_parser.py @@ -32,14 +32,10 @@ def parse(spec_object_xml) -> ReqIFSpecObject: ) xml_spec_values = spec_object_xml.find("VALUES") - attributes: Optional[List[SpecObjectAttribute]] = ( - AttributeValueParser.parse_attribute_values(xml_spec_values) + attributes: List[SpecObjectAttribute] = ( + AttributeValueParser.parse_attribute_values(xml_spec_values) or [] ) - # FIXME: Technically, we can get a ReqIF file where VALUES is empty. - # But don't want to break the interfaces for now. - assert attributes is not None - return ReqIFSpecObject( xml_node=spec_object_xml, description=spec_object_description, diff --git a/tests/unit/reqif/parsers/test_spec_object_parser.py b/tests/unit/reqif/parsers/test_spec_object_parser.py index ee5e3d8..2789f69 100644 --- a/tests/unit/reqif/parsers/test_spec_object_parser.py +++ b/tests/unit/reqif/parsers/test_spec_object_parser.py @@ -40,6 +40,22 @@ def test_01_nominal_case(): assert spec_object.attribute_map["TEST_FIELD_STATEMENT"].value == "Test statement" +def test_03_missing_values_element(): + """ReqIF-1.2 §10.8.36/§10.8.40: is optional; omitting it must not raise.""" + spec_object_string = """ + + + TEST_SPEC_OBJECT_TYPE + + + """ + + spec_object_xml = etree.fromstring(spec_object_string) + spec_object = SpecObjectParser.parse(spec_object_xml) + assert spec_object.identifier == "TEST_NO_VALUES_ID" + assert spec_object.attributes == [] + + def test_02_attributes_xhtml(): spec_object_string = """\