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

test_actor_with_mocked_method_works fails #85

Closed
mcepl opened this issue Dec 2, 2019 · 2 comments
Closed

test_actor_with_mocked_method_works fails #85

mcepl opened this issue Dec 2, 2019 · 2 comments

Comments

@mcepl
Copy link

mcepl commented Dec 2, 2019

When building packages for openSUSE, I get this failed test:

[   36s] =================================== FAILURES ===================================
[   36s] ________________ test_actor_with_mocked_method_works[threading] ________________
[   36s] 
[   36s] actor_class = <class 'tests.proxy.test_mocking.ActorForMocking'>
[   36s] stop_all = None
[   36s] mocker = <pytest_mock.plugin.MockFixture object at 0x7f3ce7cc3fd0>
[   36s] 
[   36s]     def test_actor_with_mocked_method_works(actor_class, stop_all, mocker):
[   36s]         mock = mocker.MagicMock(return_value='mocked method return')
[   36s] >       with mocker.patch.object(actor_class, 'a_method', new=mock):
[   36s] 
[   36s] tests/proxy/test_mocking.py:72: 
[   36s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
[   36s] /usr/lib/python2.7/site-packages/pytest_mock/plugin.py:159: in object
[   36s]     self._enforce_no_with_context(inspect.stack())
[   36s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
[   36s] 
[   36s] self = <pytest_mock.plugin._Patcher object at 0x7f3ce7cc3790>
[   36s] stack = [(<frame object at 0x55eac2cac980>, '/usr/lib/python2.7/site-packages/pytest_mock/plugin.py', 159, 'object', ['       ...ackages/pluggy/manager.py', 92, '_hookexec', ['        return self._inner_hookexec(hook, methods, kwargs)\n'], 0), ...]
[   36s] 
[   36s]     def _enforce_no_with_context(self, stack):
[   36s]         """raises a ValueError if mocker is used in a with context"""
[   36s]         caller = stack[1]
[   36s]         frame = caller[0]
[   36s]         info = inspect.getframeinfo(frame)
[   36s]         code_context = " ".join(info.code_context).strip()
[   36s]     
[   36s]         if code_context.startswith("with mocker."):
[   36s]             raise ValueError(
[   36s] >               "Using mocker in a with context is not supported. "
[   36s]                 "https://github.com/pytest-dev/pytest-mock#note-about-usage-as-context-manager"
[   36s]             )
[   36s] E           ValueError: Using mocker in a with context is not supported. https://github.com/pytest-dev/pytest-mock#note-about-usage-as-context-manager
[   36s] 
[   36s] /usr/lib/python2.7/site-packages/pytest_mock/plugin.py:171: ValueError
[   36s] ============== 1 failed, 145 passed, 261 skipped in 1.34 seconds ===============

See https://github.com/pytest-dev/pytest-mock#note-about-usage-as-context-manager for explanation.

Complete build log with all details

@jodal jodal closed this as completed in 7f53d39 Dec 2, 2019
@jodal
Copy link
Owner

jodal commented Dec 2, 2019

Thanks for pointing this out! It seems we used pytest-mocker wrong. It has been fixed and a new release, 2.0.2, has been pushed to PyPI.

Cool that you're packaging this for openSUSE. I assume Pykka is a dependency of something else you're packaging? Is that Mopidy, or something else?

@mcepl
Copy link
Author

mcepl commented Dec 2, 2019

Cool that you're packaging this for openSUSE. I assume Pykka is a dependency
of something else you're packaging? Is that Mopidy, or something else?

I don’t think so, we apparently have some lover of the actor-based programming (which is The Right Thing™ anyway).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants