Skip to content

mock.patch introspects original even when new_callable set #119600

Closed

Description

@rbtcollins

Bug report

Bug description:

In order to patch flask.g e.g. as in #84982, that proxies getattr must not be invoked. For that, mock must not try to read from the original object. In some cases that is unavoidable, e.g. when doing autospec. However, patch("flask.g", new_callable=MagicMock) should be entirely safe.

CPython versions tested on:

3.11, 3.12

Operating systems tested on:

Linux, macOS, Windows, Other

Linked PRs

Activity

  1. added a commit that references this issue on May 27, 2024
  2. added
    stdlibStandard Library Python modules in the Lib/ directory
    on May 27, 2024
  3. added a commit that references this issue on May 27, 2024
  4. added a commit that references this issue on Jun 10, 2024
  5. added a commit that references this issue on Jun 11, 2024
  6. added 2 commits that reference this issue on Jun 11, 2024
  7. added 2 commits that reference this issue on Jun 11, 2024
  8. added a commit that references this issue on Jun 30, 2024
  9. added a commit that references this issue on Jul 11, 2024
  10. added a commit that references this issue on Jul 17, 2024
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

    stdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions