Skip to content

Commit

Permalink
fix: error messages changed in Python 3.12
Browse files Browse the repository at this point in the history
  • Loading branch information
texastony committed Oct 30, 2023
1 parent 0dd7083 commit fb16f5b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 20 deletions.
24 changes: 11 additions & 13 deletions test/unit/test_caches_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,16 @@


def test_abstracts():
with pytest.raises(TypeError) as excinfo:
with pytest.raises(TypeError, match='instantiate abstract class CryptoMaterialsCache') as excinfo:
CryptoMaterialsCache()

excinfo.match(
r"Can't instantiate abstract class CryptoMaterialsCache with abstract methods {}".format(
", ".join(
[
"get_decryption_materials",
"get_encryption_materials",
"put_decryption_materials",
"put_encryption_materials",
]
)
)
)
exception = str(excinfo.value)
method_names = [
"get_decryption_materials",
"get_encryption_materials",
"put_decryption_materials",
"put_encryption_materials"
]
for name in method_names:
if exception.rfind(name) == -1:
raise AssertionError("{} missing from Exception Message".format(name))
13 changes: 6 additions & 7 deletions test/unit/test_material_managers_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,10 @@


def test_abstracts():
with pytest.raises(TypeError) as excinfo:
with pytest.raises(TypeError, match='instantiate abstract class CryptoMaterialsManager') as excinfo:
CryptoMaterialsManager()

excinfo.match(
r"Can't instantiate abstract class CryptoMaterialsManager with abstract methods {}".format(
", ".join(["decrypt_materials", "get_encryption_materials"])
)
)
method_names = ["decrypt_materials", "get_encryption_materials"]
exception = str(excinfo.value)
for name in method_names:
if exception.rfind(name) == -1:
raise AssertionError("{} missing from Exception Message".format(name))

0 comments on commit fb16f5b

Please sign in to comment.