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

Replace unmaintained test dependency 'asynctest' #433

Closed
OrangeTux opened this issue Mar 20, 2023 · 8 comments
Closed

Replace unmaintained test dependency 'asynctest' #433

OrangeTux opened this issue Mar 20, 2023 · 8 comments
Labels
enhancement New feature or request

Comments

@OrangeTux
Copy link
Contributor

Running the unit test in python3.11 fails with:

ImportError while loading conftest '/home/auke/projects/ocpp/tests/conftest.py'.
tests/conftest.py:2: in <module>
    from asynctest import CoroutineMock
../../.cache/pypoetry/virtualenvs/ocpp--w1P7PD0-py3.11/lib/python3.11/site-packages/asynctest/__init__.py:22: in <module>
    from .case import *
../../.cache/pypoetry/virtualenvs/ocpp--w1P7PD0-py3.11/lib/python3.11/site-packages/asynctest/case.py:54: in <module>
    import asynctest.selector
../../.cache/pypoetry/virtualenvs/ocpp--w1P7PD0-py3.11/lib/python3.11/site-packages/asynctest/selector.py:29: in <module>
    from . import mock
../../.cache/pypoetry/virtualenvs/ocpp--w1P7PD0-py3.11/lib/python3.11/site-packages/asynctest/mock.py:428: in <module>
    class _AwaitEvent:
../../.cache/pypoetry/virtualenvs/ocpp--w1P7PD0-py3.11/lib/python3.11/site-packages/asynctest/mock.py:433: in _AwaitEvent
    ???
E   AttributeError: module 'asyncio' has no attribute 'coroutine'ImportError while loading conftest '/home/auke/projects/ocpp/tests/conftest.py'.
tests/conftest.py:2: in <module>
    from asynctest import CoroutineMock
../../.cache/pypoetry/virtualenvs/ocpp--w1P7PD0-py3.11/lib/python3.11/site-packages/asynctest/__init__.py:22: in <module>
    from .case import *
../../.cache/pypoetry/virtualenvs/ocpp--w1P7PD0-py3.11/lib/python3.11/site-packages/asynctest/case.py:54: in <module>
    import asynctest.selector
../../.cache/pypoetry/virtualenvs/ocpp--w1P7PD0-py3.11/lib/python3.11/site-packages/asynctest/selector.py:29: in <module>
    from . import mock
../../.cache/pypoetry/virtualenvs/ocpp--w1P7PD0-py3.11/lib/python3.11/site-packages/asynctest/mock.py:428: in <module>
    class _AwaitEvent:
../../.cache/pypoetry/virtualenvs/ocpp--w1P7PD0-py3.11/lib/python3.11/site-packages/asynctest/mock.py:433: in _AwaitEvent
    ???
E   AttributeError: module 'asyncio' has no attribute 'coroutine'

It's a known issue of asynctest, see Martiusweb/asynctest#161.
The library is unmaintained and I don't expect a fix. So we should replace the library.

@OrangeTux OrangeTux added question Further information is requested and removed question Further information is requested labels Mar 20, 2023
@mgonzalezperna
Copy link

mgonzalezperna commented May 15, 2023

Good timing for finding this. I've replaced some of these CoroutineMocks with AsyncMock

@Jared-Newell-Mobility Jared-Newell-Mobility added the bug Something isn't working label Sep 8, 2023
@Jared-Newell-Mobility
Copy link
Contributor

