Skip to content

typing tests: test_overload_on_compiled_functions() may not work on alternative Python implementations #98713

Closed

Description

@AlexWaygood

Bug report

A few weeks ago, the typing_extensions backport library received a bug report that test_overload_on_compiled_functions(), a recently added test, failed when run on PyPy: python/typing_extensions#83. This is due to the fact that builtins.sum() and builtins.print() are not compiled functions on PyPy.

The same test exists in the CPython test suite (the test was ported over to typing_extensions in python/typing_extensions#73 after being added to the CPython test suite in #96479):

def test_overload_on_compiled_functions(self):
with patch("typing._overload_registry",
defaultdict(lambda: defaultdict(dict))):
# The registry starts out empty:
self.assertEqual(typing._overload_registry, {})
# This should just not fail:
overload(sum)
overload(print)
# No overloads are recorded (but, it still has a side-effect):
self.assertEqual(typing.get_overloads(sum), [])
self.assertEqual(typing.get_overloads(print), [])
.

I think the test should probably be marked with the @test.support.cpython_only decorator in the CPython test suite.

(Cc. @sobolevn, who added the test.)

Activity

  1. sobolevn commented on Oct 26, 2022

    @sobolevn
    Member

    Yes, I will send a PR for that!

  2. self-assigned this
    on Oct 26, 2022
  3. added a commit that references this issue on Oct 26, 2022
  4. added a commit that references this issue on Oct 26, 2022
  5. added 2 commits that reference this issue on Oct 26, 2022
  6. AlexWaygood commented on Oct 26, 2022

    @AlexWaygood
    MemberAuthor

    Thanks for the fix @sobolevn!

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

Metadata

Metadata

Assignees

Labels

testsTests in the Lib/test dirtopic-typingtype-bugAn unexpected behavior, bug, or error

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions