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

Multiprocess plugins incompatible with mocks or docktests? #444

Open
FurcyPin opened this issue Jun 13, 2019 · 1 comment
Open

Multiprocess plugins incompatible with mocks or docktests? #444

FurcyPin opened this issue Jun 13, 2019 · 1 comment

Comments

@FurcyPin
Copy link

Hi,

I have a python projects that uses doctest for some tests and mocks for some other tests, and I use nose2 to run everything.

It works like a charm, but when I tried to enable the nose2.plugins.mp plugin for MultiProcess
testing I got error messages on all my tests that were using either doctest or mocks.

For test using mocks, I got errors that look like this:

======================================================================
ERROR: test_not_found (nose2.loader.LoadTestsFailure)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python3.6/unittest/mock.py", line 1179, in patched
    return func(*args, **keywargs)
TypeError: test_method() missing 1 required positional argument: 'mock_settings'

The test looks like this

    @mock.patch('dynaconf.settings.get', side_effect=test_settings)
    def test_method(self, mock_settings):
        "test something"

For test using doctest, I got errors that look like this:

======================================================================
ERROR: _my_function (some.Object)
Doctest: some.Object._my_function
----------------------------------------------------------------------
TypeError: _my_function() missing 3 required positional arguments: 'a', 'b', and 'c'

Where my doctest looks like this:

class Object():

    def _my_function(self, a, b, c):
        """

        Doctest:
        >>> Object()._my_function('a', 'b', 'c')
        hello

        :param a:
        :param b:
        :param c:
        :return:
        """
        print("hello")

If I disable the nose2.plugins.mp, everything works fine though.

stefanholek added a commit to stefanholek/nose2 that referenced this issue Jul 27, 2020
…#468)

Stop loadTestsFromName from accepting class methods when they are
decorated (with e.g. mock.patch) and thus of types.FunctionType.

Also fixes issue with mock.patch'ed test case methods not working
under the multiprocess plugin (nose-devs#444).
@stefanholek
Copy link
Collaborator

The mock.patch issue has been fixed in PR #472.

As for doctests: No, they don't work with the multiprocessing plugin.

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