Skip to content

Commit

Permalink
fix: add assertEquals compatibility for Python 3.12+ (#160)
Browse files Browse the repository at this point in the history
Looks like assertEquals() has been retired from unittest.TestCase.
We use `assertEqual()` now but we will allow users to use `assertEquals()` for existing checks.
  • Loading branch information
cletomartin authored Jul 30, 2024
1 parent b682473 commit 82e7d0b
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# [3.0.1](https://github.com/ComplianceAsCode/auditree-framework/releases/tag/v3.0.1)

- [CHANGED] Add compatibility with assertEquals() for Python 3.12+.

# [3.0.0](https://github.com/ComplianceAsCode/auditree-framework/releases/tag/v3.0.0)

- [CHANGED] Remove IBM findings notifier.
Expand Down
2 changes: 1 addition & 1 deletion compliance/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
# limitations under the License.
"""Compliance automation package."""

__version__ = "3.0.0"
__version__ = "3.0.1"
5 changes: 4 additions & 1 deletion compliance/check.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ def run(self, result=None):
def wrapper(method):
def check_failures():
method()
self.assertEquals(self.failures_count(), 0)
self.assertEqual(self.failures_count(), 0)

return check_failures

Expand Down Expand Up @@ -348,3 +348,6 @@ def _get_all_test_objs(self, results):
for info in results.values()
if info["test"].test.__class__ == self.__class__
]

# keep backward compatibility so users can still use assertEquals()
assertEquals = unittest.TestCase.assertEqual
4 changes: 4 additions & 0 deletions test/t_compliance/t_check/test_base_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,3 +212,7 @@ def test_add_partitioned_evidence_metadata(self):
}
},
)

def test_has_assertEquals(self):
"""Test assertEquals is still present"""
self.check.assertEquals(1, 1)

0 comments on commit 82e7d0b

Please sign in to comment.