Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve test_inspect #103553

Closed
sobolevn opened this issue Apr 15, 2023 · 0 comments
Closed

Improve test_inspect #103553

sobolevn opened this issue Apr 15, 2023 · 0 comments
Assignees
Labels
tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error

Comments

@sobolevn
Copy link
Member

sobolevn commented Apr 15, 2023

While working on #103406 I've noticed that there are some problems with test_inspect that we can easily fix.

List of problems I found:

  1. f3 = self.makeCallable('**c')
    self.assertEqualException(f3, '1, 2')
    self.assertEqualException(f3, '1, 2, a=1, b=2')
    f4 = self.makeCallable('*, a, b=0')
    self.assertEqualException(f3, '1, 2')
    self.assertEqualException(f3, '1, 2, a=1, b=2')
    Here f4 is not ever used, but f3 has duplicate asserts. It looks like a copy-paste error to me. I propose to add asserts for f4 as well
  2. # XXX: Python inconsistency
    # - for functions and bound methods: unexpected keyword 'c'
    # - for unbound methods: multiple values for keyword 'a'
    #self.assertEqualException(f, '1, c=3, a=2')
    Unbound methods do not exist anymore, so this comment is outdated. Probably, it should be removed and assert should be restored
  3. # XXX: success of this one depends on dict order
    ## self.assertEqualException(f, '2, 3, 4, a=1, c=5')
    It says that the result depends on the dict order. But, dicts are ordered now. Let's see if that possible to uncomment / modernize this test somehow
  4. psig = inspect.signature(partial(partial(test, 1), 2))
    This variable is not needed, because it is not used and there's an identical test right above it:
    self.assertEqual(self.signature(partial(partial(test, 1), 2)),
    ((('c', ..., int, "positional_or_keyword"),),
    42))
  5. There are also several unsused variables that can be removed durin this cleanup

Here's my PR :)

Linked PRs

@sobolevn sobolevn added type-bug An unexpected behavior, bug, or error tests Tests in the Lib/test dir labels Apr 15, 2023
sobolevn added a commit to sobolevn/cpython that referenced this issue Apr 15, 2023
@sobolevn sobolevn self-assigned this Apr 15, 2023
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Apr 15, 2023
…unused (pythonGH-103554)

(cherry picked from commit 4fe1c4b)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
miss-islington added a commit that referenced this issue Apr 15, 2023
…GH-103554)

(cherry picked from commit 4fe1c4b)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
carljm added a commit to carljm/cpython that referenced this issue Apr 17, 2023
* main:
  Remove `expert-*` from `project-updater` GH workflow (python#103579)
  pythongh-103583: Add codecs and maps to _codecs_* module state (python#103540)
  pythongh-48330: address review comments to PR-12271 (python#103209)
  pythongh-103527: Add multibytecodec.h as make dep for _codecs_* (python#103567)
  pythongh-103553: Improve `test_inspect`: add more assertions, remove unused (python#103554)
  pythonGH-103517: Improve tests for `pathlib.Path.walk()` (pythonGH-103518)
  pythongh-102114: Make dis print more concise tracebacks for syntax errors in str inputs (python#102115)
  pythonGH-78079: Fix UNC device path root normalization in pathlib (pythonGH-102003)
  pythongh-101517: Add regression test for a lineno bug in try/except* impacting pdb (python#103547)
  pythongh-103527: Add make deps for _codecs_* and _multibytecodec (python#103528)
  pythongh-103532: Fix reST syntax in NEWS entry (pythonGH-103544)
  pythongh-103532: Add NEWS entry (python#103542)
carljm added a commit to carljm/cpython that referenced this issue Apr 17, 2023
* superopt:
  update generated cases with new comment
  review comments
  Remove `expert-*` from `project-updater` GH workflow (python#103579)
  pythongh-103583: Add codecs and maps to _codecs_* module state (python#103540)
  pythongh-48330: address review comments to PR-12271 (python#103209)
  pythongh-103527: Add multibytecodec.h as make dep for _codecs_* (python#103567)
  pythongh-103553: Improve `test_inspect`: add more assertions, remove unused (python#103554)
  pythonGH-103517: Improve tests for `pathlib.Path.walk()` (pythonGH-103518)
  pythongh-102114: Make dis print more concise tracebacks for syntax errors in str inputs (python#102115)
  pythonGH-78079: Fix UNC device path root normalization in pathlib (pythonGH-102003)
  pythongh-101517: Add regression test for a lineno bug in try/except* impacting pdb (python#103547)
  pythongh-103527: Add make deps for _codecs_* and _multibytecodec (python#103528)
  pythongh-103532: Fix reST syntax in NEWS entry (pythonGH-103544)
  pythongh-103532: Add NEWS entry (python#103542)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

1 participant