File tree Expand file tree Collapse file tree 2 files changed +21
-3
lines changed
Expand file tree Collapse file tree 2 files changed +21
-3
lines changed Original file line number Diff line number Diff line change 1- # Copyright The IETF Trust 2014-2020 , All Rights Reserved
1+ # Copyright The IETF Trust 2014-2025 , All Rights Reserved
22# -*- coding: utf-8 -*-
33
44
@@ -741,6 +741,23 @@ def test_render_author_name(self):
741741 "J. Q." ,
742742 )
743743
744+ @patch ("ietf.utils.xmldraft.XMLDraft.__init__" , return_value = None )
745+ def test_get_title (self , mock_init ):
746+ xmldraft = XMLDraft ("fake" )
747+ self .assertTrue (mock_init .called )
748+ # Stub XML that does not have a front/title element
749+ xmldraft .xmlroot = lxml .etree .XML (
750+ "<rfc><front></front></rfc>" # no title
751+ )
752+ self .assertEqual (xmldraft .get_title (), "" )
753+
754+ # Stub XML that has a front/title element
755+ xmldraft .xmlroot = lxml .etree .XML (
756+ "<rfc><front><title>This Is the Title</title></front></rfc>"
757+ )
758+ self .assertEqual (xmldraft .get_title (), "This Is the Title" )
759+
760+
744761 def test_capture_xml2rfc_output (self ):
745762 """capture_xml2rfc_output reroutes and captures xml2rfc logs"""
746763 orig_write_out = xml2rfc_log .write_out
Original file line number Diff line number Diff line change 1- # Copyright The IETF Trust 2022, All Rights Reserved
1+ # Copyright The IETF Trust 2022-2025 , All Rights Reserved
22# -*- coding: utf-8 -*-
33import datetime
44import io
@@ -147,7 +147,8 @@ def parse_docname(xmlroot):
147147 return revmatch .group ('filename' ), revmatch .group ('rev' )
148148
149149 def get_title (self ):
150- return self .xmlroot .findtext ('front/title' ).strip ()
150+ title_text = self .xmlroot .findtext ('front/title' )
151+ return "" if title_text is None else title_text .strip ()
151152
152153 @staticmethod
153154 def parse_creation_date (date_elt ):
You can’t perform that action at this time.
0 commit comments