FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

mock.patch decorating a generator returns a regular function. · Issue #71528 · python/cpython · GitHub

Repository navigation

mock.patch decorating a generator returns a regular function. #71528

Open

Description

mannequin
BPO 27341
Nosy @terryjreedy, @rbtcollins, @voidspace, @shoshber, @tirkarthi
Files
  • silentfail.py: example tests
  • actual.out: output
  • 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 = None
    created_at = <Date 2016-06-17.05:35:08.841>
    labels = ['type-bug', 'tests']
    title = 'mock.patch decorating a generator returns a regular function.'
    updated_at = <Date 2019-12-13.11:13:51.134>
    user = 'https://github.com/shoshber'

    bugs.python.org fields:

    activity = <Date 2019-12-13.11:13:51.134>
    actor = 'xtreak'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = ['Tests']
    creation = <Date 2016-06-17.05:35:08.841>
    creator = 'shoshber'
    dependencies = []
    files = ['43443', '43444']
    hgrepos = []
    issue_num = 27341
    keywords = []
    message_count = 6.0
    messages = ['268709', '268749', '268757', '268758', '268761', '268762']
    nosy_count = 5.0
    nosy_names = ['terry.reedy', 'rbcollins', 'michael.foord', 'shoshber', 'xtreak']
    pr_nums = []
    priority = 'normal'
    resolution = None
    stage = 'test needed'
    status = 'open'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue27341'
    versions = ['Python 3.5', 'Python 3.6']

    Activity

    1. shoshber commented on Jun 17, 2016

      shoshbermannequin
      MannequinAuthor

      (at least in my case)

      I committed two tests before I realized the tests were not being run: https://github.com/nipy/nipype/blob/abe7920a051f1570ccce4b71f26f50102d6e4e12/nipype/testing/tests/test_utils.py#L23

      I realized this afternoon, while writing some more tests, that tests with the patch decorator were all reported as "OK", even when I wanted them to fail. Turns out they aren't being run at all.

      I commented out all the yield statements, and the tests ran just as they should.

      I don't know exactly what is going on here, but might raising an error or warning be good here?

      Originally filed here: testing-cabal/mock#366

    2. added
      testsTests in the Lib/test dir
      type-bugAn unexpected behavior, bug, or error
      on Jun 17, 2016
    3. terryjreedy commented on Jun 18, 2016

      Member

      3.2 to 3.4 only get security fixes

      please provide a simple test that fails now and that you think should pass or at least warn.

    4. rbtcollins commented on Jun 18, 2016

      Member

      There are two related things here.

      Firstly, the generator's body will run without the patch (because the wrapping function has

      try:
      return decorated(..)
      finally:
      unpwatch()

      Secondly, the wrapping function is itself not a generator, and anything that introspects functions to see if they are generators will not detect the wrapped function as one - which is I suspect whats tripping nose up, but I haven't actually checked the nose code to see what its doing/expecting.

    5. changed the title [-]mock.patch decorator fails silently on generators[/-] [+]mock.patch decorating a generator returns a regular function.[/+] on Jun 18, 2016
    6. rbtcollins commented on Jun 18, 2016

      Member

      Once fixed in CPython, we'll put the backport in mock, for folk using older Python's.

    7. shoshber commented on Jun 18, 2016

      shoshbermannequin
      MannequinAuthor

      I attached a file with 4 tests and the output. nosetests reports that all four tests were executed. In reality, only two tests were executed.

    8. shoshber commented on Jun 18, 2016

      shoshbermannequin
      MannequinAuthor

      output

    9. 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

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

      Projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL