Skip to content

Add additional tests for new features in typing.py #90843

Closed

Description

@sobolevn
BPO 46685
Nosy @gvanrossum, @JelleZijlstra, @corona10, @miss-islington, @sobolevn, @Fidget-Spinner, @AlexWaygood
PRs
  • bpo-46685: improve test coverage of Self and Never in typing #31222
  • bpo-46685: cover TypeError of ForwardRef(1) in test_typing #31223
  • [3.10] bpo-46685: cover TypeError of ForwardRef(1) in test_typing (GH-31223) #31229
  • [3.9] bpo-46685: cover TypeError of ForwardRef(1) in test_typing (GH-31223) #31230
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2022-02-19.01:57:22.817>
    created_at = <Date 2022-02-08.20:03:46.542>
    labels = ['type-bug', 'tests', '3.11']
    title = 'Add additional tests for new features in `typing.py`'
    updated_at = <Date 2022-02-19.01:57:22.817>
    user = 'https://github.com/sobolevn'

    bugs.python.org fields:

    activity = <Date 2022-02-19.01:57:22.817>
    actor = 'JelleZijlstra'
    assignee = 'none'
    closed = True
    closed_date = <Date 2022-02-19.01:57:22.817>
    closer = 'JelleZijlstra'
    components = ['Tests']
    creation = <Date 2022-02-08.20:03:46.542>
    creator = 'sobolevn'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 46685
    keywords = ['patch']
    message_count = 6.0
    messages = ['412865', '412866', '412907', '412912', '412913', '413526']
    nosy_count = 7.0
    nosy_names = ['gvanrossum', 'JelleZijlstra', 'corona10', 'miss-islington', 'sobolevn', 'kj', 'AlexWaygood']
    pr_nums = ['31222', '31223', '31229', '31230']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue46685'
    versions = ['Python 3.11']

    Activity

    1. sobolevn commented on Feb 8, 2022

      @sobolevn
      MemberAuthor

      New features (like Self type and Never type), in my opinion, require some extra testing.

      Things that were not covered:

      • Inheritance from Self, only type(Self) is covered:
        def test_cannot_subclass(self):
        with self.assertRaises(TypeError):
        class C(type(Self)):
        pass
      • Equality and non-equality for Self and Never. We should be sure that NoReturn is not equal to Never, but they are equal to themselfs
      • get_type_hints with Never
      • get_origin with Self and Never types, it should return None for both cases
      • (not exactly related) I've also noticed that this line is not covered at all:
        raise TypeError(f"Forward reference must be a string -- got {arg!r}")

      Maybe there are some other cases?

      I will send a PR :)

    2. added
      3.11only security fixes
      testsTests in the Lib/test dir
      type-bugAn unexpected behavior, bug, or error
      on Feb 8, 2022
    3. JelleZijlstra commented on Feb 8, 2022

      @JelleZijlstra
      Member

      Thanks for catching these details! Please send a PR.

    4. corona10 commented on Feb 9, 2022

      @corona10
      Member

      New changeset d2d1d49 by Nikita Sobolev in branch 'main':
      bpo-46685: cover TypeError of ForwardRef(1) in test_typing (GH-31223)
      d2d1d49

    5. miss-islington commented on Feb 9, 2022

      @miss-islington
      Contributor

      New changeset d29bbc2 by Miss Islington (bot) in branch '3.10':
      bpo-46685: cover TypeError of ForwardRef(1) in test_typing (GH-31223)
      d29bbc2

    6. miss-islington commented on Feb 9, 2022

      @miss-islington
      Contributor

      New changeset bde3765 by Miss Islington (bot) in branch '3.9':
      bpo-46685: cover TypeError of ForwardRef(1) in test_typing (GH-31223)
      bde3765

    7. JelleZijlstra commented on Feb 19, 2022

      @JelleZijlstra
      Member

      New changeset 32e3e0b by Nikita Sobolev in branch 'main':
      bpo-46685: improve test coverage of Self and Never in typing (GH-31222)
      32e3e0b

    8. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      3.11only security fixestestsTests in the Lib/test dirtype-bugAn unexpected behavior, bug, or error

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions