[issue45028] module 'unittest.mock' has no attribute 'AsyncMock'

2021-08-27 Thread Phani Kumar Yadavilli


New submission from Phani Kumar Yadavilli :

The unittest.mock does not have AsyncMock. I tested the same code in 3.9 it 
works fine.

--
messages: 400400
nosy: wandermonk
priority: normal
severity: normal
status: open
title: module 'unittest.mock' has no attribute 'AsyncMock'
type: compile error
versions: Python 3.7

___
Python tracker 
<https://bugs.python.org/issue45028>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45028] module 'unittest.mock' has no attribute 'AsyncMock'

2021-08-27 Thread Phani Kumar Yadavilli


Phani Kumar Yadavilli  added the comment:

from unittest import mock

@mock.patch(
"project.celerytasks.embedder.BulkEmbedder.fetch_embedding",
mock.AsyncMock(return_value=embedding_response),
)
def test_document_embedding():

doc = {
"orgId": "orgtest"
}

doc = embed(document=doc, embedding_endpoint=embedding_endpoint)

assert doc["subdocuments"]

assert len(doc["title_embedding"]) == embedding_dim
assert len(doc["subdocuments"]) == len(doc["paragraphs"])

assert len(doc["subdocuments"][0][embedding_name]) == embedding_dim

Error:


ERROR collecting code/tests/test_embedder.py


tests/test_embedder.py:18: in 

mock.AsyncMock(return_value=embedding_response),

E   AttributeError: module 'unittest.mock' has no attribute 'AsyncMock'

==
short test summary info
===

ERROR tests/test_embedder.py - AttributeError: module 'unittest.mock' has
no attribute 'AsyncMock'

!!!
Interrupted: 1 error during collection
!!!

==
1 error in 6.02s
======

Regards
Phani kumar yadavilli

On Fri, Aug 27, 2021 at 1:19 PM Karthikeyan Singaravelan <
rep...@bugs.python.org> wrote:

>
> Karthikeyan Singaravelan  added the comment:
>
> Can you please add a sample script to reproduce the problem. It will be
> also helpful to add how you run the script and also attach the error
> message you are getting. Given that you have selected Python 3.7 version
> AsyncMock was added in Python 3.8 . For Python 3.7 you might want to use
> the backport of mock.
>
> --
> nosy: +xtreak
>
> ___
> Python tracker 
> <https://bugs.python.org/issue45028>
> ___
>

--

___
Python tracker 
<https://bugs.python.org/issue45028>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45028] module 'unittest.mock' has no attribute 'AsyncMock'

2021-08-27 Thread Phani Kumar Yadavilli


Phani Kumar Yadavilli  added the comment:

I am using python 3.7.

Regards
Phani kumar yadavilli

On Fri, Aug 27, 2021 at 7:49 PM Karthikeyan Singaravelan <
rep...@bugs.python.org> wrote:

>
> Karthikeyan Singaravelan  added the comment:
>
> What version of Python are you using?
>
> --
>
> ___
> Python tracker 
> <https://bugs.python.org/issue45028>
> ___
>

--

___
Python tracker 
<https://bugs.python.org/issue45028>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45028] module 'unittest.mock' has no attribute 'AsyncMock'

2021-08-27 Thread Phani Kumar Yadavilli


Phani Kumar Yadavilli  added the comment:

Sure, will do that.
Regards
Phani kumar yadavilli

On Fri, Aug 27, 2021 at 7:54 PM Karthikeyan Singaravelan <
rep...@bugs.python.org> wrote:

>
> Karthikeyan Singaravelan  added the comment:
>
> AsyncMock is a feature of Python 3.8 . Please upgrade to Python 3.8 or use
> mock backport for AsyncMock in Python 3.7
> https://github.com/testing-cabal/mock . I guess this can be closed as not
> a bug.
>
> --
>
> ___
> Python tracker 
> <https://bugs.python.org/issue45028>
> ___
>

--

___
Python tracker 
<https://bugs.python.org/issue45028>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com