Add the assert_ prefix to mock assertions that lack it

Proprietary

Since Python 3.12 a mock raises AttributeError for called_once_with() and the other assertion names without their assert_ prefix. Before, such a call asserted nothing. The prefix is added where the call is a statement of its own inside a function, the whole condition of an assert without a message, or the only argument of assertTrue(). The recipe matches the method name, and leaves a receiver whose type resolves to a class other than a mock. A test that passed only because nothing was asserted fails once it asserts.

org.openrewrite.python.migrate.AddMockAssertPrefix
mod run . --recipe=org.openrewrite.python.migrate.AddMockAssertPrefix

Install it once, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.