Giter Club home page Giter Club logo

Comments (4)

tirkarthi avatar tirkarthi commented on September 4, 2024

Can you please test this with unittest.mock from python 3.9? Mock is a backport of the changes made in stdlib. Most probably it's an issue upstream that needs to be fixed and backported here.

from mock.

valeriupredoi avatar valeriupredoi commented on September 4, 2024

@tirkarthi cheers for your reply! this is the Python 3.9 unittest mock, that's why I added the way we import it in the test, the exception is raised like this:

>           if spec_arg and _is_async_obj(spec_arg):
E           ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

../miniconda3/envs/esmvalcore39-3/lib/python3.9/unittest/mock.py:409: ValueError

and a bit more info:

(esmvalcore39-3) valeriu@valeriu-PORTEGE-Z30-C:~/ESMValCore$ conda list mock
# packages in environment at /home/valeriu/miniconda3/envs/esmvalcore39-3:
#
# Name                    Version                   Build  Channel
pytest-mock               3.3.1                    pypi_0    pypi

installing an using the actual package mock:

(esmvalcore39-3) valeriu@valeriu-PORTEGE-Z30-C:~/ESMValCore$ conda list mock
# packages in environment at /home/valeriu/miniconda3/envs/esmvalcore39-3:
#
# Name                    Version                   Build  Channel
mock                      4.0.2                    pypi_0    pypi
pytest-mock               3.3.1                    pypi_0    pypi

and changing to using it rather than the unittest.mock results in the same error:

spec_arg = array([4, 4])

    def __new__(cls, *args, **kw):
        # every instance has its own class
        # so we can create magic methods on the
        # class without stomping on other mocks
        bases = (cls,)
        if not issubclass(cls, AsyncMockMixin):
            # Check if spec is an async object or function
            bound_args = _MOCK_SIG.bind_partial(cls, *args, **kw).arguments
            spec_arg = bound_args.get('spec_set', bound_args.get('spec'))
>           if spec_arg and _is_async_obj(spec_arg):
E           ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

../miniconda3/envs/esmvalcore39-3/lib/python3.9/site-packages/mock/mock.py:411: ValueError

Please let me know what else should I try, cheers for your assistance 🍺

from mock.

cjw296 avatar cjw296 commented on September 4, 2024

This package is a rolling backport of unittest.mock.
As such, any problems you encounter most likely need to be fixed upstream.

Please can you try and reproduce the problem on the latest release of Python 3, including alphas, and replace any import from mock with ones from unittest.mock.

If the issue still occurs, then please report upstream through https://bugs.python.org/ as it will need to be fixed there so that it can be backported here and released to you.

If not, reply with what you find out and we can re-open this issue.

from mock.

valeriupredoi avatar valeriupredoi commented on September 4, 2024

Please can you try and reproduce the problem on the latest release of Python 3, including alphas, and replace any import from mock with ones from unittest.mock.

Cheers @cjw296 - we did just that, hence my posts above, mate! I will report upstream, cheers for your assistance - note however that the issue tracker for the package points here https://pypi.org/project/mock/ so you guys might want to add a descriptor note there saying that any issue should probably be first tested with unittest.mock and reported upstream - I find it a bit confusing if issues reported here get closed and bug reports need to be communicated upstream. Cheers, V 🍻

from mock.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.