From 675526f3221f3709ee601f257e4777a4b58f39c7 Mon Sep 17 00:00:00 2001 From: Matthew Feickert Date: Wed, 20 Mar 2024 03:58:10 -0500 Subject: [PATCH] Backport PR #2459: fix: Test xml.etree.ElementTree.Element truth value by 'is not None' --- src/pyhf/writexml.py | 2 +- tests/test_export.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pyhf/writexml.py b/src/pyhf/writexml.py index 8d3ecd3ca3..ff7aac800b 100644 --- a/src/pyhf/writexml.py +++ b/src/pyhf/writexml.py @@ -56,7 +56,7 @@ def _export_root_histogram(hist_name, data): # https://stackoverflow.com/a/4590052 def indent(elem, level=0): i = "\n" + level * " " - if elem: + if elem is not None: if not elem.text or not elem.text.strip(): elem.text = i + " " if not elem.tail or not elem.tail.strip(): diff --git a/tests/test_export.py b/tests/test_export.py index bba0aa224e..5c1ebed6e2 100644 --- a/tests/test_export.py +++ b/tests/test_export.py @@ -447,7 +447,7 @@ def test_integer_data(datadir, mocker): mocker.patch("pyhf.writexml._ROOT_DATA_FILE") channel = pyhf.writexml.build_channel(spec, channel_spec, {}) - assert channel + assert channel is not None @pytest.mark.parametrize(