From 951dbc510b68c115ed2f9759b17d36dce5ed607b Mon Sep 17 00:00:00 2001 From: SET Date: Wed, 12 Aug 2020 15:47:14 -0300 Subject: [PATCH] Fixed XLSX tests when no links. --- tests/utils/context.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/utils/context.py b/tests/utils/context.py index fc5f0440..ec320a11 100644 --- a/tests/utils/context.py +++ b/tests/utils/context.py @@ -439,8 +439,10 @@ class TestContext(object): # Links are "Relationship"s links = {} nr = '{http://schemas.openxmlformats.org/officeDocument/2006/relationships}' - for r in root.find(ns+'hyperlinks').iter(ns+'hyperlink'): - links[r.attrib['ref']] = r.attrib[nr+'id'] + hlinks = root.find(ns+'hyperlinks') + if hlinks: + for r in hlinks.iter(ns+'hyperlink'): + links[r.attrib['ref']] = r.attrib[nr+'id'] # Read the strings strings = self.get_out_path(os.path.join('desc', 'xl', 'sharedStrings.xml')) strs = [t.text for t in ET.parse(strings).getroot().iter(ns+'t')]