From 3f98609fce42d09085875b24cb6693b7902556a7 Mon Sep 17 00:00:00 2001 From: Michael Kubacki Date: Mon, 30 Sep 2024 17:09:09 -0400 Subject: [PATCH] test.unit: Prevent bare except ruff errors Allows ruff to pass in the repo with no problem. Since these are unit tests, no investment is made to change behavior of the exception handler. Signed-off-by: Michael Kubacki --- .../database/test_instanced_fv_table.py | 2 +- tests.unit/parsers/test_dmar_parser.py | 22 +++++++++---------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/tests.unit/database/test_instanced_fv_table.py b/tests.unit/database/test_instanced_fv_table.py index cfb78aac..0dd8e5f5 100644 --- a/tests.unit/database/test_instanced_fv_table.py +++ b/tests.unit/database/test_instanced_fv_table.py @@ -11,7 +11,7 @@ from pathlib import Path import pytest -from common import Tree, empty_tree # noqa: F401 +from common import Tree from edk2toollib.database import Edk2DB, Fv from edk2toollib.database.tables import InstancedFvTable, InstancedInfTable from edk2toollib.uefi.edk2.path_utilities import Edk2Path diff --git a/tests.unit/parsers/test_dmar_parser.py b/tests.unit/parsers/test_dmar_parser.py index b635d008..58430397 100644 --- a/tests.unit/parsers/test_dmar_parser.py +++ b/tests.unit/parsers/test_dmar_parser.py @@ -34,7 +34,7 @@ def test_dmar_parser_dse_01h(self): try: dse_01_str = str(DmarParserTest.dse_t_01h) self.assertNotEqual(dse_01_str, None) - except: + except Exception: self.assertFalse(False, "Failed to convert Device Scope Entry type 0 object to string") def test_dmar_parser_dse_03h(self): @@ -53,7 +53,7 @@ def test_dmar_parser_dse_03h(self): try: dse_03_str = str(DmarParserTest.dse_t_03h) self.assertNotEqual(dse_03_str, None) - except: + except Exception: self.assertFalse(False, "Failed to convert Device Scope Entry type 3 object to string") def test_dmar_parser_dse_04h(self): @@ -72,7 +72,7 @@ def test_dmar_parser_dse_04h(self): try: dse_04_str = str(DmarParserTest.dse_t_04h) self.assertNotEqual(dse_04_str, None) - except: + except Exception: self.assertFalse(False, "Failed to convert Device Scope Entry type 4 object to string") def test_dmar_parser_drhd(self): @@ -111,13 +111,13 @@ def test_dmar_parser_drhd(self): try: drhd_xml = DmarParserTest.drhd_t.toXml() self.assertNotEqual(drhd_xml, None) - except: + except Exception: self.assertFalse(False, "Failed to convert DRHD object to xml") try: drhd_str = str(DmarParserTest.drhd_t) self.assertNotEqual(drhd_str, None) - except: + except Exception: self.assertFalse(False, "Failed to convert DRHD object to string") def test_dmar_parser_rmrr(self): @@ -164,13 +164,13 @@ def test_dmar_parser_rmrr(self): try: rmrr_xml = DmarParserTest.rmrr_t.toXml() self.assertNotEqual(rmrr_xml, None) - except: + except Exception: self.assertFalse(False, "Failed to convert RMRR object to xml") try: rmrr_str = str(DmarParserTest.rmrr_t) self.assertNotEqual(rmrr_str, None) - except: + except Exception: self.assertFalse(False, "Failed to convert RMRR object to string") def test_dmar_parser_acpi_header(self): @@ -246,13 +246,13 @@ def test_dmar_parser_acpi_header(self): try: dmar_xml = acpi_header.toXml() self.assertNotEqual(dmar_xml, None) - except: + except Exception: self.assertFalse(False, "Failed to convert ACPI header object to xml") try: dmar_str = str(acpi_header) self.assertNotEqual(dmar_str, None) - except: + except Exception: self.assertFalse(False, "Failed to convert ACPI header object to string") def test_dmar_parser_ivrs_full(self): @@ -408,13 +408,13 @@ def test_dmar_parser_ivrs_full(self): try: dmar_xml = dmar_table.toXml() self.assertNotEqual(dmar_xml, None) - except: + except Exception: self.assertFalse(False, "Failed to convert DMAR object to xml") try: dmar_str = str(dmar_table) self.assertNotEqual(dmar_str, None) - except: + except Exception: self.assertFalse(False, "Failed to convert DMAR object to string")