From 597ca64f9fde8f1053f288d833c831359233d761 Mon Sep 17 00:00:00 2001 From: Sean Whalen Date: Fri, 21 Nov 2025 00:09:28 -0500 Subject: [PATCH] Clean up tests --- tests.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/tests.py b/tests.py index 09310d8..31498db 100644 --- a/tests.py +++ b/tests.py @@ -63,7 +63,9 @@ class Test(unittest.TestCase): data = f.read() print("Testing {0}: ".format(file), end="") xmlout = parsedmarc.extract_report(data) - xmlin = open("samples/extract_report/nice-input.xml").read() + xmlin_file = open("samples/extract_report/nice-input.xml") + xmlin = xmlin_file.read() + xmlin_file.close() self.assertTrue(compare_xml(xmlout, xmlin)) print("Passed!") @@ -83,7 +85,9 @@ class Test(unittest.TestCase): file = "samples/extract_report/nice-input.xml.gz" print("Testing {0}: ".format(file), end="") xmlout = parsedmarc.extract_report_from_file_path(file) - xmlin = open("samples/extract_report/nice-input.xml").read() + xmlin_file = open("samples/extract_report/nice-input.xml") + xmlin = xmlin_file.read() + xmlin_file.close() self.assertTrue(compare_xml(xmlout, xmlin)) print("Passed!") @@ -93,12 +97,13 @@ class Test(unittest.TestCase): file = "samples/extract_report/nice-input.xml.zip" print("Testing {0}: ".format(file), end="") xmlout = parsedmarc.extract_report_from_file_path(file) - print(xmlout) - xmlin = minify_xml(open("samples/extract_report/nice-input.xml").read()) - print(xmlin) + xmlin_file = open("samples/extract_report/nice-input.xml") + xmlin = minify_xml(xmlin_file.read()) + xmlin_file.close() self.assertTrue(compare_xml(xmlout, xmlin)) - xmlin = minify_xml(open("samples/extract_report/changed-input.xml").read()) - print(xmlin) + xmlin_file = open("samples/extract_report/changed-input.xml") + xmlin = xmlin_file.read() + xmlin_file.close() self.assertFalse(compare_xml(xmlout, xmlin)) print("Passed!")