Conversation
… docs A number of TestCase assert helpers are documented with parameter names the methods do not actually have. assertIs is documented as taking first and second while the parameters are expr1 and expr2, assertRegex as taking regex while it is expected_regex, and so on, so the documented spelling raises TypeError as soon as an argument is passed by keyword. Use the names the methods really accept. Renaming the parameters in Lib/unittest/case.py instead would break code that already passes them by keyword, and typeshed has declared the real names since python/typeshed#2724. assertRaises, assertRaisesRegex, assertWarns and assertWarnsRegex keep their "callable, *args, **kwds" tail, which describes how they are called rather than their literal signature, but their leading parameters are renamed as well, because exception, warning and regex are simply the wrong names there. typeshed spells these four the same way: real names, same call form. The summary tables are left alone. They use short stand-in names such as a, b, exc and r throughout and are not meant to be read as signatures.
Documentation build overview
|
Author
|
Closing this myself. @picnixz pointed out on #158152 that I have been opening too many at once and that old issues nobody has revived are the wrong ones to pick up unasked — this is one of those, so it should not be sitting in the queue. The branch stays on my fork if the issue ever comes back to life. |
Author
|
Reopened. Closing this was my own overreaction to being told I had too many open, not something anyone asked for. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #79857.
The parameter names in the
unittestdocs do not match the ones the methods actually take, which matters because they are usable as keywords:while the docs say
assertIs(first, second, msg=None). Anyone who reads the page and writesassertIs(first=a, second=b)gets aTypeError.Checking every documented
assert*signature againstinspect.signature, there were 26 such names on main and none after this change.assertIs/assertIsNottakeexpr1/expr2,assertIsNone/assertIsNotNonetakeobj, the ordering comparisons takea/b,assertRaisestakesexpected_exception, and so on. The prose was updated along with each signature so it refers to the same names.The
assertRaisesfamily is left describingcallableandmsgeven though the runtime signature is(expected_exception, *args, **kwargs)— those names are how the docs explain the two call forms, and they are not claims about keywords.Docs only, no behaviour change, so no news entry.