Skip to content

Use assertEqual instead of assertEquals, removed in Python 3.12 - #210

Open
FrimpsManu wants to merge 1 commit into
sassoftware:mainfrom
FrimpsManu:use-assertEqual
Open

FrimpsManu wants to merge 1 commit into
sassoftware:mainfrom
FrimpsManu:use-assertEqual

Conversation

@FrimpsManu

Copy link
Copy Markdown

unittest removed the deprecated assertEquals alias in Python 3.12, so test_builtins.py raises AttributeError there whenever the loadactionset call reports a problem. assertEqual is the documented replacement (Python 3.12 What's New).

-            self.assertEquals(r.status, None)
+            self.assertEqual(r.status, None)

self.assertEqual here goes through the compatibility wrapper in swat/utils/testing.py, which calls unittest.TestCase.assertEqual, so behaviour is unchanged on every Python version.

How it was made: with PatchAhead, a deterministic migration tool, reading the unittest section of CPython's 3.12 release notes. It also found the old names inside the compatibility wrappers in swat/utils/testing.py (assertEqual falling back to assertEquals, and so on) and deliberately left them alone, since rewriting them would make each wrapper call itself.

Testing: this test needs a CAS server, which I don't have, so I couldn't run it. The change is the one-for-one rename Python documents, and the file compiles. This is a change to a test, so there's no separate unit test for it.

Use of AI tools: the change itself came from PatchAhead, which is deterministic. Claude Code (an AI assistant) helped me find the issue, run the tool, and write this commit and description. That's recorded as Assisted-by: Claude Code in the commit.

Contributor Agreement (from ContributorAgreement.txt), accepted with the sign-off in the commit
Contributor Agreement

Version 1.2

To contribute to this project, you must (1) attest to your right to offer your 
contribution and (2) clearly indicate whether you used artificial intelligence 
tools to develop your contribution.

== (1) Your Right to Contribute ==

You must agree to and comply with the terms of the following agreement.
Complying with the agreement does not alter your right to use your
contributions for any other purpose.

        Developer's Certificate of Origin 1.1

        By making a contribution to this project, I certify that:

        (a) The contribution was created in whole or in part by me and I have 
            the right to submit it under the open source license indicated in 
            the file; or

        (b) The contribution is based upon previous work that, to the best of 
            my knowledge, is covered under an appropriate open source license 
            and I have the right under that license to submit that work with 
            modifications, whether created in whole or in part by me, under 
            the same open source license (unless I am permitted to submit 
            under a different license), as indicated in the file; or

        (c) The contribution was provided directly to me by some other person 
            who certified (a), (b) or (c) and I have not modified it.

        (d) I understand and agree that this project and the contribution are 
            public and that a record of the contribution (including all 
            personal information I submit with it, including my sign-off) is 
            maintained indefinitely and may be redistributed consistent with 
            this project or the open source license(s) involved.

Indicate your acceptance of the agreement by including a "sign-off" in any 
contribution you propose. The sign-off is a line of text that accompanies your 
proposed contribution, attesting that you have the right to provide it.

When proposing changes via source control systems (such as Git), you can 
comply with the agreement by adding the following line to your commit message:

	Signed-off-by: Firstname Lastname <user@domain>

For example:

	Signed-off-by: Random J. Developer <random@developer.example.org>

Please provide your real name (no pseudonyms or anonymous contributions). All 
changes accepted into the project's official source code must be accompanied 
by this sign-off.

== (2) Your Use of Generative AI Tools ==

You must note contributions generated in whole or in part by artificial
intelligence tools. In your comments or commit messages, provide any context
reviewers might need to understand the change, and explain which part(s) of
your proposed change came from the tool. Then follow the instructions below.

If you used a generative artificial intelligence tool to create your entire 
contribution, add the following additional line to your commit message:

	Generated-by: Assistant Name

For example:

	Generated-by: Claude Code

If you used a generative artificial intelligence tool to assist you in 
creating your contribution, add the following line to your commit message:

	Assisted-by: Assistant Name

For example:

	Assisted-by: GitHub Copilot

Signed-off-by: Augustine Manu-Frimpong 150844417+FrimpsManu@users.noreply.github.com

unittest removed the deprecated assertEquals alias in Python 3.12, so
this test raises AttributeError there when the loadactionset call
reports a problem. assertEqual is its documented replacement.

The change was made with PatchAhead, a deterministic migration tool.
Its other uses of old names in swat/utils/testing.py are compatibility
wrappers (assertEqual falling back to assertEquals on old Pythons) and
were deliberately left alone.

Signed-off-by: Augustine Manu-Frimpong <150844417+FrimpsManu@users.noreply.github.com>
Assisted-by: Claude Code

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant