Skip to content

Commit 82e7d0b

Browse files
authored
fix: add assertEquals compatibility for Python 3.12+ (#160)
Looks like assertEquals() has been retired from unittest.TestCase. We use `assertEqual()` now but we will allow users to use `assertEquals()` for existing checks.
1 parent b682473 commit 82e7d0b

File tree

4 files changed

+13
-2
lines changed

4 files changed

+13
-2
lines changed

CHANGES.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# [3.0.1](https://github.com/ComplianceAsCode/auditree-framework/releases/tag/v3.0.1)
2+
3+
- [CHANGED] Add compatibility with assertEquals() for Python 3.12+.
4+
15
# [3.0.0](https://github.com/ComplianceAsCode/auditree-framework/releases/tag/v3.0.0)
26

37
- [CHANGED] Remove IBM findings notifier.

compliance/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313
# limitations under the License.
1414
"""Compliance automation package."""
1515

16-
__version__ = "3.0.0"
16+
__version__ = "3.0.1"

compliance/check.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ def run(self, result=None):
248248
def wrapper(method):
249249
def check_failures():
250250
method()
251-
self.assertEquals(self.failures_count(), 0)
251+
self.assertEqual(self.failures_count(), 0)
252252

253253
return check_failures
254254

@@ -348,3 +348,6 @@ def _get_all_test_objs(self, results):
348348
for info in results.values()
349349
if info["test"].test.__class__ == self.__class__
350350
]
351+
352+
# keep backward compatibility so users can still use assertEquals()
353+
assertEquals = unittest.TestCase.assertEqual

test/t_compliance/t_check/test_base_check.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,3 +212,7 @@ def test_add_partitioned_evidence_metadata(self):
212212
}
213213
},
214214
)
215+
216+
def test_has_assertEquals(self):
217+
"""Test assertEquals is still present"""
218+
self.check.assertEquals(1, 1)

0 commit comments

Comments
 (0)