Currently I see:
`
platform linux -- Python 3.11.5, pytest-7.2.0, pluggy-1.0.0
rootdir: /home/jared/PycharmProjects/ocpp/tests
plugins: cov-4.0.0, asyncio-0.20.3
asyncio: mode=Mode.STRICT
collected 96 items

test_charge_point.py .......... [ 10%]
test_exceptions.py .... [ 14%]
test_messages.py ................FF...... [ 39%]
test_routing.py . [ 40%]
v16/test_v16_charge_point.py .......... [ 51%]
v16/test_v16_enums.py .................................... [ 88%]
v20/test_v20_charge_point.py .... [ 92%]
v201/test_v201_charge_point.py .... [ 96%]
v201/test_v201_enums.py ...

___________________________________________________________________________________________________ test_call_representation ___________________________________________________________________________________________________

def test_call_representation():
    call = Call(unique_id="1", action=Action.Heartbeat, payload={})
  assert str(call) == "<Call - unique_id=1, action=Heartbeat, payload={}>"

E AssertionError: assert '<Call - uniq..., payload={}>' == '<Call - uniq..., payload={}>'
E - <Call - unique_id=1, action=Heartbeat, payload={}>
E + <Call - unique_id=1, action=Action.Heartbeat, payload={}>
E ? +++++++

test_messages.py:264: AssertionError

def test_call_result_representation():
    call = CallResult(
        unique_id="1", action=Action.Authorize, payload={"status": "Accepted"}
    )
  assert (
        str(call) == "<CallResult - unique_id=1, action=Authorize, payload={'status': "
        "'Accepted'}>"
    )

E assert "<CallResult ... 'Accepted'}>" == "<CallResult ... 'Accepted'}>"
E - <CallResult - unique_id=1, action=Authorize, payload={'status': 'Accepted'}>
E + <CallResult - unique_id=1, action=Action.Authorize, payload={'status': 'Accepted'}>
E ? +++++++

test_messages.py:272: AssertionError
'
with

`
from enum import Enum, auto

class Action(str, auto):
"""An Action is a required part of a Call message."""
`

I see now:

`
platform linux -- Python 3.11.5, pytest-7.2.0, pluggy-1.0.0
rootdir: /home/jared/PycharmProjects/ocpp/tests
plugins: cov-4.0.0, asyncio-0.20.3
asyncio: mode=Mode.STRICT
collected 96 items

test_charge_point.py .......... [ 10%]
test_exceptions.py .... [ 14%]
test_messages.py ........................ [ 39%]
test_routing.py . [ 40%]
v16/test_v16_charge_point.py .......... [ 51%]
v16/test_v16_enums.py .................................... [ 88%]
v20/test_v20_charge_point.py .... [ 92%]
v201/test_v201_charge_point.py .... [ 96%]
v201/test_v201_enums.py ... [100%]

====================================================================================================== 96 passed in 0.34s ======================================================================================================
platform linux -- Python 3.11.5, pytest-7.2.0, pluggy-1.0.0
rootdir: /home/jared/PycharmProjects/ocpp/tests
plugins: cov-4.0.0, asyncio-0.20.3
asyncio: mode=Mode.STRICT
collected 96 items

test_charge_point.py .......... [ 10%]
test_exceptions.py .... [ 14%]
test_messages.py ........................ [ 39%]
test_routing.py . [ 40%]
v16/test_v16_charge_point.py .......... [ 51%]
v16/test_v16_enums.py .................................... [ 88%]
v20/test_v20_charge_point.py .... [ 92%]
v201/test_v201_charge_point.py .... [ 96%]
v201/test_v201_enums.py ... [100%]

====================================================================================================== 96 passed in 0.34s ======================================================================================================
`

@Jared-Newell-Mobility
Copy link
Contributor

Same behaviour as in #447

@OrangeTux
Copy link
Contributor Author

#447 and this issue are independent issues that both causes the Python 3.11 build to fail.
We should address them both individually.

@Jared-Newell-Mobility
Copy link
Contributor

What I see when running the tests is only the test failing related to Enum's issue. Once this is corrected then all the test pass. I don't see the asynctest issue shown with the pytest output above. Does it still exist?

@OrangeTux
Copy link
Contributor Author

Interesting. I've no idea why it works now.

I think it's still a good idea to remove the dependency, since it's unmaintained. And as @mgonzalezperna stated, we can replace it with a type in the stdlib, reducing the list of dependencies.

@Jared-Newell-Mobility
Copy link
Contributor

I might then change the tag to an enhancement

@Jared-Newell-Mobility Jared-Newell-Mobility added enhancement New feature or request and removed bug Something isn't working labels Nov 15, 2023
@Jared-Newell-Mobility
Copy link
Contributor

PR #585 created and approved for inclusion in v1.0.0 - so closing issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

No branches or pull requests

3 participants