Comments (4)
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.
@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.
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.
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)
- should we mark as deprecated? HOT 3
- Add assert_not_called_with HOT 1
- Version 4.0 release HOT 3
- Syntax Error in 4.0.0 HOT 3
- Mock 4.0.0 "missing X positional argument" on instantiation of objects inherited from mock.MagicMock HOT 7
- Please add contribution guidelines HOT 1
- Should the backports follow upstream releases? instead of alpha/beta/rcs. HOT 3
- Remove universal wheel tag and hide 4.0.0b1 and 4.0.0 releases to stop tools finding them. HOT 14
- egg_info for package mock produced metadata for project name unknown HOT 5
- 4.0.x: 'ValueError: Sentinels must not start with _' and others HOT 7
- Can we get mock supported in python 3.8 HOT 2
- Can no longer patch flask.g HOT 9
- spec_set/autospec/spec seems to not be reading attributes defined in class body HOT 2
- Question on release 4.0.3 HOT 2
- Test test_bool_not_called_when_passing_spec_arg() fails (mixup unittest.mock vs mock?) HOT 4
- 4.0.3: pytest is failing HOT 5
- AsyncMock stubs for mypy in Python 3.7 HOT 5
- Error when inspecting the signature of AsyncMock() HOT 6
- Unclear error mocking a class and asserting called with HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mock.